[PATCH 1/2] testsuite: add check-cp-if

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 evaluation of some pre-processor expression at test-time.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 Documentation/test-suite |  4 ++++
 validation/test-suite    | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/Documentation/test-suite b/Documentation/test-suite
index 1315dbd67..626bc3fe7 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-cpp-if: <condition>
+	Ignore the test if the given condition is false when evaluated
+	by sparse's pre-processor.
+
 check-exit-value: <value>
 	The expected exit value of check-command. It defaults to 0.
 
diff --git a/validation/test-suite b/validation/test-suite
index 4fdc9e9fa..6c6d34b28 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_cpp_if=""
 
 	lines=$(grep 'check-[a-z-]*' $1 | \
 		sed -e 's/^.*\(check-[a-z-]*:*\) *\(.*\)$/\1 \2/')
@@ -102,6 +103,7 @@ get_tag_value()
 					check_arch_ignore="$val" ;;
 		check-arch-only:)	arch=$(uname -m)
 					check_arch_only="$val" ;;
+		check-cpp-if:)		check_cpp_if="$val" ;;
 
 		check-description:)	;;	# ignore
 		check-note:)		;;	# ignore
@@ -301,6 +303,18 @@ do_test()
 			return 3
 		fi
 	fi
+	if [ "$check_cpp_if" != "" ]; then
+		res=$(../sparse -E - 2>/dev/null <<- EOF
+			#if !($check_cpp_if)
+			fail
+			#endif
+			EOF
+		)
+		if [ "$res" != "" ]; then
+			disable "$test_name" "$file"
+			return 3
+		fi
+	fi
 
 	if [ -z "$vquiet" ]; then
 		echo "  TEST    $test_name ($file)"
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux