public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org,
	Jakub Kicinski <kuba@kernel.org>,
	joe@dama.to, shuah@kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH net-next] selftests: drv-net: update the README with variants
Date: Mon, 30 Mar 2026 17:19:30 -0700	[thread overview]
Message-ID: <20260331001930.3411279-1-kuba@kernel.org> (raw)

Test authors need to know about variants, existing tests don't use
them because variants are relatively recent.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: joe@dama.to
CC: shuah@kernel.org
CC: linux-kselftest@vger.kernel.org
---
 .../testing/selftests/drivers/net/README.rst  | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)

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
 ======================
 
-- 
2.53.0


             reply	other threads:[~2026-03-31  0:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31  0:19 Jakub Kicinski [this message]
2026-03-31 20:49 ` [PATCH net-next] selftests: drv-net: update the README with variants Joe Damato
2026-04-01  2:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260331001930.3411279-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=joe@dama.to \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox