Subject: Re: [PATCH net-next] selftests/net: convert so_txtime to drv-net

From: Jakub Kicinski <[email-masked]>
Date: Fri, 3 Apr 2026 13:28:55 -0700

On Fri,  3 Apr 2026 13:50:12 -0400 Willem de Bruijn wrote:
> From: Willem de Bruijn <[email-masked]>
> 
> In preparation for extending to pacing hardware offload, convert the
> so_txtime.sh test to a drv-net test that can be run against netdevsim
> and real hardware.
> 
> Also move so_txtime.c to lib so that it is easily accessible for the
> new drv-net test, similar to gro.c in commit 8888bf4fb980 ("selftests:
> net: move gro to lib for HW vs SW reuse").
> 
> Also update so_txtime.c to not exit on first failure, but run to
> completion and report exit code there. This helps with debugging
> unexpected results, especially when processing multiple packets,
> as in the "reverse_order" testcase.

> diff --git a/tools/testing/selftests/drivers/net/config b/tools/testing/selftests/drivers/net/config
> index 77ccf83d87e0..a3301d4da540 100644
> --- a/tools/testing/selftests/drivers/net/config
> +++ b/tools/testing/selftests/drivers/net/config
> @@ -3,6 +3,8 @@ CONFIG_DEBUG_INFO_BTF=y
>  CONFIG_DEBUG_INFO_BTF_MODULES=n
>  CONFIG_INET_PSP=y
>  CONFIG_IPV6=y
> +CONFIG_NET_SCH_ETF=m
> +CONFIG_NET_SCH_FQ=m

I think our sort order puts _ after characters

>  CONFIG_NETCONSOLE=m
>  CONFIG_NETCONSOLE_DYNAMIC=y
>  CONFIG_NETCONSOLE_EXTENDED_LOG=y
> diff --git a/tools/testing/selftests/drivers/net/so_txtime.py b/tools/testing/selftests/drivers/net/so_txtime.py
> new file mode 100755
> index 000000000000..565cecf307dd
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/net/so_txtime.py
> @@ -0,0 +1,87 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0
> +
> +"""Regression tests for the SO_TXTIME interface.
> +
> +Test delivery time in FQ and ETF qdiscs.
> +"""

> +import time
> +
> +from lib.py import ksft_exit, ksft_run
> +from lib.py import KsftNamedVariant, KsftSkipEx, ksft_variants
> +from lib.py import NetDrvEpEnv, bkg, cmd
> +
> +
> +def test_so_txtime(cfg, clockid, ipver, args_tx, args_rx, expect_fail):
> +  bin_path = cfg.net_lib_dir / "so_txtime"
> +
> +  tstart = time.time_ns() + 100_000_000
> +
> +  cmd_addr = f"-S {cfg.addr_v[ipver]} -D {cfg.remote_addr_v[ipver]}"
> +  cmd_base = f"{bin_path} -{ipver} -c {clockid} -t {tstart} {cmd_addr}"
> +  cmd_rx = f"{cmd_base} {args_rx} -r"
> +  cmd_tx = f"{cmd_base} {args_tx}"
> +
> +  try:
> +    with bkg(cmd_rx, host=cfg.remote, exit_wait=True):
> +      cmd(cmd_tx)
> +  except:
> +    if not expect_fail:
> +      raise

ruff check says:
tools/testing/selftests/drivers/net/so_txtime.py:29: [E722] Do not use bare `except`

Why not pass fail=(not expect_fail) to bkg ?

> +def main() -> None:

pylint --disable=R should be clean, please
I usually add something like:

	"""Boilerplate ksft main"""

> +  with NetDrvEpEnv(__file__) as cfg:
> +    ksft_run([test_so_txtime_mono], args=(cfg,))
> +    ksft_run([test_so_txtime_etf], args=(cfg,))

ksft_run() is not supposed to be called multiple times, it will break
KTAP format

> diff --git a/tools/testing/selftests/net/lib/Makefile b/tools/testing/selftests/net/lib/Makefile
> index ff83603397d0..8c50b6631524 100644
> --- a/tools/testing/selftests/net/lib/Makefile
> +++ b/tools/testing/selftests/net/lib/Makefile
> @@ -15,6 +15,7 @@ TEST_GEN_FILES := \
>  	$(patsubst %.c,%.o,$(wildcard *.bpf.c)) \
>  	csum \
>  	gro \
> +	so_txtime \

is there a reason for the binary to be in lib?
gro is used by drivers/net and drivers/net/hw
if the C helper / binary is only used by a single target it should live
in the same dir as the python code