# Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
# Copyright (c) 1991 Version Technology.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met: (1) Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer. (2) Redistributions in binary form must reproduce the
# above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution. (3) All advertising materials mentioning
# features or use of this software must display the following
# acknowledgement: ``This product includes software developed by
# Version Technology.'' Neither the name of Version Technology nor
# the name of Peter J. Nicklin may be used to endorse or promote
# products derived from this software without specific prior written
# THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL VERSION TECHNOLOGY BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# Report problems and direct questions to nicklin@netcom.com
# $Header: ptest.sh,v 4.5 91/11/26 17:01:57 nicklin Exp $
# ptest - test a project module
# Author: Peter J. Nicklin
set argv
[1] = `echo $argv[1] | sed -e s/-F//`
else if ($#argv < 2) then
set argv
[1] = `echo $argv[1] | sed -e s/-P//`
else if ($#argv < 2) then
eval `chproject -f $argv[1]`
if ($status != 0) exit(1)
echo "ptest: bad option $argv[1]"
echo "ptest: usage: ptest [-d] [-F template] [-P projectname] [module ...]"
echo "ptest: no project environment"
# does the test case directory exist?
if (!(-e $PROJECT/test)) then
echo "ptest: $PROJECT/test: No such file or directory"
pushd $PROJECT/test >& /dev
/null
if ($test =~
*.a ||
-d $test ) set argv
= ($argv $test:r
)
echo "ptest: no test cases available"
# remove compilable test programs
# extract test files from archive
if (-e $PROJECT/test
/$test.a
) then
echo -n "${test}: extracting archive ... "
ar x
$PROJECT/test
/$test.a
else if (-d $PROJECT/test
/$test) then
echo -n "${test}: copying test ... "
cp $PROJECT/test
/$test/* .
echo "ptest: test case $test not found"
echo -n "compiling test ... "
if ( -e T
$test.mkmf
) then
mkmf
-cd -fT_makefile -FT$test.mkmf PROGRAM
=T
$test
mkmf
-cd -fT_makefile -M$template PROGRAM
=T
$test
make -f T_makefile
-s >& E
$test
if ($status != 0) goto badtest
echo -n "executing test ... "
# User supplied test script
if ($status != 0) goto badtest
# Default test script with input
.
/T
$test < I
$test |
& diff - O
$test >>& E
$test
if ($status != 0) goto badtest
# Default test script without input
.
/T
$test |
& diff - O
$test >>& E
$test
if ($status != 0) goto badtest
if (!($?debug
)) /bin
/rm -f E
$test [TIO
]$test* T_makefile
if (!($?debug
)) /bin
/rm -f [TIO
]$test* T_makefile