diff options
author | Scott Mayhew <smayhew@redhat.com> | 2024-03-21 17:32:00 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-05-30 10:44:32 +0300 |
commit | 107bbcb5d37d08c14f5648b64fff63ce0e5247ea (patch) | |
tree | 5f29c03ab035cb906dc578d03c83e470c5313b71 | |
parent | dfd7f89a395cf89245590b3c65b56326d86ec466 (diff) | |
download | linux-107bbcb5d37d08c14f5648b64fff63ce0e5247ea.tar.xz |
kunit: bail out early in __kunit_test_suites_init() if there are no suites to test
[ Upstream commit 5496b9b77d7420652202b73cf036e69760be5deb ]
Commit c72a870926c2 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: c72a870926c2 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | lib/kunit/test.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 1d1475578515..b8514dbb337c 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -712,6 +712,9 @@ int __kunit_test_suites_init(struct kunit_suite * const * const suites, int num_ { unsigned int i; + if (num_suites == 0) + return 0; + if (!kunit_enabled() && num_suites > 0) { pr_info("kunit: disabled\n"); return 0; |