@@ -1130,33 +1130,37 @@ static void __igt_kunit(struct igt_ktest *tst,
igt_skip_on(lseek(tst->kmsg, 0, SEEK_END) < 0);
- igt_skip_on(pthread_mutexattr_init(&attr));
- igt_skip_on(pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST));
- igt_skip_on(pthread_mutex_init(&modprobe.lock, &attr));
-
ktap = igt_ktap_alloc(&results);
igt_require(ktap);
- if (igt_debug_on(pthread_create(&modprobe.thread, NULL,
- modprobe_task, &modprobe))) {
- igt_ktap_free(ktap);
- igt_skip("Failed to create a modprobe thread\n");
- }
-
igt_list_for_each_entry(t, tests, link) {
igt_dynamic_f("%s%s%s",
strcmp(t->suite_name, name) ? t->suite_name : "",
strcmp(t->suite_name, name) ? "-" : "",
t->case_name) {
- if (igt_list_empty(&results)) {
+ if (!modprobe.thread) {
+ igt_assert_eq(pthread_mutexattr_init(&attr), 0);
+ igt_assert_eq(pthread_mutexattr_setrobust(&attr,
+ PTHREAD_MUTEX_ROBUST),
+ 0);
+ igt_assert_eq(pthread_mutex_init(&modprobe.lock,
+ &attr), 0);
+
+ modprobe.err = pthread_create(&modprobe.thread,
+ NULL,
+ modprobe_task,
+ &modprobe);
+ igt_assert_eq(modprobe.err, 0);
+
+ igt_assert(igt_list_empty(&results));
igt_assert_eq(ret, -EINPROGRESS);
ret = kunit_kmsg_result_get(&results, &modprobe,
tst->kmsg, ktap);
igt_fail_on(igt_list_empty(&results));
- }
- r = igt_list_first_entry(&results, r, link);
+ r = igt_list_first_entry(&results, r, link);
+ }
while (igt_debug_on_f(strcmp(r->suite_name, t->suite_name),
"suite_name expected: %s, got: %s\n",
@@ -1228,30 +1232,30 @@ static void __igt_kunit(struct igt_ktest *tst,
igt_assert_eq(igt_kernel_tainted(&taints), 0);
}
- kunit_result_free(&r, &suite_name, &case_name);
-
if (igt_debug_on(ret != -EINPROGRESS))
break;
}
kunit_results_free(&results, &suite_name, &case_name);
- switch (pthread_mutex_lock(&modprobe.lock)) {
- case 0:
- igt_debug_on(pthread_cancel(modprobe.thread));
- igt_debug_on(pthread_mutex_unlock(&modprobe.lock));
- igt_debug_on(pthread_join(modprobe.thread, NULL));
- break;
- case EOWNERDEAD:
- /* leave the mutex unrecoverable */
- igt_debug_on(pthread_mutex_unlock(&modprobe.lock));
- break;
- case ENOTRECOVERABLE:
- break;
- default:
- igt_debug("pthread_mutex_lock() failed\n");
- igt_debug_on(pthread_join(modprobe.thread, NULL));
- break;
+ if (modprobe.thread) {
+ switch (pthread_mutex_lock(&modprobe.lock)) {
+ case 0:
+ igt_debug_on(pthread_cancel(modprobe.thread));
+ igt_debug_on(pthread_mutex_unlock(&modprobe.lock));
+ igt_debug_on(pthread_join(modprobe.thread, NULL));
+ break;
+ case EOWNERDEAD:
+ /* leave the mutex unrecoverable */
+ igt_debug_on(pthread_mutex_unlock(&modprobe.lock));
+ break;
+ case ENOTRECOVERABLE:
+ break;
+ default:
+ igt_debug("pthread_mutex_lock() failed\n");
+ igt_debug_on(pthread_join(modprobe.thread, NULL));
+ break;
+ }
}
igt_ktap_free(ktap);