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