Re: [PATCH v4 1/3] kunit: Provide a static key to check if KUnit is actively running tests

From: Daniel Latypov
Date: Thu Dec 01 2022 - 20:19:50 EST


On Thu, Dec 1, 2022 at 4:53 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> > + static_branch_inc(&kunit_running);
>
> Is it expected there will be multiple tests running? (I was expecting
> "static_branch_enable").

It shouldn't normally happen, no.

One possible use case:
KUnit's unit tests for itself create fake test objects and operate on them.
They don't currently exercise this particular code though, afaict
(maybe they should).

>
> > +
> > for (i = 0; i < num_suites; i++) {
> > kunit_init_suite(suites[i]);
> > kunit_run_tests(suites[i]);
> > }
> > +
> > + static_branch_dec(&kunit_running);
> > return 0;
> > }
> > EXPORT_SYMBOL_GPL(__kunit_test_suites_init);
> > --
> > 2.38.1.584.g0f3c55d4c2-goog
> >
>
> Regardless:
>
> Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
>
> --
> Kees Cook

Daniel