linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	shuah@kernel.org, kees@kernel.org, luto@amacapital.net,
	wad@chromium.org, linux-kselftest@vger.kernel.org,
	usama.anjum@collabora.com, skhan@linuxfoundation.org
Subject: Re: [PATCH 3/3] selftests: harness: Add kselftest harness selftest with variant
Date: Tue, 17 Jun 2025 23:57:48 +0000	[thread overview]
Message-ID: <20250617235748.pbw2mrpneol6gajb@master> (raw)
In-Reply-To: <20250617093230-7c07d08b-5956-4a78-863c-f35cc300815c@linutronix.de>

On Tue, Jun 17, 2025 at 09:35:12AM +0200, Thomas Weißschuh wrote:
>Good idea.
>

Thanks.

>On Mon, Jun 16, 2025 at 12:23:38PM +0000, Wei Yang wrote:
>> Each fixture could support variant. Add fixture with variant to verify
>> the behavior, so we can validate for further change.
>> 
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>>  .../kselftest_harness/harness-selftest.c      | 34 +++++++++++++++++++
>>  .../harness-selftest.expected                 | 22 +++++++++---
>>  2 files changed, 52 insertions(+), 4 deletions(-)
>> 
>> diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.c b/tools/testing/selftests/kselftest_harness/harness-selftest.c
>> index b555493bdb4d..2fd5310b33c7 100644
>> --- a/tools/testing/selftests/kselftest_harness/harness-selftest.c
>> +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c
>> @@ -118,6 +118,40 @@ TEST_F(fixture_setup_failure, pass) {
>>  	TH_LOG("after");
>>  }
>>  
>> +FIXTURE(fixture_variant) {
>> +	pid_t testpid;
>> +};
>> +
>> +FIXTURE_VARIANT(fixture_variant)
>> +{
>> +	int value;
>> +};
>> +
>> +FIXTURE_VARIANT_ADD(fixture_variant, v32)
>> +{
>> +	.value = 32,
>> +};
>> +
>> +FIXTURE_VARIANT_ADD(fixture_variant, v64)
>> +{
>> +	.value = 64,
>> +};
>> +
>> +FIXTURE_SETUP(fixture_variant) {
>> +	TH_LOG("setup %d", variant->value);
>> +	self->testpid = getpid();
>> +}
>> +
>> +FIXTURE_TEARDOWN(fixture_variant) {
>> +	TH_LOG("teardown same-process=%d", self->testpid == getpid());
>> +}
>> +
>> +TEST_F(fixture_variant, pass) {
>> +	TH_LOG("before");
>> +	ASSERT_EQ(0, 0);
>
>Please log the variant value from the test itself and the teardown function.
>Also I don't think we need the pid logging and before/after/ASSERT in this test
>also, it is already validated in the other ones.
>

Sure, per my understanding, is this what you prefer?


FIXTURE_SETUP(fixture_variant) {
	TH_LOG("setup %d", variant->value);
}

FIXTURE_TEARDOWN(fixture_variant) {
	TH_LOG("teardown %d", variant->value);
}

TEST_F(fixture_variant, pass) {
	TH_LOG("before %d", variant->value);
	ASSERT_EQ(0, 0);
	TH_LOG("after %d", variant->value);
}


-- 
Wei Yang
Help you, Help me

  reply	other threads:[~2025-06-17 23:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 12:23 [PATCH 0/3] Add kselftest harness selftest with variant Wei Yang
2025-06-16 12:23 ` [PATCH 1/3] selftests: correct one typo in comment Wei Yang
2025-06-17  7:31   ` Thomas Weißschuh
2025-06-17 23:52     ` Wei Yang
2025-06-16 12:23 ` [PATCH 2/3] selftests: print 0 if no test is chosen Wei Yang
2025-06-16 12:44   ` Muhammad Usama Anjum
2025-06-16 22:49     ` Wei Yang
2025-06-16 12:23 ` [PATCH 3/3] selftests: harness: Add kselftest harness selftest with variant Wei Yang
2025-06-16 12:45   ` Muhammad Usama Anjum
2025-06-18  0:05     ` Wei Yang
2025-06-17  7:35   ` Thomas Weißschuh
2025-06-17 23:57     ` Wei Yang [this message]
2025-06-18  5:47       ` Thomas Weißschuh
2025-06-18  8:16         ` Wei Yang
2025-06-18  9:12           ` Wei Yang

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=20250617235748.pbw2mrpneol6gajb@master \
    --to=richard.weiyang@gmail.com \
    --cc=kees@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=usama.anjum@collabora.com \
    --cc=wad@chromium.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).