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:09 +0100 |
| commit | 74ba40fadc42f7b3b2222cc231d2c38959943643 (patch) | |
| tree | fe6c4a3bfc2767c779002cf62a412ebb634afa49 /validation/test-suite | |
| parent | 49c98aa3ed1b315ed2f4fbe44271ecd5bdd9cbc7 (diff) | |
| download | sparse-dev-74ba40fadc42f7b3b2222cc231d2c38959943643.tar.gz | |
testsuite: add a new tag: check-output-match
The current tags check-output-contains/excludes/pattern are
quite powerful, universal, but they often need 'complex' regular
expressions with escaping which make them not so nice to read.
For testing IR results, a very common pattern is:
this instruction must have this (kind of) operand.
So, make a new tag for this. It does nothing than can't be done
with done with the previous ones, on the contrary, but is much
simpler to use:
check-output-match(instruction): operand
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/test-suite')
| -rwxr-xr-x | validation/test-suite | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/validation/test-suite b/validation/test-suite index f7d992dc..37f9cdb5 100755 --- a/validation/test-suite +++ b/validation/test-suite @@ -77,6 +77,7 @@ get_tag_value() check_output_contains=0 check_output_excludes=0 check_output_pattern=0 + check_output_match=0 check_arch_ignore="" check_arch_only="" check_assert="" @@ -100,6 +101,7 @@ get_tag_value() check-output-contains:) check_output_contains=1 ;; check-output-excludes:) check_output_excludes=1 ;; check-output-pattern) check_output_pattern=1 ;; + check-output-match) check_output_match=1 ;; check-arch-ignore:) arch=$(uname -m) check_arch_ignore="$val" ;; check-arch-only:) arch=$(uname -m) @@ -205,6 +207,24 @@ minmax_patterns() } ## +match_patterns() +{ + ifile="$1" + patt="$2" + ofile="$3" + grep "$patt" "$ifile" | sed -e "s/^.*$patt(\(.*\)): *\(.*\)$/\1 \2/" | \ + while read ins pat; do + grep -s "^ $ins\\.*[0-9]* " "$ofile" | grep -v -s -q "$pat" + if [ "$?" -ne 1 ]; then + error " IR doesn't match '$pat'" + return 1 + fi + done + + return $? +} + +## # arg_file(filename) - checks if filename exists arg_file() { @@ -395,6 +415,13 @@ do_test() test_failed=1 fi fi + if [ $check_output_match -eq 1 ]; then + # verify the 'check-output-match($insn): $patt' tags + match_patterns "$file" 'check-output-match' $file.output.got + if [ "$?" -ne "0" ]; then + test_failed=1 + fi + fi if [ "$must_fail" -eq "1" ]; then if [ "$test_failed" -eq "1" ]; then |
