diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-30 18:51:53 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-01 00:55:44 +0100 |
commit | dc27965726cbc506250ccc12c5169be048a01082 (patch) | |
tree | 31cc6bac1c7bd6084f7affacba281a2a7b5921c9 | |
parent | 74ba40fadc42f7b3b2222cc231d2c38959943643 (diff) | |
download | sparse-dc27965726cbc506250ccc12c5169be048a01082.tar.gz |
testsuite: add a new tag: check-output-returns
The current tags check-output-contains/excludes/pattern are
quite powerful and the new check-output-match is easy to use
but it can be even simpler. Indeed, a lot of IR simplifications/
canonicalizations can be tested by checking that the expression
to be tested is equivalent to another one. This is less precise
than some more specific tests but:
* it's a big advantage because it's less sensitive to 'noise'
like the exact number used by the pseudos or to the results
of some new simplifications or canonicalizations
* very often, this equivalence is what really matters and not
the exact transformation.
So, add a new utra-simple-to-use tag: just ask that all functions
of the tests return the same specified value (usually 1):
check-output-returns: <value>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | Documentation/test-suite.rst | 5 | ||||
-rw-r--r-- | validation/optim/testsuite.c | 1 | ||||
-rwxr-xr-x | validation/test-suite | 27 |
3 files changed, 33 insertions, 0 deletions
diff --git a/Documentation/test-suite.rst b/Documentation/test-suite.rst index 4ff2db2f..3181e109 100644 --- a/Documentation/test-suite.rst +++ b/Documentation/test-suite.rst @@ -96,6 +96,11 @@ Tag's syntax is ignored in the first pattern but is expected to be followed by a space character. +``check-output-returns:`` *value* + + Check that in the output (stdout) all IR return instructions + have the given value. + Using test-suite ================ diff --git a/validation/optim/testsuite.c b/validation/optim/testsuite.c index 15c9bdd6..f4535522 100644 --- a/validation/optim/testsuite.c +++ b/validation/optim/testsuite.c @@ -9,4 +9,5 @@ int foo(void) * * check-output-ignore * check-output-match(ret): \\$0 + * check-output-returns: 0 */ diff --git a/validation/test-suite b/validation/test-suite index 37f9cdb5..6935d40c 100755 --- a/validation/test-suite +++ b/validation/test-suite @@ -78,6 +78,7 @@ get_tag_value() check_output_excludes=0 check_output_pattern=0 check_output_match=0 + check_output_returns=0 check_arch_ignore="" check_arch_only="" check_assert="" @@ -102,6 +103,7 @@ get_tag_value() check-output-excludes:) check_output_excludes=1 ;; check-output-pattern) check_output_pattern=1 ;; check-output-match) check_output_match=1 ;; + check-output-returns:) check_output_returns=1 ;; check-arch-ignore:) arch=$(uname -m) check_arch_ignore="$val" ;; check-arch-only:) arch=$(uname -m) @@ -225,6 +227,24 @@ match_patterns() } ## +return_patterns() +{ + ifile="$1" + patt="$2" + ofile="$3" + grep "$patt:" "$ifile" | sed -e "s/^.*$patt: *\(.*\)$/\1/" | \ + while read ret; do + grep -s "^ ret\\.[0-9]" "$ofile" | grep -v -s -q "[ \$]${ret}\$" + if [ "$?" -ne 1 ]; then + error " Return doesn't match '$ret'" + return 1 + fi + done + + return $? +} + +## # arg_file(filename) - checks if filename exists arg_file() { @@ -422,6 +442,13 @@ do_test() test_failed=1 fi fi + if [ $check_output_returns -eq 1 ]; then + # verify the 'check-output-return: $value' tags + return_patterns "$file" 'check-output-returns' $file.output.got + if [ "$?" -ne "0" ]; then + test_failed=1 + fi + fi if [ "$must_fail" -eq "1" ]; then if [ "$test_failed" -eq "1" ]; then |