Message ID | 20240321143200.1854489-1-smayhew@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | kunit: bail out early in __kunit_test_suites_init() if there are no suites to test | expand |
On Thu, Mar 21, 2024 at 10:32 AM Scott Mayhew <smayhew@redhat.com> wrote: > > 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> Hi! Sorry about this bug. Thanks for the patch! We should definitely add this check. Reviewed-by: Rae Moar <rmoar@google.com> Thanks! -Rae > --- > lib/kunit/test.c | 3 +++ > 1 file changed, 3 insertions(+) > > 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; > -- > 2.43.0 >
On Thu, 21 Mar 2024 at 22:32, Scott Mayhew <smayhew@redhat.com> wrote: > > 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> > --- Thanks, this works well here, and is a good idea anyway. Reviewed-by: David Gow <davidgow@google.com> Cheers, -- David > lib/kunit/test.c | 3 +++ > 1 file changed, 3 insertions(+) > > 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; > -- > 2.43.0 >
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;
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> --- lib/kunit/test.c | 3 +++ 1 file changed, 3 insertions(+)