Home | History | Annotate | Download | only in tlsdate
      1 #!/bin/sh
      2 
      3 run_test() {
      4 	# Clear the last results
      5 	rm -f "$1"/result
      6 	[ -x "$1"/setup ] && "$1"/setup
      7 	if [ -r "$1"/tlsdated-flags ]; then
      8 		flags=$(cat "$1"/tlsdated-flags | sed "s/@TESTDIR@/$1/g")
      9 	elif [ -r "$1"/test.conf ]; then
     10 		flags="-U -w -p -r -l -s -b -f $1/test.conf -v"
     11 	else
     12 		flags="-U -w -p -r -l -s -b -f test.conf -v"
     13 	fi
     14 	# flags are deliberately unquoted here so that they'll be interpolated
     15 	(test -x "$1"/input.sh && "$1"/input.sh) |
     16 	   timeout 8 src/tlsdated $flags -- "$1"/subproc.sh  \
     17 		   >"$1"/run-output 2>"$1"/run-err
     18 	[ -x "$1"/teardown ] && "$1"/teardown
     19 }
     20 
     21 test_passed() {
     22 	f="$t"/result
     23 	test -f "$f" && grep -q ok "$f"
     24 }
     25 
     26 total=0
     27 passed=0
     28 
     29 if ! test -x src/test/emit; then
     30   echo "Make sure src/test/emit has been built (make check)!"
     31   exit 1
     32 fi
     33 for t in tests/*; do
     34 	[ ! -d "$t" ] && continue
     35 	name="$(basename "$t")"
     36 	echo -n "$name: "
     37 	run_test "$t"
     38 	if test_passed "$t"; then
     39 		echo "ok"
     40 		passed=$((passed + 1))
     41 	else
     42 		echo "failed"
     43 	fi
     44 	total=$((total + 1))
     45 done
     46 echo "Passed: $passed/$total"
     47 [ $passed != $total ]
     48 exit $?
     49