selftests: kselftest framework: add handling for TAP header level
authorShuah Khan <shuahkh@osg.samsung.com>
Thu, 22 Feb 2018 00:11:54 +0000 (17:11 -0700)
committerShuah Khan <shuahkh@osg.samsung.com>
Tue, 6 Mar 2018 02:10:27 +0000 (19:10 -0700)
Introduce environment variable KSFT_TAP_LEVEL to avoid printing
nested TAP headers for each test. lib.mk run_tests target prints
TAP header before invoking the test program or test script. Tests
need a way to suppress TAP headers if it is already printed out.

This new environment variable adds a way for ksft_print_header()
print TAP header only when KSFT_TAP_LEVEL isn't set.

lib.mk run_tests and test program should print TAP header and set
KSFT_TAP_LEVEL to avoid a second TAP header to be printed.

selftests Makefile should export KSFT_TAP_LEVEL and add TAP Header
echo to the run_kselftest.sh script from emit_tests target handling.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/kselftest.h

index 1a52b03..1b9d8ec 100644 (file)
@@ -57,7 +57,8 @@ static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; }
 
 static inline void ksft_print_header(void)
 {
-       printf("TAP version 13\n");
+       if (!(getenv("KSFT_TAP_LEVEL")))
+               printf("TAP version 13\n");
 }
 
 static inline void ksft_print_cnts(void)