If a test provides a subtest name that doesn't match any test suites provided by the requested KUnit test module then no KTAP report appears in dmesg, not even an empty one as one may expect. As a consequence, we now loop endlessly around reading potential lines of the missing report from /dev/kmsg, until killed by IGT runner on timeout.
When trying to collect names of test cases from a KTAP report generated in all skip mode, set an alarm that fires up 10 seconds after we start waiting for the report, interrupts blocking read() if pending, and terminates the subtest with SKIP result. As soon as we have collected a non-empty list of test cases, we may as well expect a non-empty KTAP report from actual execution of those test cases, assuming successful load of the KUnit test module in execution mode. Then, there is no need to set up a similar timeout before we start to extract and parse that report. Suggested-by: Kamil Konieczny <kamil.koniec...@linux.intel.com> Signed-off-by: Janusz Krzysztofik <janusz.krzyszto...@linux.intel.com> --- lib/igt_kmod.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index 8a6824ea7e..f0e4d5ec76 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -1204,12 +1204,19 @@ static void __igt_kunit_legacy(struct igt_ktest *tst, igt_skip_on_f(ret, "KTAP parser failed\n"); } +static void kunit_get_tests_timeout(int signal) +{ + igt_skip("Timed out while trying to extract a list of KUnit test cases from /dev/kmsg\n"); +} + static bool kunit_get_tests(struct igt_list_head *tests, struct igt_ktest *tst, const char *suite, const char *opts, struct igt_ktap_results **ktap) { + struct sigaction sigalrm = { .sa_handler = kunit_get_tests_timeout, }, + *saved; struct igt_ktap_result *r, *rn; unsigned long taints; int flags, err; @@ -1239,10 +1246,16 @@ static bool kunit_get_tests(struct igt_list_head *tests, *ktap = igt_ktap_alloc(tests); igt_require(*ktap); + igt_skip_on(sigaction(SIGALRM, &sigalrm, saved)); + alarm(10); + do err = kunit_kmsg_result_get(tests, NULL, tst->kmsg, *ktap); while (err == -EINPROGRESS); + alarm(0); + igt_debug_on(sigaction(SIGALRM, saved, NULL)); + igt_ktap_free(ktap); igt_skip_on_f(err, -- 2.43.0