[BACK]Return to run CVS log [TXT][DIR] Up to [cvs] / v6shell / tests

File: [cvs] / v6shell / tests / run (download)

Revision 1.5, Sat Dec 15 21:01:08 2018 UTC (2 months, 1 week ago) by jneitzel
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +2 -2 lines

Update tests/* (- tests/*.log); 'io' to 'nl' changes...; that's all

: etsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;;
:
: "  The author of this file, J.A. Neitzel <jan (at) etsh (dot) nl>,  "
: "  hereby grants it to the public domain.                           "
:
: "  From:  https://etsh.nl/tests  "
:

:
: "  Exit w/ zero status (true) when all tests pass.       "
: "  Exit w/ non-zero status (false) when any tests fail.  "
:
: "  usage: ../etsh run [-newlog] {etsh | tsh}  "
:

: >>$0'' <'' ; : >>$1'' <'' ; : >>$2'' <'' ; : >>$3'' <''

if $uX = rootX if { fd2 -e echo Cannot run tests as superuser }\
	if { exit } if A = B
if $0X != runX -a $0X != ./runX if { fd2 -e echo Wrong directory }\
	if { exit } if A = B
if $# = # if { fd2 -e echo Invalid shell - etsh\(1\) required }\
	if { exit } if A = B

trap : 1 2 3 13 15 ; : trap
setenv PATH ..:./bin:$p ; : printenv PATH
umask 22 ; : umask
rm -f TestFailCount TestPassCount syntax_error
( : ) >TestFailCount ; ( : ) >TestPassCount

set C $#

if $# = 3 -a X$1 = X-newlog -a X$2 = Xetsh -a X$3 = Xtsh goto NewLog

: Again - " Check for correct usage and/or test other binary. "

	if ! \( \( $# = 1 -o $# = 2 \) -a \( $1X = etshX -o $1X = tshX \) \) \
	    if {\
		fd2 -e echo usage: ../etsh run \[-newlog\] \{etsh \| tsh\} }\
		    if { exit } if A = B
	: fallthrough

: NewLog - " Generate new test logs if needed. "

	if X$1 != X-newlog goto ab-PreRun
	if ! -d CVS if {\
	     fd2 -e echo run: Need CVS checkout to generate new test logs\
	} if { exit } if A = B
	rm -f test0[1-8]_etsh.log
	rm -f test0[1-8]_tsh.log
	fd2 $2 test01 >test01_$2.log ; fd2 $3 test01 >test01_$3.log
	fd2 $2 test02 >test02_$2.log ; fd2 $3 test02 >test02_$3.log
	fd2 $2 test03 >test03_$2.log ; fd2 $3 test03 >test03_$3.log
	fd2 -f/dev/null $2 test04 >test04_$2.log
	fd2 -f/dev/null $3 test04 >test04_$3.log
	fd2 $2 test05 $2 >test05_$2.log ; fd2 $3 test05 $3 >test05_$3.log
	rm -f syntax_error
	fd2 $2 test08 >test08_$2.log ; fd2 $3 test08 >test08_$3.log
	( : ) >test06_$2.log ; ( : ) >test07_$2.log
	fd2 $2 test06 >test06_$2.log
	fd2 $2 test07 >test07_$2.log
	mv CVS .CVS ; : " move CVS to .CVS for a moment... "
	: " log file name cannot contain 'CVS', but 'cvs' is ok "
	( : ) >test06_$2_nocvsdir.log ; ( : ) >test07_$2_nocvsdir.log
	fd2 $2 test06 >test06_$2_nocvsdir.log
	fd2 $2 test07 >test07_$2_nocvsdir.log
	mv .CVS CVS ; : " ..., and move it back. "
	shift
	: fallthrough

: ab-PreRun - " Prepare $a & $b before BinCheck and Run. "

	set a 'Testing etsh binary '
	set b 'Testing tsh  binary '
	: fallthrough

: BinCheck - " Ensure that needed binaries are present and executable. "

if ! -x ../$1 if { fd2 -e echo $1: Missing or not executable }\
	if { exit } if A = B
if $1X = etshX goto Jump
	if \( $C -eq 2 -a $# -eq 2 \) -o \( $C -eq 1 -a $# -eq 1 \) \
		fd2 -e -- now
	: which tsh
	goto Run
: Jump
	fd2 -e -- now
	: which etsh
	: fallthrough

: Run - " Run appropriate tests w/ $1 binary. "

	if $1 = etsh fd2 -e -- echo -n "$a"
	if $1 =  tsh fd2 -e -- echo -n "$b"
	fd2 $1 test01 | diff -u test01_$1.log -
	if $? != 0 if { fd2 -e echo $1: Test 1 Failed } echo >>TestFailCount
	echo >>TestPassCount
	fd2 -e -- echo -n .\ 
	fd2 $1 test02 | diff -u test02_$1.log -
	if $? != 0 if { fd2 -e echo $1: Test 2 Failed } echo >>TestFailCount
	echo >>TestPassCount
	fd2 -e -- echo -n .\ 
	fd2 $1 test03 | diff -u test03_$1.log -
	if $? != 0 if { fd2 -e echo $1: Test 3 Failed } echo >>TestFailCount
	echo >>TestPassCount
	fd2 -e -- echo -n .\ 
	fd2 -f/dev/null $1 test04 | diff -u test04_$1.log -
	if $? != 0 if { fd2 -e echo $1: Test 4 Failed } echo >>TestFailCount
	echo >>TestPassCount
	fd2 -e -- echo -n .\ 
	fd2 $1 test05 $1 | diff -u test05_$1.log -
	if $? != 0 if { fd2 -e echo $1: Test 5 Failed } echo >>TestFailCount
	echo >>TestPassCount
	fd2 -e -- echo -n .\ 
	if X$1 = Xtsh goto Next
		: " Tests 6 and 7 are for etsh only. "
		rm -f syntax_error
		if ! -d CVS goto noCVSdir
		    fd2 $1 test06 | diff -u test06_$1.log -
		    if $? != 0 if { fd2 -e echo $1: Test 6 Failed }\
			echo >>TestFailCount
		    echo >>TestPassCount
		    fd2 -e -- echo -n .\ 
		    fd2 $1 test07 | diff -u test07_$1.log -
		    if $? != 0 if { fd2 -e echo $1: Test 7 Failed }\
			echo >>TestFailCount
		    echo >>TestPassCount
		    fd2 -e -- echo -n .\ 
		    goto jump
		: noCVSdir
		    fd2 $1 test06 | diff -u test06_$1_nocvsdir.log -
		    if $? != 0 if { fd2 -e echo $1: Test 6 Failed }\
			echo >>TestFailCount
		    echo >>TestPassCount
		    fd2 -e -- echo -n .\ 
		    fd2 $1 test07 | diff -u test07_$1_nocvsdir.log -
		    if $? != 0 if { fd2 -e echo $1: Test 7 Failed }\
			echo >>TestFailCount
		    echo >>TestPassCount
		    fd2 -e -- echo -n .\ 
		    : fallthrough
		: jump
		    : fallthrough
	: Next
	fd2 $1 test08 | diff -u test08_$1.log -
	if $? != 0 if { fd2 -e echo $1: Test 8 Failed } echo >>TestFailCount
	echo >>TestPassCount
	fd2 -e echo . Done .
	shift
	if $# = 0 goto Done
	goto Again

: Done - " Print final results and exit false/true as needed. "

	fd2 -e -- now
	if ! -s TestFailCount goto TestsPassed
		( wc -l <TestFailCount | tr -d ' \t\n' ;\
		  echo ' Test(s) Failed' ) | fd2 -e cat
		rm -f TestFailCount TestPassCount syntax_error ; if A = B
		exit
	: TestsPassed
		( wc -l <TestPassCount | tr -d ' \t\n' ;\
		  echo ' Test(s) Passed' ) | fd2 -e cat
		rm -f TestFailCount TestPassCount syntax_error
		: zero status