Home | History | Annotate | Line # | Download | only in test
ckscripts.sh revision 1.5
      1 #!/bin/sh -
      2 # This script runs the .ed scripts generated by mkscripts.sh
      3 # and compares their output against the .r files, which contain
      4 # the correct output
      5 
      6 PATH="/bin:/usr/bin:/usr/local/bin/:."
      7 ED=$1
      8 [ X"$ED" = X ] && ED="../ed"
      9 [ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
     10 
     11 # Run the *-err.ed scripts first, since these don't generate output;
     12 # rename then to *-err.ed~; they exit with non-zero status
     13 for i in *-err.ed; do
     14 	echo $i~
     15 	if $i; then
     16 		echo "*** The script $i~ exited abnormally  ***"
     17 	fi
     18 	mv $i $i~
     19 done >errs.o 2>&1
     20 
     21 # Run the remainding scripts; they exit with zero status
     22 for i in *.ed; do
     23 	base=`expr $i : '\([^.]*\)'`
     24 #	base=`echo $i | sed 's/\..*//'`
     25 #	base=`$ED - \!"echo \\\\$i" <<-EOF
     26 #		s/\..*
     27 #	EOF`
     28 	if $base.ed; then
     29 		if cmp -s $base.o $base.r; then :; else
     30 			echo "*** Output $base.o of script $i is incorrect ***"
     31 		fi
     32 	else
     33 		echo "*** The script $i exited abnormally ***"
     34 	fi
     35 done >scripts.o 2>&1
     36 
     37 grep -h '\*\*\*' errs.o scripts.o
     38