Skip to content

Commit 5496b9b

Browse files
scottmayhewshuahkh
authored andcommitted
kunit: bail out early in __kunit_test_suites_init() if there are no suites to test
Commit c72a870 added a mutex to prevent kunit tests from running concurrently. Unfortunately that mutex gets locked during module load regardless of whether the module actually has any kunit tests. This causes a problem for kunit tests that might need to load other kernel modules (e.g. gss_krb5_test loading the camellia module). So check to see if there are actually any tests to run before locking the kunit_run_lock mutex. Fixes: c72a870 ("kunit: add ability to run tests after boot using debugfs") Reported-by: Nico Pache <npache@redhat.com> Signed-off-by: Scott Mayhew <smayhew@redhat.com> Reviewed-by: Rae Moar <rmoar@google.com> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent a96a394 commit 5496b9b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/kunit/test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ int __kunit_test_suites_init(struct kunit_suite * const * const suites, int num_
712712
{
713713
unsigned int i;
714714

715+
if (num_suites == 0)
716+
return 0;
717+
715718
if (!kunit_enabled() && num_suites > 0) {
716719
pr_info("kunit: disabled\n");
717720
return 0;

0 commit comments

Comments
 (0)