summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kselftest_harness.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-07 11:54:21 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-07 11:54:21 -0700
commitfc22e19a114f000da4db2ed0ed82023c44d38a8c (patch)
tree1eb8672cb121bef7c366127d41bd36bdc9753e8c /tools/testing/selftests/kselftest_harness.h
parent3612605a5a5bc3d3ae0ec861328be8a2990f2c7a (diff)
parent6aa69043d9f3f4adc5b3817ccfcac1fddfe10ded (diff)
Merge tag 'linux-kselftest-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest update from Shuah Khan: "This Kselftest update for 4.17-rc1 consists of: - Test build error fixes - Fixes to prevent intel_pstate from building on non-x86 systems. - New test for ion with vgem driver. - Change to print the test name to /dev/kmsg to add context to kernel failures if any uncovered from running the test. - Kselftest framework enhancements to add KSFT_TAP_LEVEL environment variable to prevent nested TAP headers being printed in the Kselftest output. Nested TAP13 headers could cause problems for some parsers. This change suppresses the nested headers from test programs and test shell scripts with changes to framework and Makefiles without changing the tests" * tag 'linux-kselftest-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests/intel_pstate: Fix build rule for x86 selftests: Print the test we're running to /dev/kmsg selftests/seccomp: Allow get_metadata to XFAIL selftests/android/ion: Makefile: fix build error selftests: futex Makefile add top level TAP header echo to RUN_TESTS selftests: Makefile set KSFT_TAP_LEVEL to prevent nested TAP headers selftests: lib.mk set KSFT_TAP_LEVEL to prevent nested TAP headers selftests: kselftest framework: add handling for TAP header level selftests: ion: Add simple test with the vgem driver selftests: ion: Remove some prints
Diffstat (limited to 'tools/testing/selftests/kselftest_harness.h')
-rw-r--r--tools/testing/selftests/kselftest_harness.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index e81bd28bdd89..6ae3730c4ee3 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -107,6 +107,27 @@
__FILE__, __LINE__, _metadata->name, ##__VA_ARGS__)
/**
+ * XFAIL(statement, fmt, ...)
+ *
+ * @statement: statement to run after reporting XFAIL
+ * @fmt: format string
+ * @...: optional arguments
+ *
+ * This forces a "pass" after reporting a failure with an XFAIL prefix,
+ * and runs "statement", which is usually "return" or "goto skip".
+ */
+#define XFAIL(statement, fmt, ...) do { \
+ if (TH_LOG_ENABLED) { \
+ fprintf(TH_LOG_STREAM, "[ XFAIL! ] " fmt "\n", \
+ ##__VA_ARGS__); \
+ } \
+ /* TODO: find a way to pass xfail to test runner process. */ \
+ _metadata->passed = 1; \
+ _metadata->trigger = 0; \
+ statement; \
+} while (0)
+
+/**
* TEST(test_name) - Defines the test function and creates the registration
* stub
*
@@ -198,7 +219,7 @@
/**
* FIXTURE_SETUP(fixture_name) - Prepares the setup function for the fixture.
- * *_metadata* is included so that ASSERT_* work as a convenience
+ * *_metadata* is included so that EXPECT_* and ASSERT_* work correctly.
*
* @fixture_name: fixture name
*
@@ -221,6 +242,7 @@
FIXTURE_DATA(fixture_name) __attribute__((unused)) *self)
/**
* FIXTURE_TEARDOWN(fixture_name)
+ * *_metadata* is included so that EXPECT_* and ASSERT_* work correctly.
*
* @fixture_name: fixture name
*
@@ -253,6 +275,8 @@
* Defines a test that depends on a fixture (e.g., is part of a test case).
* Very similar to TEST() except that *self* is the setup instance of fixture's
* datatype exposed for use by the implementation.
+ *
+ * Warning: use of ASSERT_* here will skip TEARDOWN.
*/
/* TODO(wad) register fixtures on dedicated test lists. */
#define TEST_F(fixture_name, test_name) \