From: Vaibhav Jain <vaibhav@linux.ibm.com>
To: David Gow <david@davidgow.net>,
linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
kvm-ppc@vger.kernel.org, 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 2/2] kunit: Add example of test suite that can be skipped at runtime
Date: Mon, 08 Jun 2026 14:11:15 +0530 [thread overview]
Message-ID: <87cxy1mnkk.fsf@vajain21.in.ibm.com> (raw)
In-Reply-To: <d7b56622-6455-4e80-844f-086a0a3b1946@davidgow.net>
David Gow <david@davidgow.net> writes:
> Le 05/06/2026 à 12:28 AM, 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>
>> ---
>
> Thanks!
>
> Reviewed-by: David Gow <david@davidgow.net>
Awesome, thanks
Will add your RB to v2 of the patch series
>
> Cheers,
> -- David
>
>> 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");
>
--
Cheers
~ Vaibhav
prev parent reply other threads:[~2026-06-08 8:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 16:27 [PATCH 0/2] kunit: Add support for skipping entire test suites Vaibhav Jain
2026-06-04 16:28 ` [PATCH 1/2] kunit: Add ability to skip " Vaibhav Jain
2026-06-05 5:09 ` David Gow
2026-06-08 9:04 ` Vaibhav Jain
2026-06-04 16:28 ` [PATCH 2/2] kunit: Add example of test suite that can be skipped at runtime Vaibhav Jain
2026-06-05 5:10 ` David Gow
2026-06-08 8:41 ` Vaibhav Jain [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=87cxy1mnkk.fsf@vajain21.in.ibm.com \
--to=vaibhav@linux.ibm.com \
--cc=brendan.higgins@linux.dev \
--cc=david@davidgow.net \
--cc=kunit-dev@googlegroups.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=raemoar63@gmail.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