Good idea.
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 <[email protected]>
> ---
> .../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.
> + TH_LOG("after");
> +}
> +
> 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..ab081c5aba05 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,19 @@ 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:141:pass:setup 32
> +# harness-selftest.c:150:pass:before
> +# harness-selftest.c:152:pass:after
> +# harness-selftest.c:146:pass:teardown same-process=1
> +# OK fixture_variant.v32.pass
> +ok 10 fixture_variant.v32.pass
> +# RUN fixture_variant.v64.pass ...
> +# harness-selftest.c:141:pass:setup 64
> +# harness-selftest.c:150:pass:before
> +# harness-selftest.c:152:pass:after
> +# harness-selftest.c:146:pass:teardown same-process=1
> +# 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
>