]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: allow to re-use single function for tests
authorLucas De Marchi <lucas.demarchi@intel.com>
Fri, 12 Feb 2021 09:45:23 +0000 (01:45 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 15 Feb 2021 19:53:43 +0000 (11:53 -0800)
Add a new DEFINE_TEST_WITH_FUNC() that accepts the function
alongside the test name. This will allow us to share a single function
for different tests.

testsuite/testsuite.h

index c74b648054ab336273ee29632c8cf8c794498f8f..44d17300d371c56199b6a871eb0bd891e55474f3 100644 (file)
@@ -140,14 +140,16 @@ int test_run(const struct test *t);
 
 
 /* Test definitions */
-#define DEFINE_TEST(_name, ...) \
+#define DEFINE_TEST_WITH_FUNC(_name, _func, ...) \
        static const struct test UNIQ(s##_name) \
        __attribute__((used, section("kmod_tests"), aligned(8))) = { \
                .name = #_name, \
-               .func = _name, \
+               .func = _func, \
                ## __VA_ARGS__ \
        };
 
+#define DEFINE_TEST(_name, ...) DEFINE_TEST_WITH_FUNC(_name, _name, __VA_ARGS__)
+
 #define TESTSUITE_MAIN() \
        extern struct test __start_kmod_tests[] __attribute__((weak, visibility("hidden")));    \
        extern struct test __stop_kmod_tests[] __attribute__((weak, visibility("hidden")));     \