[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87y0o19j4h.fsf@nvidia.com>
Date: Thu, 20 Nov 2025 09:55:48 +0100
From: Petr Machata <petrm@...dia.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: <davem@...emloft.net>, <netdev@...r.kernel.org>, <edumazet@...gle.com>,
<pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>,
<willemdebruijn.kernel@...il.com>, <shuah@...nel.org>, <sdf@...ichev.me>,
<krakauer@...gle.com>, <linux-kselftest@...r.kernel.org>, <petrm@...dia.com>,
<matttbe@...nel.org>, Willem de Bruijn <willemb@...gle.com>
Subject: Re: [PATCH net-next v3 03/12] selftests: net: py: add test variants
Jakub Kicinski <kuba@...nel.org> writes:
> There's a lot of cases where we try to re-run the same code with
> different parameters. We currently need to either use a generator
> method or create a "main" case implementation which then gets called
> by trivial case functions:
>
> def _test(x, y, z):
> ...
>
> def case_int():
> _test(1, 2, 3)
>
> def case_str():
> _test('a', 'b', 'c')
>
> Add support for variants, similar to kselftests_harness.h and
> a lot of other frameworks. Variants can be added as decorator
> to test functions:
>
> @ksft_variants([(1, 2, 3), ('a', 'b', 'c')])
> def case(x, y, z):
> ...
>
> ksft_run() will auto-generate case names:
> case.1_2_3
> case.a_b_c
>
> Because the names may not always be pretty (and to avoid forcing
> classes to implement case-friendly __str__()) add a wrapper class
> KsftNamedVariant which lets the user specify the name for the variant.
>
> Note that ksft_run's args are still supported. ksft_run splices args
> and variant params together.
>
> Reviewed-by: Willem de Bruijn <willemb@...gle.com>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
Reviewed-by: Petr Machata <petrm@...dia.com>
Powered by blists - more mailing lists