Home | History | Annotate | Line # | Download | only in tests
      1 #!/bin/sh
      2 
      3 # This script is modelled after cmdtest:
      4 #   it takes all *.scripts and executes them and saves the stdout/err
      5 #   This output is compared against *.stdout/stderr.
      6 #   If no difference is found, the test is assumed as PASS (otherwise FAIL)
      7 #
      8 total_ret=0
      9 testsrc="${srcdir:-.}"
     10 for script in `ls -1 ${testsrc}/*.script | sort` ; do
     11 	base=`basename $script .script`
     12 	echo "Testing $base"
     13         $script > out.stdout 2> out.stderr
     14 
     15 	# check stdout for correctness
     16 	if [ -f ${testsrc}/$base.stdout ]; then
     17 		diff out.stdout ${testsrc}/$base.stdout
     18 		ret_stdout=$?
     19 	else
     20 		ret_stdout=0
     21 	fi
     22 
     23 	# check stderr for correctness
     24 	if [ -f ${testsrc}/$base.stderr ]; then
     25 		diff out.stderr ${testsrc}/$base.stderr
     26 		ret_stderr=$?
     27 	else
     28 		if [ -s out.stderr ] ; then
     29 			diff out.stderr /dev/null
     30 			ret_stderr=1
     31 		else
     32 			ret_stderr=0
     33 		fi
     34 	fi
     35 
     36 	if [ $ret_stdout -eq 0 -a $ret_stderr -eq 0 ]; then
     37 		echo "OK"
     38 	else
     39 		echo "FAIL"
     40 		total_ret=1
     41 	fi
     42 done
     43 
     44 exit $total_ret
     45