selftests: drv-net: update the README with variants
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 selftests: drv-net: update the README with variants
Test authors need to know about variants, existing tests don't use them because variants are relatively recent.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- .../testing/selftests/drivers/net/README.rst | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
tools/testing/selftests/drivers/net/README.rst +33 -0
@@ -253,6 +253,39 @@ By default the tests are expected to be able to run on single-interface systems. All tests which may disconnect ``NETIF`` must be annotated with ``@ksft_disruptive``. +ksft_variants +~~~~~~~~~~~~~ + +Use the ``@ksft_variants`` decorator to run a test with multiple sets +of inputs as separate test cases. This avoids duplicating test functions +that only differ in parameters. + +Parameters can be a single value, a tuple, or a ``KsftNamedVariant`` +(which gives an explicit name to the sub-case). The argument to the +decorator can be a list or a generator. + +Example:: + + @ksft_variants([ + KsftNamedVariant("main", False), + KsftNamedVariant("ctx", True), + ]) + def resize_periodic(cfg, create_context): + # test body receives (cfg, create_context) where create_context + # is False for the "main" variant and True for "ctx" + pass + +or:: + + def _gro_variants(): + for mode in ["sw", "hw"]: + for protocol in ["tcp4", "tcp6"]: + yield (mode, protocol) + + @ksft_variants(_gro_variants()) + def test(cfg, mode, protocol): + pass + Running tests CI-style ======================
Signature · 1 line
2.53.0
Quoted 11 lines · Jakub Kicinski
Test authors need to know about variants, existing tests don't use them because variants are relatively recent.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- .../testing/selftests/drivers/net/README.rst | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Mon, 30 Mar 2026 17:19:30 -0700 you wrote:
Test authors need to know about variants, existing tests don't use them because variants are relatively recent.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected][...]
Here is the summary with links:
- [net-next] selftests: drv-net: update the README with variants
https://git.kernel.org/netdev/net-next/c/f843687c3027
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html