From 7ab5c97924bf971a348ff4a1768da624ba2f564c Mon Sep 17 00:00:00 2001 From: Petri Latvala Date: Fri, 10 Mar 2017 16:20:33 +0200 Subject: Always expose IGT subtests for known kernel selftests Even when the running kernel does not support selftests, make subtest enumeration list known kselftests. The list is generated using selftest listing headers copied from the kernel. If the running kernel gains new selftest subtests, they are listed even without copying the headers over and rebuilding IGT. v2: Use correct names for the testcases Signed-off-by: Petri Latvala --- lib/igt_kmod.c | 52 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'lib/igt_kmod.c') diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index 4b8ea81a..86b78967 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -493,30 +493,54 @@ void igt_kselftest_fini(struct igt_kselftest *tst) kmod_module_unref(tst->kmod); } +static void mocklist_mark_entry(struct igt_kselftest_mockentry *mocklist, + const char *name) +{ + struct igt_kselftest_mockentry *me; + + for (me = mocklist; me->name != NULL; ++me) { + if (!strcmp(me->name, name)) { + me->do_mock = false; + return; + } + } +} + void igt_kselftests(const char *module_name, const char *options, const char *result, - const char *filter) + const char *filter, + struct igt_kselftest_mockentry *mocklist) { struct igt_kselftest tst; IGT_LIST(tests); struct igt_kselftest_list *tl, *tn; + struct igt_kselftest_mockentry *me; - igt_require(igt_kselftest_init(&tst, module_name) == 0); - igt_fixture - igt_require(igt_kselftest_begin(&tst) == 0); + if (igt_kselftest_init(&tst, module_name) == 0) { + igt_fixture + igt_require(igt_kselftest_begin(&tst) == 0); - igt_kselftest_get_tests(tst.kmod, filter, &tests); - igt_list_for_each_safe(tl, tn, &tests, link) { - igt_subtest_f("%s", tl->name) - igt_kselftest_execute(&tst, tl, options, result); - free(tl); - } + igt_kselftest_get_tests(tst.kmod, filter, &tests); + igt_list_for_each_safe(tl, tn, &tests, link) { + igt_subtest_f("%s", tl->name) + igt_kselftest_execute(&tst, tl, options, result); + mocklist_mark_entry(mocklist, tl->name); + free(tl); + } - igt_fixture { - igt_kselftest_end(&tst); - igt_require(!igt_list_empty(&tests)); + igt_fixture { + igt_kselftest_end(&tst); + igt_require(!igt_list_empty(&tests)); + } + + igt_kselftest_fini(&tst); } - igt_kselftest_fini(&tst); + /* Expose subtests for anything the above didn't already generate. */ + for (me = mocklist; me->name != NULL; ++me) { + if (me->do_mock) + igt_subtest(me->name) + igt_skip("Kernel selftest not present"); + } } -- cgit v1.2.3