linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch v2 0/2] Add kselftest harness selftest with variant
@ 2025-06-20  3:28 Wei Yang
  2025-06-20  3:28 ` [Patch v2 1/2] selftests: harness: correct typo of __constructor_order_forward in comment Wei Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Wei Yang @ 2025-06-20  3:28 UTC (permalink / raw)
  To: kees, luto, wad, shuah
  Cc: linux-kselftest, usama.anjum, thomas.weissschuh, Wei Yang

We already have a selftest for harness, while there is not usage 
of FIXTURE_VARIANT.                                                                                                                                                                                                   
                                                                                                                                                                                                                   
Patch 2 add FIXTURE_VARIANT usage in the selftest.

Patch 1 is a typo fix.

v2:
  * drop patch 2 in v1
  * adjust patch 2 based on Thomas comment

Wei Yang (2):
  selftests: harness: correct typo of __constructor_order_forward in
    comment
  selftests: harness: Add kselftest harness selftest with variant

 tools/testing/selftests/kselftest_harness.h   |  2 +-
 .../kselftest_harness/harness-selftest.c      | 30 +++++++++++++++++++
 .../harness-selftest.expected                 | 20 ++++++++++---
 3 files changed, 47 insertions(+), 5 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Patch v2 1/2] selftests: harness: correct typo of __constructor_order_forward in comment
  2025-06-20  3:28 [Patch v2 0/2] Add kselftest harness selftest with variant Wei Yang
@ 2025-06-20  3:28 ` Wei Yang
  2025-06-20  3:28 ` [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant Wei Yang
  2025-08-18  9:18 ` [Patch v2 0/2] " Wei Yang
  2 siblings, 0 replies; 8+ messages in thread
From: Wei Yang @ 2025-06-20  3:28 UTC (permalink / raw)
  To: kees, luto, wad, shuah
  Cc: linux-kselftest, usama.anjum, thomas.weissschuh, Wei Yang

The name is __constructor_order_forward.

Just correct it.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/testing/selftests/kselftest_harness.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 2925e47db995..674a6112e6e1 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -936,7 +936,7 @@ static inline bool __test_passed(struct __test_metadata *metadata)
  * list so tests are run in source declaration order.
  * https://gcc.gnu.org/onlinedocs/gccint/Initialization.html
  * However, it seems not all toolchains do this correctly, so use
