diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2026-03-30 17:19:30 -0700 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-03-31 19:18:20 -0700 |
| commit | f843687c30272d55739ef153ace29c58db2575ee (patch) | |
| tree | 7d93b2c553437233611443feb063199edcf3c777 /tools | |
| parent | 75171eeff3538c6859b50f6a516342c8f1ed6e00 (diff) | |
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.
Reviewed-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/20260331001930.3411279-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/testing/selftests/drivers/net/README.rst | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/testing/selftests/drivers/net/README.rst b/tools/testing/selftests/drivers/net/README.rst index c94992acf10b..b26b364be534 100644 --- a/tools/testing/selftests/drivers/net/README.rst +++ b/tools/testing/selftests/drivers/net/README.rst @@ -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 ====================== |
