From: Marco Elver <elver@google.com>
To: Daniel Latypov <dlatypov@google.com>
Cc: brendanhiggins@google.com, davidgow@google.com,
linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com,
linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org,
kasan-dev@googlegroups.com, glider@google.com
Subject: Re: [PATCH 3/3] kfence: test: use new suite_{init/exit} support, add .kunitconfig
Date: Wed, 27 Apr 2022 14:41:13 +0200 [thread overview]
Message-ID: <Ymk56YygGUU52CHG@elver.google.com> (raw)
In-Reply-To: <20220426181925.3940286-3-dlatypov@google.com>
On Tue, Apr 26, 2022 at 11:19AM -0700, 'Daniel Latypov' via kasan-dev wrote:
> Currently, the kfence test suite could not run via "normal" means since
> KUnit didn't support per-suite setup/teardown. So it manually called
> internal kunit functions to run itself.
> This has some downsides, like missing TAP headers => can't use kunit.py
> to run or even parse the test results (w/o tweaks).
>
> Use the newly added support and convert it over, adding a .kunitconfig
> so it's even easier to run from kunit.py.
>
> People can now run the test via
> $ ./tools/testing/kunit/kunit.py run --kunitconfig=mm/kfence --arch=x86_64
> ...
> [11:02:32] Testing complete. Passed: 23, Failed: 0, Crashed: 0, Skipped: 2, Errors: 0
> [11:02:32] Elapsed time: 43.562s total, 0.003s configuring, 9.268s building, 34.281s running
>
> Cc: kasan-dev@googlegroups.com
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Marco Elver <elver@google.com>
> ---
> mm/kfence/.kunitconfig | 6 ++++++
> mm/kfence/kfence_test.c | 31 +++++++++++++------------------
> 2 files changed, 19 insertions(+), 18 deletions(-)
> create mode 100644 mm/kfence/.kunitconfig
>
> diff --git a/mm/kfence/.kunitconfig b/mm/kfence/.kunitconfig
> new file mode 100644
> index 000000000000..f3d65e939bfa
> --- /dev/null
> +++ b/mm/kfence/.kunitconfig
> @@ -0,0 +1,6 @@
> +CONFIG_KUNIT=y
> +CONFIG_KFENCE=y
> +CONFIG_KFENCE_KUNIT_TEST=y
> +
> +# Additional dependencies.
> +CONFIG_FTRACE=y
> diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c
> index 1b50f70a4c0f..96206a4ee9ab 100644
> --- a/mm/kfence/kfence_test.c
> +++ b/mm/kfence/kfence_test.c
> @@ -826,14 +826,6 @@ static void test_exit(struct kunit *test)
> test_cache_destroy();
> }
>
> -static struct kunit_suite kfence_test_suite = {
> - .name = "kfence",
> - .test_cases = kfence_test_cases,
> - .init = test_init,
> - .exit = test_exit,
> -};
> -static struct kunit_suite *kfence_test_suites[] = { &kfence_test_suite, NULL };
> -
> static void register_tracepoints(struct tracepoint *tp, void *ignore)
> {
> check_trace_callback_type_console(probe_console);
> @@ -847,11 +839,7 @@ static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
> tracepoint_probe_unregister(tp, probe_console, NULL);
> }
>
> -/*
> - * We only want to do tracepoints setup and teardown once, therefore we have to
> - * customize the init and exit functions and cannot rely on kunit_test_suite().
> - */
> -static int __init kfence_test_init(void)
> +static int kfence_suite_init(struct kunit_suite *suite)
> {
> /*
> * Because we want to be able to build the test as a module, we need to
> @@ -859,18 +847,25 @@ static int __init kfence_test_init(void)
> * won't work here.
> */
> for_each_kernel_tracepoint(register_tracepoints, NULL);
> - return __kunit_test_suites_init(kfence_test_suites);
> + return 0;
> }
>
> -static void kfence_test_exit(void)
> +static void kfence_suite_exit(struct kunit_suite *suite)
> {
> - __kunit_test_suites_exit(kfence_test_suites);
> for_each_kernel_tracepoint(unregister_tracepoints, NULL);
> tracepoint_synchronize_unregister();
> }
>
> -late_initcall_sync(kfence_test_init);
> -module_exit(kfence_test_exit);
> +static struct kunit_suite kfence_test_suite = {
> + .name = "kfence",
> + .test_cases = kfence_test_cases,
> + .init = test_init,
> + .exit = test_exit,
> + .suite_init = kfence_suite_init,
> + .suite_exit = kfence_suite_exit,
> +};
> +
> +kunit_test_suites(&kfence_test_suite);
Much nicer!
Thanks,
-- Marco
next prev parent reply other threads:[~2022-04-27 12:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 18:19 [PATCH 1/3] kunit: rename print_subtest_{start,end} for clarity (s/subtest/suite) Daniel Latypov
2022-04-26 18:19 ` [PATCH 2/3] kunit: add ability to specify suite-level init and exit functions Daniel Latypov
2022-04-27 1:55 ` David Gow
2022-04-27 3:06 ` Daniel Latypov
2022-04-29 6:01 ` David Gow
2022-04-29 18:16 ` Daniel Latypov
2022-04-26 18:19 ` [PATCH 3/3] kfence: test: use new suite_{init/exit} support, add .kunitconfig Daniel Latypov
2022-04-27 1:56 ` David Gow
2022-04-27 12:41 ` Marco Elver [this message]
2022-04-27 1:55 ` [PATCH 1/3] kunit: rename print_subtest_{start,end} for clarity (s/subtest/suite) David Gow
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=Ymk56YygGUU52CHG@elver.google.com \
--to=elver@google.com \
--cc=brendanhiggins@google.com \
--cc=davidgow@google.com \
--cc=dlatypov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=skhan@linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.