- * __constructor_order_foward to detect which direction is called first
+ * __constructor_order_forward to detect which direction is called first
  * and adjust list building logic to get things running in the right
  * direction.
  */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant
  2025-06-20  3:28 [Patch v2 0/2] Add kselftest harness selftest with variant Wei Yang
  2025-06-20  3:28 ` [Patch v2 1/2] selftests: harness: correct typo of __constructor_order_forward in comment Wei Yang
@ 2025-06-20  3:28 ` Wei Yang
  2025-06-20  6:07   ` Thomas Weißschuh
  2025-06-20  7:12   ` Muhammad Usama Anjum
  2025-08-18  9:18 ` [Patch v2 0/2] " Wei Yang
  2 siblings, 2 replies; 8+ messages in thread
From: Wei Yang @ 2025-06-20  3:28 UTC (permalink / raw)
  To: kees, luto, wad, shuah
  Cc: linux-kselftest, usama.anjum, thomas.weissschuh, Wei Yang

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>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

---
v2:
  * remove testpid
  * print value in teardown and test itself
---
 .../kselftest_harness/harness-selftest.c      | 30 +++++++++++++++++++
 .../harness-selftest.expected                 | 20 ++++++++++---
 2 files changed, 46 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..2a2a91717fce 100644
--- a/tools/testing/selftests/kselftest_harness/harness-selftest.c
+++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c
@@ -118,6 +118,36 @@ TEST_F(fixture_setup_failure, pass) {
 	TH_LOG("after");
 }
 
+FIXTURE(fixture_variant) {
+};
+
+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);
+}
+
+FIXTURE_TEARDOWN(fixture_variant) {
+	TH_LOG("teardown %d", variant->value);
+}
+
+TEST_F(fixture_variant, pass) {
+	TH_LOG("test function %d", variant->value);
+}
+
 int main(int argc, char **argv)
 {
 	/*
diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.expected b/tools/testing/selftests/kselftest_harness/harness-selftest.expected
index 97e1418c1c7e..0c19794e018d 100644
--- a/tools/testing/selftests/kselftest_harness/harness-selftest.expected
+++ b/tools/testing/selftests/kselftest_harness/harness-selftest.expected
@@ -1,6 +1,6 @@
 TAP version 13
-1..9
-# Starting 9 tests from 4 test cases.
+1..11
+# Starting 11 tests from 6 test cases.
 #  RUN           global.standalone_pass ...
 # harness-selftest.c:19:standalone_pass:before
 # harness-selftest.c:23:standalone_pass:after
@@ -60,5 +60,17 @@ ok 8 fixture_parent.pass
 # pass: Test terminated by assertion
 #          FAIL  fixture_setup_failure.pass
 not ok 9 fixture_setup_failure.pass
-# FAILED: 4 / 9 tests passed.
-# Totals: pass:4 fail:5 xfail:0 xpass:0 skip:0 error:0
+#  RUN           fixture_variant.v32.pass ...
+# harness-selftest.c:140:pass:setup 32
+# harness-selftest.c:148:pass:test function 32
+# harness-selftest.c:144:pass:teardown 32
+#            OK  fixture_variant.v32.pass
+ok 10 fixture_variant.v32.pass
+#  RUN           fixture_variant.v64.pass ...
+# harness-selftest.c:140:pass:setup 64
+# harness-selftest.c:148:pass:test function 64
+# harness-selftest.c:144:pass:teardown 64
+#            OK  fixture_variant.v64.pass
+ok 11 fixture_variant.v64.pass
+# FAILED: 6 / 11 tests passed.
+# Totals: pass:6 fail:5 xfail:0 xpass:0 skip:0 error:0
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant
  2025-06-20  3:28 ` [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant Wei Yang
@ 2025-06-20  6:07   ` Thomas Weißschuh
  2025-06-20  6:51     ` Wei Yang
  2025-06-20  7:12   ` Muhammad Usama Anjum
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2025-06-20  6:07 UTC (permalink / raw)
  To: Wei Yang; +Cc: kees, luto, wad, shuah, linux-kselftest, usama.anjum

On Fri, Jun 20, 2025 at 03:28:15AM +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>
> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>

Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

> ---
> v2:
>   * remove testpid
>   * print value in teardown and test itself
> ---
>  .../kselftest_harness/harness-selftest.c      | 30 +++++++++++++++++++
>  .../harness-selftest.expected                 | 20 ++++++++++---
>  2 files changed, 46 insertions(+), 4 deletions(-)

<snip>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant
  2025-06-20  6:07   ` Thomas Weißschuh
@ 2025-06-20  6:51     ` Wei Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Wei Yang @ 2025-06-20  6:51 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Wei Yang, kees, luto, wad, shuah, linux-kselftest, usama.anjum

On Fri, Jun 20, 2025 at 08:07:46AM +0200, Thomas Weißschuh wrote:
>On Fri, Jun 20, 2025 at 03:28:15AM +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>
>> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
>
>Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>

Thanks

>> ---
>> v2:
>>   * remove testpid
>>   * print value in teardown and test itself
>> ---
>>  .../kselftest_harness/harness-selftest.c      | 30 +++++++++++++++++++
>>  .../harness-selftest.expected                 | 20 ++++++++++---
>>  2 files changed, 46 insertions(+), 4 deletions(-)
>
><snip>

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant
  2025-06-20  3:28 ` [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant Wei Yang
  2025-06-20  6:07   ` Thomas Weißschuh
@ 2025-06-20  7:12   ` Muhammad Usama Anjum
  2025-06-20  8:53     ` Wei Yang
  1 sibling, 1 reply; 8+ messages in thread
From: Muhammad Usama Anjum @ 2025-06-20  7:12 UTC (permalink / raw)
  To: Wei Yang, kees, luto, wad, shuah; +Cc: linux-kselftest, thomas.weissschuh

On 6/20/25 8:28 AM, 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>
> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
> Cc: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> 
> ---
> v2:
>   * remove testpid
>   * print value in teardown and test itself
> ---
>  .../kselftest_harness/harness-selftest.c      | 30 +++++++++++++++++++
>  .../harness-selftest.expected                 | 20 ++++++++++---
>  2 files changed, 46 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..2a2a91717fce 100644
> --- a/tools/testing/selftests/kselftest_harness/harness-selftest.c
> +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c
> @@ -118,6 +118,36 @@ TEST_F(fixture_setup_failure, pass) {
>  	TH_LOG("after");
>  }
>  
> +FIXTURE(fixture_variant) {
> +};
> +
> +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);
> +}
> +
> +FIXTURE_TEARDOWN(fixture_variant) {
> +	TH_LOG("teardown %d", variant->value);
> +}
> +
> +TEST_F(fixture_variant, pass) {
> +	TH_LOG("test function %d", variant->value);
> +}
> +
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

>  int main(int argc, char **argv)
>  {
>  	/*
> diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.expected b/tools/testing/selftests/kselftest_harness/harness-selftest.expected
> index 97e1418c1c7e..0c19794e018d 100644
> --- a/tools/testing/selftests/kselftest_harness/harness-selftest.expected
> +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.expected
> @@ -1,6 +1,6 @@
>  TAP version 13
> -1..9
> -# Starting 9 tests from 4 test cases.
> +1..11
> +# Starting 11 tests from 6 test cases.
>  #  RUN           global.standalone_pass ...
>  # harness-selftest.c:19:standalone_pass:before
>  # harness-selftest.c:23:standalone_pass:after
> @@ -60,5 +60,17 @@ ok 8 fixture_parent.pass
>  # pass: Test terminated by assertion
>  #          FAIL  fixture_setup_failure.pass
>  not ok 9 fixture_setup_failure.pass
> -# FAILED: 4 / 9 tests passed.
> -# Totals: pass:4 fail:5 xfail:0 xpass:0 skip:0 error:0
> +#  RUN           fixture_variant.v32.pass ...
> +# harness-selftest.c:140:pass:setup 32
> +# harness-selftest.c:148:pass:test function 32
> +# harness-selftest.c:144:pass:teardown 32
> +#            OK  fixture_variant.v32.pass
> +ok 10 fixture_variant.v32.pass
> +#  RUN           fixture_variant.v64.pass ...
> +# harness-selftest.c:140:pass:setup 64
> +# harness-selftest.c:148:pass:test function 64
> +# harness-selftest.c:144:pass:teardown 64
> +#            OK  fixture_variant.v64.pass
> +ok 11 fixture_variant.v64.pass
> +# FAILED: 6 / 11 tests passed.
> +# Totals: pass:6 fail:5 xfail:0 xpass:0 skip:0 error:0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant
  2025-06-20  7:12   ` Muhammad Usama Anjum
@ 2025-06-20  8:53     ` Wei Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Wei Yang @ 2025-06-20  8:53 UTC (permalink / raw)
  To: Muhammad Usama Anjum
  Cc: Wei Yang, kees, luto, wad, shuah, linux-kselftest,
	thomas.weissschuh

On Fri, Jun 20, 2025 at 12:12:40PM +0500, Muhammad Usama Anjum wrote:
[...]
>>  
>> +FIXTURE(fixture_variant) {
>> +};
>> +
>> +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);
>> +}
>> +
>> +FIXTURE_TEARDOWN(fixture_variant) {
>> +	TH_LOG("teardown %d", variant->value);
>> +}
>> +
>> +TEST_F(fixture_variant, pass) {
>> +	TH_LOG("test function %d", variant->value);
>> +}
>> +
>Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>

Thanks,  Muhammad :-)

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 0/2] Add kselftest harness selftest with variant
  2025-06-20  3:28 [Patch v2 0/2] Add kselftest harness selftest with variant Wei Yang
  2025-06-20  3:28 ` [Patch v2 1/2] selftests: harness: correct typo of __constructor_order_forward in comment Wei Yang
  2025-06-20  3:28 ` [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant Wei Yang
@ 2025-08-18  9:18 ` Wei Yang
  2 siblings, 0 replies; 8+ messages in thread
From: Wei Yang @ 2025-08-18  9:18 UTC (permalink / raw)
  To: Wei Yang
  Cc: kees, luto, wad, shuah, linux-kselftest, usama.anjum,
	thomas.weissschuh

On Fri, Jun 20, 2025 at 03:28:13AM +0000, Wei Yang wrote:
>We already have a selftest for harness, while there is not usage 
>of FIXTURE_VARIANT.                                                                                                                                                                                                   
>                                                                                                                                                                                                                   
>Patch 2 add FIXTURE_VARIANT usage in the selftest.
>
>Patch 1 is a typo fix.

Ping...

Would someone pick it up?

>
>v2:
>  * drop patch 2 in v1
>  * adjust patch 2 based on Thomas comment
>
>Wei Yang (2):
>  selftests: harness: correct typo of __constructor_order_forward in
>    comment
>  selftests: harness: Add kselftest harness selftest with variant
>
> tools/testing/selftests/kselftest_harness.h   |  2 +-
> .../kselftest_harness/harness-selftest.c      | 30 +++++++++++++++++++
> .../harness-selftest.expected                 | 20 ++++++++++---
> 3 files changed, 47 insertions(+), 5 deletions(-)
>
>-- 
>2.34.1

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-08-18  9:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20  3:28 [Patch v2 0/2] Add kselftest harness selftest with variant Wei Yang
2025-06-20  3:28 ` [Patch v2 1/2] selftests: harness: correct typo of __constructor_order_forward in comment Wei Yang
2025-06-20  3:28 ` [Patch v2 2/2] selftests: harness: Add kselftest harness selftest with variant Wei Yang
2025-06-20  6:07   ` Thomas Weißschuh
2025-06-20  6:51     ` Wei Yang
2025-06-20  7:12   ` Muhammad Usama Anjum
2025-06-20  8:53     ` Wei Yang
2025-08-18  9:18 ` [Patch v2 0/2] " Wei Yang

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).