[PATCH v4 11/14] selftests: harness: Add "variant" and "self" to test metadata

Thomas Weißschuh posted 14 patches 7 months, 2 weeks ago
[PATCH v4 11/14] selftests: harness: Add "variant" and "self" to test metadata
Posted by Thomas Weißschuh 7 months, 2 weeks ago
To get rid of setjmp()/longjmp(), the variant and self need to be usable
from __bail().

Make them available from the test metadata.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/testing/selftests/kselftest_harness.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index acb476093b74968ecb71180ade9e5852b22da170..088c875df91a58f8760749b6047b246fb2a7891f 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -423,6 +423,8 @@
 				self = &self_private; \
 			} \
 		} \
+		_metadata->variant = variant->data; \
+		_metadata->self = self; \
 		if (setjmp(_metadata->env) == 0) { \
 			/* _metadata and potentially self are shared with all forks. */ \
 			child = fork(); \
@@ -926,6 +928,8 @@ struct __test_metadata {
 	bool aborted;	/* stopped test due to failed ASSERT */
 	bool *no_teardown; /* fixture needs teardown */
 	jmp_buf env;	/* for exiting out of test early */
+	void *self;
+	const void *variant;
 	struct __test_results *results;
 	struct __test_metadata *prev, *next;
 };

-- 
2.49.0