aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-04-28 11:54:43 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-04 18:55:44 +0200
commit13b85df87ae16206df4615ae911c284684b3f3bc (patch)
tree1e53a1b12ec5b797bb995c6469e5106976c49309
parent78389300348804c26c231f56e1c8156082957a64 (diff)
downloadsparse-dev-13b85df87ae16206df4615ae911c284684b3f3bc.tar.gz
testsuite: add check-assert
Ideally, the testcases should be universal but it happen than some of them need to test some specificities or are meaningless or plainly wrong in some situations. In such cases, these tests must but ignored. Currently, the only the only mechanisms a test are: 1) ignoring the tests depending on a tool which cannot be compiled (like, for example, those using sparse-llvm when LLVM is not installed. 2) some rather corse criteria using the name of the arch used to run the tests. Allow more flexibility by allowing to exclude some tests based on the success or failure of an arbitrary condition via _Static_assert(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--Documentation/test-suite4
-rwxr-xr-xvalidation/test-suite12
2 files changed, 16 insertions, 0 deletions
diff --git a/Documentation/test-suite b/Documentation/test-suite
index 626bc3fe..bf4518a2 100644
--- a/Documentation/test-suite
+++ b/Documentation/test-suite
@@ -27,6 +27,10 @@ check-arch-only: <arch[|...]>
Ignore the test if the current architecture (as returned by 'uname -m')
match or not one of the archs given in the pattern.
+check-assert: <condition>
+ Ignore the test if the given condition is false when evaluated as a
+ static assertion (_Static_assert).
+
check-cpp-if: <condition>
Ignore the test if the given condition is false when evaluated
by sparse's pre-processor.
diff --git a/validation/test-suite b/validation/test-suite
index 6c6d34b2..04607a3e 100755
--- a/validation/test-suite
+++ b/validation/test-suite
@@ -79,6 +79,7 @@ get_tag_value()
check_output_pattern=0
check_arch_ignore=""
check_arch_only=""
+ check_assert=""
check_cpp_if=""
lines=$(grep 'check-[a-z-]*' $1 | \
@@ -103,6 +104,7 @@ get_tag_value()
check_arch_ignore="$val" ;;
check-arch-only:) arch=$(uname -m)
check_arch_only="$val" ;;
+ check-assert:) check_assert="$val" ;;
check-cpp-if:) check_cpp_if="$val" ;;
check-description:) ;; # ignore
@@ -303,6 +305,16 @@ do_test()
return 3
fi
fi
+ if [ "$check_assert" != "" ]; then
+ res=$(../sparse - 2>&1 >/dev/null <<- EOF
+ _Static_assert($check_assert, "$check_assert");
+ EOF
+ )
+ if [ "$res" != "" ]; then
+ disable "$test_name" "$file"
+ return 3
+ fi
+ fi
if [ "$check_cpp_if" != "" ]; then
res=$(../sparse -E - 2>/dev/null <<- EOF
#if !($check_cpp_if)