kunit: alpha: transition: make kunit_test_suites() take pointers
TL;DR make this work
kunit_test_suites(&test_test_module);
In commit 86ff26500ecb ("kunit: add kunit/Kconfig and <kunit/test.h> to
ease upgrade from alpha"), we added a #define of kunit_test_suites to
module_test.
This isn't quite correct since kunit_test_suites() takes its args by
pointer.
And given how the module_test() macro is written, we can't reuse it.
So rewrite a version of module_test() that uses __COUNTER__ to generate
unique variable names instead of pasting the suite's var name.
Also add a line
#define kunit_test_suite module_test
since kunit_test_suite() is sadly still around upstream and has the same
semantics as module_test*
It's defined as
#define kunit_test_suite(suite) kunit_test_suites(&suite)
Change-Id: Ia661924b25ad0f86f0b8c8712780f58db837774b
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 58217d4..b3119e2 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -43,7 +43,15 @@
#define KUNIT_ASSERT_SIGSEGV ASSERT_SIGSEGV
#define KUNIT_CASE TEST_CASE
-#define kunit_test_suites module_test
+#define kunit_test_suite module_test
+
+// NOTE: in upstream, this can handle multiple suites. We can't here.
+#define ___concat(a,b) a##b
+#define __concat(a,b) ___concat(a,b)
+#define kunit_test_suites(suite_ptr) \
+ static struct KUNIT_SUITE_T *__concat(__test_module_,__COUNTER__) __used \
+ __aligned(8) __attribute__((__section__(".test_modules"))) = \
+ suite_ptr
#define kunit_info test_info
#define kunit_warn test_warn
diff --git a/test/test-test.c b/test/test-test.c
index 9839c75..c1bdfe9 100644
--- a/test/test-test.c
+++ b/test/test-test.c
@@ -5,7 +5,7 @@
* Copyright (C) 2018, Google LLC.
* Author: Brendan Higgins <brendanhiggins@google.com>
*/
-#include <test/test.h>
+#include <kunit/test.h>
typedef void (*test_resource_free_t)(struct KUNIT_RESOURCE_T *);
@@ -128,4 +128,4 @@
.exit = test_test_exit,
.test_cases = test_test_cases,
};
-module_test(test_test_module);
+kunit_test_suites(&test_test_module);