X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/9628bd06223d7e1730574ca0c93d76b1d39856b4..879d69d46fdf7ddf33beac6c32c7f2646d97d0ca:/tests/crossparse-c-random.sh diff --git a/tests/crossparse-c-random.sh b/tests/crossparse-c-random.sh index 8fb1b63..a800f3f 100755 --- a/tests/crossparse-c-random.sh +++ b/tests/crossparse-c-random.sh @@ -14,19 +14,52 @@ randomdecl=test/randomdecl$EXEEXT crossparse=test/crossparse$EXEEXT test -x $randomdecl || exit 77 +# Slow case: run tests one at a time to determine exactly which one failed. +first_failed() { + ff_count=0 + + while test $# -gt 0 + do + $crossparse "$1" 2>/dev/null || break + ff_count=`expr $ff_count + 1` + shift + done + + echo "$ff_count" +} + proc() { result=pass count=0 + set x while read decl do - count=`expr $count + 1` - $crossparse "$decl" || { result=fail - printf 'original input: %s\n' "$decl" 1>&2 - break + set "$@" "$decl" + + # Accumulate tests in $@ and run them in batches to avoid + # significant startup costs. + if test $# -gt 25; then + shift + $crossparse "$@" || { result=fail + tmp_count=`first_failed "$@"` + count=`expr $count + $tmp_count` + break } + count=`expr $count + $#` + set x + fi done + shift + if test $# -gt 0 && test x"$result" = x"pass"; then + tmp_count=$# + $crossparse "$@" || { result=fail + tmp_count=`first_failed "$@"` + } + count=`expr $count + $tmp_count` + fi + echo "result=$result" echo "count=$count" } @@ -39,6 +72,12 @@ eval_cmd=`exec 3>&1 } | proc >&3` eval "$eval_cmd" +if test x"$gen_status" != x"0"; then + printf '%s: %s failed with status=%d\n' \ + "$0" "$randomdecl" "$gen_status" 1>&2 + exit 1 +fi + expected_count=`expr "$TESTITER" + 0` if test x"$count" != x"$expected_count"; then printf '%s: failed after %d successful tests (out of %d)\n' \ @@ -46,5 +85,5 @@ if test x"$count" != x"$expected_count"; then exit 1 fi -test x"$result" = x"pass" && test x"$gen_status" = x"0" && exit 0 +test x"$result" = x"pass" && exit 0 exit 1