Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+33
+33
tools/testing/selftests/drivers/net/README.rst
··· 253 253 single-interface systems. All tests which may disconnect ``NETIF`` 254 254 must be annotated with ``@ksft_disruptive``. 255 255 256 + ksft_variants 257 + ~~~~~~~~~~~~~ 258 + 259 + Use the ``@ksft_variants`` decorator to run a test with multiple sets 260 + of inputs as separate test cases. This avoids duplicating test functions 261 + that only differ in parameters. 262 + 263 + Parameters can be a single value, a tuple, or a ``KsftNamedVariant`` 264 + (which gives an explicit name to the sub-case). The argument to the 265 + decorator can be a list or a generator. 266 + 267 + Example:: 268 + 269 + @ksft_variants([ 270 + KsftNamedVariant("main", False), 271 + KsftNamedVariant("ctx", True), 272 + ]) 273 + def resize_periodic(cfg, create_context): 274 + # test body receives (cfg, create_context) where create_context 275 + # is False for the "main" variant and True for "ctx" 276 + pass 277 + 278 + or:: 279 + 280 + def _gro_variants(): 281 + for mode in ["sw", "hw"]: 282 + for protocol in ["tcp4", "tcp6"]: 283 + yield (mode, protocol) 284 + 285 + @ksft_variants(_gro_variants()) 286 + def test(cfg, mode, protocol): 287 + pass 288 + 256 289 Running tests CI-style 257 290 ====================== 258 291