@@ -773,6 +773,7 @@ static void __igt_kunit(struct igt_ktest *tst, const char *opts)
results = ktap_parser_start(tst->kmsg, is_builtin);
if (igt_debug_on(igt_kmod_load(tst->module_name, opts) < 0)) {
+ ktap_parser_cancel();
igt_ignore_warn(ktap_parser_stop());
igt_skip("Unable to load %s module\n", tst->module_name);
}
@@ -602,6 +602,12 @@ struct ktap_test_results *ktap_parser_start(int fd, bool is_builtin)
return &results;
}
+void ktap_parser_cancel(void)
+{
+ ktap_args.is_running = false;
+ pthread_cancel(ktap_parser_thread);
+}
+
int ktap_parser_stop(void)
{
ktap_args.is_running = false;
@@ -45,6 +45,7 @@ struct ktap_test_results {
struct ktap_test_results *ktap_parser_start(int fd, bool is_builtin);
+void ktap_parser_cancel(void);
int ktap_parser_stop(void);
#endif /* IGT_KTAP_H */
For our KTAP parser to be running in parallel with kunit test module loading, we now start it in a separate thread before we load the module. If the module loading fails then we join the KTAP parser thread right after that failure. If the KTAP thread sleeps for some reason then we can fail to break the test immediately. Cancel the KTAP parser thread right after module load error and before joining it. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> --- lib/igt_kmod.c | 1 + lib/igt_ktap.c | 6 ++++++ lib/igt_ktap.h | 1 + 3 files changed, 8 insertions(+)