diff options
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/cond-address.c | 2 | ||||
| -rw-r--r-- | validation/cond-err-expand.c | 2 | ||||
| -rw-r--r-- | validation/fp-ops.c | 2 | ||||
| -rw-r--r-- | validation/fp2i-cast.c | 2 | ||||
| -rw-r--r-- | validation/nested-declarator.c | 4 | ||||
| -rw-r--r-- | validation/nested-declarator2.c | 4 | ||||
| -rw-r--r-- | validation/optim/canonical-cmp.c | 2 | ||||
| -rw-r--r-- | validation/optim/canonical-fcmp.c | 2 | ||||
| -rw-r--r-- | validation/option-parsing-00.c | 2 | ||||
| -rw-r--r-- | validation/option-parsing-01.c | 2 | ||||
| -rw-r--r-- | validation/reserved.c | 4 | ||||
| -rwxr-xr-x | validation/test-suite | 149 | ||||
| -rw-r--r-- | validation/typedef_shadow.c | 4 |
13 files changed, 91 insertions, 90 deletions
diff --git a/validation/cond-address.c b/validation/cond-address.c index 2a69f4b9..c9253ad0 100644 --- a/validation/cond-address.c +++ b/validation/cond-address.c @@ -10,5 +10,5 @@ int qux(void) { if (f && a) return 1; return 0; } * check-command: test-linearize -Wno-decl $file * check-output-ignore * - * check-excludes: VOID + * check-output-excludes: VOID */ diff --git a/validation/cond-err-expand.c b/validation/cond-err-expand.c index 93bbac15..7936a2d0 100644 --- a/validation/cond-err-expand.c +++ b/validation/cond-err-expand.c @@ -23,5 +23,5 @@ cond-err-expand.c:13:11: error: incompatible types in conditional expression (di * check-error-end * * check-output-ignore - * check-excludes: call.* __builtin_constant_p + * check-output-excludes: call.* __builtin_constant_p */ diff --git a/validation/fp-ops.c b/validation/fp-ops.c index 7f58a72f..71cb9848 100644 --- a/validation/fp-ops.c +++ b/validation/fp-ops.c @@ -7,7 +7,7 @@ _Bool ftst(double x) { return !x; } /* * check-name: floating-point ops - * check-command: ./test-linearize -Wno-decl $file + * check-command: test-linearize -Wno-decl $file * check-output-start fadd: diff --git a/validation/fp2i-cast.c b/validation/fp2i-cast.c index 08f8c925..98d7453e 100644 --- a/validation/fp2i-cast.c +++ b/validation/fp2i-cast.c @@ -26,5 +26,5 @@ ul d2ul(double a) { return a; } * check-command: test-linearize -Wno-decl $file * * check-output-ignore - * check-output-pattern-8-times: cast\\. + * check-output-pattern(8): cast\\. */ diff --git a/validation/nested-declarator.c b/validation/nested-declarator.c index 1efe20ce..f258d457 100644 --- a/validation/nested-declarator.c +++ b/validation/nested-declarator.c @@ -15,7 +15,7 @@ int i(void (void)(*f)); int j(int [2](*)); /* * check-name: nested declarator vs. parameters - * check-error-start: + * check-error-start nested-declarator.c:11:23: warning: missing identifier in declaration nested-declarator.c:11:23: error: Expected ; at the end of type declaration nested-declarator.c:11:23: error: got ( @@ -25,5 +25,5 @@ nested-declarator.c:14:18: error: Expected ) in function declarator nested-declarator.c:14:18: error: got ( nested-declarator.c:15:14: error: Expected ) in function declarator nested-declarator.c:15:14: error: got ( - * check-error-end: + * check-error-end */ diff --git a/validation/nested-declarator2.c b/validation/nested-declarator2.c index 345a04b0..983b7ef5 100644 --- a/validation/nested-declarator2.c +++ b/validation/nested-declarator2.c @@ -27,7 +27,7 @@ static int (-bad2); static void [2](*bad3); /* * check-name: more on handling of ( in direct-declarator - * check-error-start: + * check-error-start nested-declarator2.c:17:1: warning: non-ANSI definition of function 'w1' nested-declarator2.c:21:21: warning: non-ANSI function declaration of function '<noident>' nested-declarator2.c:22:16: warning: variadic functions must have one named argument @@ -37,5 +37,5 @@ nested-declarator2.c:26:13: error: Expected ) in nested declarator nested-declarator2.c:26:13: error: got - nested-declarator2.c:27:16: error: Expected ; at the end of type declaration nested-declarator2.c:27:16: error: got ( - * check-error-end: + * check-error-end */ diff --git a/validation/optim/canonical-cmp.c b/validation/optim/canonical-cmp.c index 19b41631..6f3b5180 100644 --- a/validation/optim/canonical-cmp.c +++ b/validation/optim/canonical-cmp.c @@ -21,7 +21,7 @@ uint uat(uint p, uint a) { return (123 < p) ? a : 0; } * check-name: canonical-cmp * check-command: test-linearize -Wno-decl $file * - * check-output-exclude: \$123, + * check-output-excludes: \$123, * * check-output-start seq: diff --git a/validation/optim/canonical-fcmp.c b/validation/optim/canonical-fcmp.c index e3e758a9..d098da64 100644 --- a/validation/optim/canonical-fcmp.c +++ b/validation/optim/canonical-fcmp.c @@ -20,7 +20,7 @@ int nfcmp_ge(double a) { return !(g < a); } * check-name: canonical-cmp * check-command: test-linearize -Wno-decl $file * - * check-output-exclude: \$123, + * check-output-excludes: \$123, * * check-output-start fcmp_eq: diff --git a/validation/option-parsing-00.c b/validation/option-parsing-00.c index 9b85943c..9dceab7f 100644 --- a/validation/option-parsing-00.c +++ b/validation/option-parsing-00.c @@ -1,5 +1,5 @@ /* * check-name: option parsing 00 - * check-command sparse -foptimize-xyz $file + * check-command: sparse -foptimize-xyz $file */ diff --git a/validation/option-parsing-01.c b/validation/option-parsing-01.c index e33a2ef0..a2875bd1 100644 --- a/validation/option-parsing-01.c +++ b/validation/option-parsing-01.c @@ -1,5 +1,5 @@ /* * check-name: option parsing 01 - * check-command sparse -fno-optimize-xyz $file + * check-command: sparse -fno-optimize-xyz $file */ diff --git a/validation/reserved.c b/validation/reserved.c index 29554560..6a2163e9 100644 --- a/validation/reserved.c +++ b/validation/reserved.c @@ -81,7 +81,7 @@ static int (__builtin_va_list); /* * check-name: const et.al. are reserved identifiers - * check-error-start: + * check-error-start reserved.c:1:12: error: Trying to use reserved word 'auto' as identifier reserved.c:2:12: error: Trying to use reserved word 'break' as identifier reserved.c:3:12: error: Trying to use reserved word 'case' as identifier @@ -154,5 +154,5 @@ reserved.c:77:12: error: Trying to use reserved word '__builtin_ms_va_list' as i reserved.c:78:12: error: Trying to use reserved word '__builtin_offsetof' as identifier reserved.c:79:12: error: Trying to use reserved word '__builtin_types_compatible_p' as identifier reserved.c:80:12: error: Trying to use reserved word '__builtin_va_list' as identifier - * check-error-end: + * check-error-end */ diff --git a/validation/test-suite b/validation/test-suite index 903a2b90..192fba30 100755 --- a/validation/test-suite +++ b/validation/test-suite @@ -42,6 +42,33 @@ vquiet="" quiet=0 abort=0 + +## +# verbose(string) - prints string if we are in verbose mode +verbose() +{ + [ "$V" -eq "1" ] && echo " $1" + return 0 +} + +## +# warning(string) - prints a warning +warning() +{ + [ "$quiet" -ne 1 ] && echo "warning: $1" + return 0 +} + +## +# error(string[, die]) - prints an error and exits with value die if given +error() +{ + [ "$quiet" -ne 1 ] && echo "error: $1" + [ -n "$2" ] && exit $2 + return 0 +} + + ## # get_tag_value(file) - get the 'check-<...>' tags & values get_tag_value() @@ -55,7 +82,6 @@ get_tag_value() check_output_ignore=0 check_output_contains=0 check_output_excludes=0 - check_output_pattern_obsolete=0 check_output_pattern=0 check_arch_ignore="" check_arch_only="" @@ -77,12 +103,23 @@ get_tag_value() check-output-ignore) check_output_ignore=1 ;; check-output-contains:) check_output_contains=1 ;; check-output-excludes:) check_output_excludes=1 ;; - check-output-pattern-) check_output_pattern_obsolete=1 ;; check-output-pattern) check_output_pattern=1 ;; check-arch-ignore:) arch=$(uname -m) check_arch_ignore="$val" ;; check-arch-only:) arch=$(uname -m) check_arch_only="$val" ;; + + check-description:) ;; # ignore + check-note:) ;; # ignore + check-warning:) ;; # ignore + check-error-start) ;; # ignore + check-error-end) ;; # ignore + check-output-start) ;; # ignore + check-output-end) ;; # ignore + check-should-pass) ;; # ignore, unused annotation + check-should-fail) ;; # ignore, unused annotation + check-should-warn) ;; # ignore, unused annotation + check-*) error "$1: unknown tag '$tag'" 1 ;; esac done << EOT $lines @@ -90,23 +127,6 @@ EOT } ## -# verbose(string) - prints string if we are in verbose mode -verbose() -{ - [ "$V" -eq "1" ] && echo " $1" - return 0 -} - -## -# error(string[, die]) - prints an error and exits with value die if given -error() -{ - [ "$quiet" -ne 1 ] && echo "error: $1" - [ -n "$2" ] && exit $2 - return 0 -} - -## # helper for has_(each|none)_patterns() has_patterns() { @@ -150,29 +170,6 @@ has_none_patterns() } ## -# nbr_patterns(ifile tag ofile) - does ofile contains the -# the patterns given by ifile's tags -# the right number of time? -nbr_patterns() -{ - ifile="$1" - patt="$2" - ofile="$3" - grep "$patt-[0-9][0-9]*-times:" "$ifile" | \ - sed -e "s/^.*$patt-\([0-9][0-9]*\)-times: *\(.*\)/\1 \2/" | \ - while read nbr pat; do - n=$(grep -s "$pat" "$ofile" | wc -l) - if [ "$n" -ne "$nbr" ]; then - error "test '$ifile' failed" - error " Pattern '$pat' expected $nbr times but got $n times" - return 1 - fi - done - - return $? -} - -## # minmax_patterns(ifile tag ofile) - does ofile contains the # the patterns given by ifile's tags # the right number of time? @@ -236,16 +233,17 @@ echo "$prog_name - a tiny automatic testing script" echo "Usage: $prog_name [option(s)] [command] [arguments]" echo echo "options:" -echo " -a|--abort abort the tests as soon as one fails" -echo " -q|--quiet be extra quiet while running the tests" +echo " -a|--abort Abort the tests as soon as one fails." +echo " -q|--quiet Be extra quiet while running the tests." echo echo "commands:" -echo " none runs the whole test suite" -echo " file ... runs the test suite on the given file(s)" -echo " single file runs the test in 'file'" -echo " format file [name [cmd]] helps writing a new test case using cmd" +echo " [file ...] Runs the test suite on the given file(s)." +echo " If a directory is given, run only those files." +echo " If no file is given, run the whole testsuite." +echo " single file Run the test in 'file'." +echo " format file [name [cmd]] Help writing a new test case using cmd." echo -echo " [command] help prints usage" +echo " [command] help Print usage." } disable() @@ -270,13 +268,14 @@ do_test() { test_failed=0 file="$1" + quiet=0 get_tag_value $file # can this test be handled by test-suite ? # (it has to have a check-name key in it) if [ "$check_name" = "" ]; then - echo "warning: test '$file' unhandled" + warning "$file: test unhandled" unhandled_tests=$(($unhandled_tests + 1)) return 2 fi @@ -331,7 +330,6 @@ do_test() actual_exit_value=$? must_fail=$check_known_to_fail - quiet=0 [ $must_fail -eq 1 ] && [ $V -eq 0 ] && quiet=1 known_ko_tests=$(($known_ko_tests + $must_fail)) @@ -371,13 +369,6 @@ do_test() test_failed=1 fi fi - if [ $check_output_pattern_obsolete -eq 1 ]; then - # verify the 'check-output-pattern-X-times' tags - nbr_patterns "$file" 'check-output-pattern' $file.output.got - if [ "$?" -ne "0" ]; then - test_failed=1 - fi - fi if [ $check_output_pattern -eq 1 ]; then # verify the 'check-output-pattern(...)' tags minmax_patterns "$file" 'check-output-pattern' $file.output.got @@ -438,6 +429,7 @@ do_format_help() { echo "Usage: $prog_name [option(s)] [--]format file [name [cmd]]" echo echo "options:" +echo " -a append the created test to the input file" echo " -f write a test known to fail" echo " -l write a test for linearized code" echo @@ -452,11 +444,14 @@ echo " cmd command to be used (defaults to 'sparse \$f do_format() { def_cmd="$default_cmd" + append=0 linear=0 fail=0 while [ $# -gt 1 ] ; do case "$1" in + -a) + append=1 ;; -f) fail=1 ;; -l) @@ -483,6 +478,7 @@ do_format() cmd=`eval echo $default_path/$fcmd` $cmd 1> $file.output.got 2> $file.error.got fexit_value=$? + [ "append" != 0 ] && exec >> $file cat <<_EOF /* @@ -515,26 +511,13 @@ _EOF return 0 } -while true; do +while [ "$#" -gt "0" ]; do case "$1" in -a|--abort) abort=1 - shift - continue ;; -q|--quiet) vquiet=1 - shift - continue - ;; - - '') - tests_list=`find . -name '*.c' | sed -e 's#^\./\(.*\)#\1#' | sort` - do_test_suite - ;; - *.c) - tests_list="$@" - do_test_suite ;; single|--single) @@ -545,18 +528,36 @@ while true; do 1) echo "$2 failed !";; 2) echo "$2 can't be handled by $prog_name";; esac + exit $failed ;; format|--format) shift do_format "$@" + exit 0 ;; - help | *) + help) do_usage exit 1 ;; + + *.c) + tests_list="$tests_list $1" + ;; + *) + if [ ! -d "$1" ]; then + do_usage + exit 1 + fi + tests_list="$tests_list $(find "$1" -name '*.c' | sort)" + ;; esac - break + shift done +if [ -z "$tests_list" ]; then + tests_list=`find . -name '*.c' | sed -e 's#^\./\(.*\)#\1#' | sort` +fi + +do_test_suite exit $failed diff --git a/validation/typedef_shadow.c b/validation/typedef_shadow.c index e52de80f..e8e4c229 100644 --- a/validation/typedef_shadow.c +++ b/validation/typedef_shadow.c @@ -5,9 +5,9 @@ static void f(int T) } /* * check-name: typedef shadowing - * check-error-start: + * check-error-start typedef_shadow.c:4:16: warning: 'T' has implicit type typedef_shadow.c:4:18: error: Expected ; at end of declaration typedef_shadow.c:4:18: error: got a - * check-error-end: + * check-error-end */ |
