summaryrefslogtreecommitdiff
path: root/lib/igt_kmod.c
diff options
context:
space:
mode:
authorJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>2024-03-15 17:22:29 +0100
committerJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>2024-03-20 23:18:20 +0100
commit4a3e87e246565177daaf2fc3cf4f8aaa09bfb629 (patch)
tree4cce8f22f7c5d7df3abc1ee7bda97c3bd313396e /lib/igt_kmod.c
parentf4d2c5b34916324f3075a248c86f877269ba1c8e (diff)
lib/kunit: Time out promptly on missing KTAP report
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.konieczny@linux.intel.com> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com> Acked-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Diffstat (limited to 'lib/igt_kmod.c')
-rw-r--r--lib/igt_kmod.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index df6d30f42..73b33e91d 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -1205,12 +1205,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;
@@ -1240,10 +1247,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,