From: Brendan Higgins <brendanhiggins@google.com>
To: shuah <shuah@kernel.org>, David Gow <davidgow@google.com>,
Daniel Latypov <dlatypov@google.com>,
Martin Fernandez <martin.fernandez@eclypsium.com>,
Daniel Gutson <daniel.gutson@eclypsium.com>,
Jeremy Kerr <jk@codeconstruct.com.au>
Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
linux-kernel@vger.kernel.org, keescook@chromium.org
Subject: Re: [RFC v1] kunit: add support for kunit_suites that reference init code
Date: Thu, 10 Mar 2022 17:50:22 -0500 [thread overview]
Message-ID: <CAFd5g45MXXi_iBjJrTSUze-jjMXU18e4oN1Yo5Qg71wac6Uzjg@mail.gmail.com> (raw)
In-Reply-To: <CAFd5g46NmmNy5ueRjDnCkgjHy75KVUXA0xcTXtXjxLg7mgKJng@mail.gmail.com>
Actually add Jeremy this time. Sorry for the spam.
On Thu, Mar 10, 2022 at 5:49 PM Brendan Higgins
<brendanhiggins@google.com> wrote:
>
> +Jeremy Kerr - Just remembered that Jeremy is doing some work here and
> might be somewhat interested.
>
> On Thu, Mar 10, 2022 at 4:02 PM Brendan Higgins
> <brendanhiggins@google.com> wrote:
> >
> > Add support for a new kind of kunit_suite registration macro called
> > kunit_test_init_suite(); this new registration macro allows the
> > registration of kunit_suites that reference functions marked __init and
> > data marked __initdata.
> >
> > Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
> > ---
> >
> > This patch is in response to a KUnit user issue[1] in which the user was
> > attempting to test some init functions; although this is a functional
> > solution as long as KUnit tests only run during the init phase, we will
> > need to do more work if we ever allow tests to run after the init phase
> > is over; it is for this reason that this patch adds a new registration
> > macro rather than simply modifying the existing macros.
> >
> > [1] https://groups.google.com/g/kunit-dev/c/XDjieRHEneg/m/D0rFCwVABgAJ
> >
> > ---
> > include/kunit/test.h | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/include/kunit/test.h b/include/kunit/test.h
> > index b26400731c02..1878e585f6d3 100644
> > --- a/include/kunit/test.h
> > +++ b/include/kunit/test.h
> > @@ -379,6 +379,27 @@ static inline int kunit_run_all_tests(void)
> >
> > #define kunit_test_suite(suite) kunit_test_suites(&suite)
> >
> > +/**
> > + * kunit_test_init_suites() - used to register one or more &struct kunit_suite
> > + * containing init functions or init data.
> > + *
> > + * @__suites: a statically allocated list of &struct kunit_suite.
> > + *
> > + * This functions identically as &kunit_test_suites() except that it suppresses
> > + * modpost warnings for referencing functions marked __init or data marked
> > + * __initdata; this is OK because currently KUnit only runs tests upon boot
> > + * during the init phase or upon loading a module during the init phase.
> > + *
> > + * NOTE TO KUNIT DEVS: If we ever allow KUnit tests to be run after boot, these
> > + * tests must be excluded.
> > + */
> > +#define kunit_test_init_suites(__suites...) \
> > + __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \
> > + CONCATENATE(__UNIQUE_ID(suites), _probe), \
> > + ##__suites)
> > +
> > +#define kunit_test_init_suite(suite) kunit_test_init_suites(&suite)
> > +
> > #define kunit_suite_for_each_test_case(suite, test_case) \
> > for (test_case = suite->test_cases; test_case->run_case; test_case++)
> >
> >
> > base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
> > --
> > 2.35.1.723.g4982287a31-goog
> >
next prev parent reply other threads:[~2022-03-10 22:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 21:02 [RFC v1] kunit: add support for kunit_suites that reference init code Brendan Higgins
2022-03-10 21:42 ` Martin Fernandez
2022-03-10 22:26 ` Kees Cook
2022-03-10 22:49 ` Brendan Higgins
2022-03-10 22:50 ` Brendan Higgins [this message]
2022-03-11 7:02 ` David Gow
[not found] ` <CAFmMkTFa9xVt314WEGd0nNx+ovc=aGB_yN1LorP7WrBga9quxw@mail.gmail.com>
2022-03-11 17:56 ` Daniel Latypov
2022-03-25 13:25 ` Daniel Gutson
2022-03-25 15:59 ` Daniel Latypov
2022-03-28 17:04 ` Brendan Higgins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFd5g45MXXi_iBjJrTSUze-jjMXU18e4oN1Yo5Qg71wac6Uzjg@mail.gmail.com \
--to=brendanhiggins@google.com \
--cc=daniel.gutson@eclypsium.com \
--cc=davidgow@google.com \
--cc=dlatypov@google.com \
--cc=jk@codeconstruct.com.au \
--cc=keescook@chromium.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.fernandez@eclypsium.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).