From: David Gow <david@davidgow.net>
To: Vaibhav Jain <vaibhav@linux.ibm.com>,
linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
linux-kernel@vger.kernel.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Brendan Higgins <brendan.higgins@linux.dev>,
Rae Moar <raemoar63@gmail.com>
Subject: Re: [PATCH v3 3/3] kunit: Add example of test suite that can be skipped at runtime
Date: Sat, 20 Jun 2026 19:08:33 +0800 [thread overview]
Message-ID: <94e796b8-aba6-426d-bb84-92259300fe66@davidgow.net> (raw)
In-Reply-To: <20260617121535.462459-4-vaibhav@linux.ibm.com>
Le 17/06/2026 à 8:15 PM, Vaibhav Jain a écrit :
> Add an example test suite name 'example_test_skip_suite' to
> 'kunit-example-test.c' that shows how to skip an entire test suite based on
> runtime conditions.
>
> The example suite 'example_skip_suite' provides a 'suite_init' callback
> named example_skip_suite_init() which marks the entire suite as skipped
> using kunit_mark_skipped().
>
> This demonstrates a way for conditionally skipping test suites when any
> prerequisites for kunit_suite execution are not met. The 'suite_init'
> callback can perform any necessary checks and mark the suite as skipped,
> preventing all test cases from executing while also indicating why the
> suite was skipped.
>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> ---
Reviewed-by: David Gow <david@davidgow.net>
> Changelog
> =========
> V2->V3:
> Link:
> https://lore.kernel.org/all/20260608090438.219497-3-vaibhav@linux.ibm.com
> * Updated patch index in the series
>
> V1->V2:
> Link:
> https://lore.kernel.org/all/20260604162805.556135-3-vaibhav@linux.ibm.com/
> * Added RB from 'David Gow'
> ---
> lib/kunit/kunit-example-test.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c
> index 0bae7b7ca0b0..b8ded54fa46d 100644
> --- a/lib/kunit/kunit-example-test.c
> +++ b/lib/kunit/kunit-example-test.c
> @@ -591,5 +591,34 @@ static struct kunit_suite example_init_test_suite = {
> */
> kunit_test_init_section_suites(&example_init_test_suite);
>
> +/*
> + * This test should always be skipped.
> + */
> +static void example_skip_suite_test(struct kunit *test)
> +{
> + /* This line should never be seen */
> + KUNIT_FAIL(test, "You should not see a this.");
> +}
> +
> +static struct kunit_case example_skip_suite_test_cases[] = {
> + KUNIT_CASE(example_skip_suite_test),
> + {}
> +};
> +
> +static int example_skip_suite_init(struct kunit_suite *suite)
> +{
> + kunit_mark_skipped(suite, "Test suite expected to be skipped");
> + return 0;
> +}
> +
> +static struct kunit_suite example_test_skip_suite = {
> + .name = "example_skip_suite",
> + .suite_init = example_skip_suite_init,
> + .test_cases = example_skip_suite_test_cases,
> +};
> +
> +/* This registers a test suite that will be skipped */
> +kunit_test_suite(example_test_skip_suite);
> +
> MODULE_DESCRIPTION("Example KUnit test suite");
> MODULE_LICENSE("GPL v2");
prev parent reply other threads:[~2026-06-20 11:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 12:15 [PATCH v3 0/3] kunit: Add support for skipping entire test suites Vaibhav Jain
2026-06-17 12:15 ` [PATCH v3 1/3] kunit: Add ability to skip " Vaibhav Jain
2026-06-20 11:08 ` David Gow
2026-06-17 12:15 ` [PATCH v3 2/3] rust: kunit: add 'kunit_suite.status' binding to 'kunit_unsafe_test_suite' Vaibhav Jain
2026-06-20 11:08 ` David Gow
2026-06-17 12:15 ` [PATCH v3 3/3] kunit: Add example of test suite that can be skipped at runtime Vaibhav Jain
2026-06-20 11:08 ` David Gow [this message]
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=94e796b8-aba6-426d-bb84-92259300fe66@davidgow.net \
--to=david@davidgow.net \
--cc=brendan.higgins@linux.dev \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=raemoar63@gmail.com \
--cc=vaibhav@linux.ibm.com \
/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
all inboxes | Powered by JetHome®