selftests/net: convert so_txtime to drv-net
Subsystems (4)
Willem de Bruijn
maintainerPATCH v2 1/1 selftests/net: convert so_txtime to drv-net
From: Willem de Bruijn <[email protected]>
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 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.
----
v1 -> v2
- move so_txtime.c for net/lib to drivers/net (Jakub)
- fix drivers/net/config order (Jakub)
- detect passing when failure is expected (Jakub, Sashiko)
- pass pylint --disable=R (Jakub)
- only call ksft_run once (Jakub)
- do not sleep if waiting time is negative (Sashiko)
- add \n when converting error() to fprintf() (Sashiko)
- 4 space indentation, instead of 2 space
- increase sync delay from 100 to 200ms, to fix rare vng flakes
v1: https://lore.kernel.org/netdev/[email protected]/
---
.../testing/selftests/drivers/net/.gitignore | 1 +
tools/testing/selftests/drivers/net/Makefile | 5 +-
tools/testing/selftests/drivers/net/config | 2 +
.../selftests/{ => drivers}/net/so_txtime.c | 24 +++-
.../selftests/drivers/net/so_txtime.py | 88 ++++++++++++++
tools/testing/selftests/net/.gitignore | 1 -
tools/testing/selftests/net/Makefile | 2 -
tools/testing/selftests/net/so_txtime.sh | 110 ------------------
8 files changed, 114 insertions(+), 119 deletions(-)
rename tools/testing/selftests/{ => drivers}/net/so_txtime.c (96%)
create mode 100755 tools/testing/selftests/drivers/net/so_txtime.py
delete mode 100755 tools/testing/selftests/net/so_txtime.shtools/testing/selftests/drivers/net/.gitignore +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only napi_id_helper psp_responder +so_txtime
tools/testing/selftests/drivers/net/Makefile +4 -1
@@ -20,12 +20,15 @@ TEST_PROGS := \ queues.py \ ring_reconfig.py \ shaper.py \ + so_txtime.py \ stats.py \ xdp.py \ # end of TEST_PROGS # YNL files, must be before "include ..lib.mk" -YNL_GEN_FILES := psp_responder +YNL_GEN_FILES := \ + psp_responder \ + so_txtime TEST_GEN_FILES += $(YNL_GEN_FILES) include ../../lib.mk
tools/testing/selftests/drivers/net/config +2 -0
@@ -7,4 +7,6 @@ CONFIG_NETCONSOLE=m CONFIG_NETCONSOLE_DYNAMIC=y CONFIG_NETCONSOLE_EXTENDED_LOG=y CONFIG_NETDEVSIM=m +CONFIG_NET_SCH_ETF=m +CONFIG_NET_SCH_FQ=m CONFIG_XDP_SOCKETS=y
tools/testing/selftests/drivers/net/so_txtime.c renamed from tools/testing/selftests/net/so_txtime.c +19 -5
@@ -33,6 +33,8 @@#include <unistd.h> #include <poll.h> +#include "kselftest.h" +static int cfg_clockid =CLOCK_TAI ;static uint16_t cfg_port =8000 ;static int cfg_variance_us =4000 ;
@@ -43,6 +45,8 @@ static bool cfg_rx;static uint64_t glob_tstart;static uint64_t tdeliver_max; +static int errors; +/* encode one timed transmission (of a 1B payload) */ struct timed_send {char data;
@@ -131,13 +135,15 @@ static void do_recv_one(int fdr, struct timed_send *ts)fprintf (stderr,"payload:%c delay:%lld expected:%lld (us)\n" , rbuf[0 ], (long long )tstop, (long long )texpect); -if (rbuf[0 ] != ts->data) -error (1 ,0 ,"payload mismatch. expected %c" , ts->data); +if (rbuf[0 ] != ts->data) { +fprintf (stderr,"payload mismatch. expected %c\n" , ts->data); + errors++; + }if (llabs (tstop - texpect) > cfg_variance_us) {fprintf (stderr,"exceeds variance (%d us)\n" , cfg_variance_us);if (!getenv ("KSFT_MACHINE_SLOW" )) -exit (1 ); + errors++; } }
@@ -255,8 +261,11 @@ static void start_time_wait(void)return ; now =gettime_ns (CLOCK_REALTIME ); -if (cfg_start_time_ns < now) +if (cfg_start_time_ns < now) { +fprintf (stderr,"FAIL: start time already passed\n" ); + errors++;return ; + } err =usleep ((cfg_start_time_ns - now) /1000 );if (err)
@@ -513,5 +522,10 @@ int main(int argc, char **argv)else do_test_tx ((void *)&cfg_src_addr, cfg_alen); -return 0 ; +if (errors) { +fprintf (stderr,"FAIL: %d errors\n" , errors); +return KSFT_FAIL ; + } + +return KSFT_PASS ; }
tools/testing/selftests/drivers/net/so_txtime.py new file +88 -0
88 lines not on this page · raw message
tools/testing/selftests/net/.gitignore +0 -1
@@ -40,7 +40,6 @@ skf_net_off socket so_incoming_cpu so_netns_cookie -so_txtime so_rcv_listener stress_reuseport_listen tap
tools/testing/selftests/net/Makefile +0 -2
@@ -81,7 +81,6 @@ TEST_PROGS := \ rxtimestamp.sh \ sctp_vrf.sh \ skf_net_off.sh \ - so_txtime.sh \ srv6_end_dt46_l3vpn_test.sh \ srv6_end_dt4_l3vpn_test.sh \ srv6_end_dt6_l3vpn_test.sh \
@@ -154,7 +153,6 @@ TEST_GEN_FILES := \ skf_net_off \ so_netns_cookie \ so_rcv_listener \ - so_txtime \ socket \ stress_reuseport_listen \ tcp_fastopen_backup_key \
tools/testing/selftests/net/so_txtime.sh deleted +0 -110
110 lines not on this page · raw message
Signature · 1 line
2.53.0.1213.gd9a14994de-goog
Willem de Bruijn
maintainerQuoted 58 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
In preparation for extending to pacing hardware offload, convert the
so_txtime.shtest to a drv-net test that can be run against netdevsim and real hardware.Also update
so_txtime.cto 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.Signed-off-by Willem de Bruijn <[email protected]>----
v1 -> v2
- moveso_txtime.cfor net/lib todrivers/net(Jakub)
- fixdrivers/net/configorder (Jakub)
- detect passing when failure is expected (Jakub, Sashiko)
- pass pylint --disable=R (Jakub)
- only callksft_runonce (Jakub)
- do not sleep if waiting time is negative (Sashiko)
- add \n when convertingerror()tofprintf()(Sashiko)
- 4 space indentation, instead of 2 space
- increase sync delay from 100 to 200ms, to fix rare vng flakesv1: https://lore.kernel.org/netdev/[email protected]/
--- .../testing/selftests/drivers/net/.gitignore | 1 + tools/testing/selftests/drivers/net/Makefile | 5 +- tools/testing/selftests/drivers/net/config | 2 + .../selftests/{ => drivers}/net/so_txtime.c | 24 +++- .../selftests/drivers/net/so_txtime.py | 88 ++++++++++++++ tools/testing/selftests/net/.gitignore | 1 - tools/testing/selftests/net/Makefile | 2 - tools/testing/selftests/net/so_txtime.sh | 110 ------------------ 8 files changed, 114 insertions(+), 119 deletions(-) rename tools/testing/selftests/{ => drivers}/net/so_txtime.c (96%) create mode 100755 tools/testing/selftests/drivers/net/so_txtime.py delete mode 100755 tools/testing/selftests/net/so_txtime.shtools/testing/selftests/drivers/net/.gitignore +1
-0@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only napi_id_helper psp_responder +so_txtimetools/testing/selftests/drivers/net/Makefile +0
-0@@ -20,12 +20,15 @@ TEST_PROGS := \ queues.py \ ring_reconfig.py \ shaper.py \
tools/testing/selftests/drivers/net/Makefile TEST_PROGS := \ · line 31
Quoted 10 lines
tools/testing/selftests/drivers/net/Makefile +4
-1+ so_txtime.py \ stats.py \ xdp.py \ # end of TEST_PROGS # YNL files, must be before "include ..lib.mk" -YNL_GEN_FILES := psp_responder +YNL_GEN_FILES := \ + psp_responder \ + so_txtime
This should just go under TEST_GEN_FILES (sashiko)
I don't quite understand the check_selftest check_new_files_makefile failure.
Jakub Kicinski
maintainerQuoted 8 lines · On Sat, 04 Apr 2026 22:20:15 -0400 Willem de Bruijn wrote:
tools/testing/selftests/drivers/net/Makefile TEST_PROGS := \ · line 31
Quoted 3 lines
tools/testing/selftests/drivers/net/Makefile +3
-0+YNL_GEN_FILES := \ + psp_responder \ + so_txtimeThis should just go under
TEST_GEN_FILES(sashiko)I don't quite understand the
check_selftestcheck_new_files_makefilefailure.
Glancing at the code you were missing the
# end of YNL_GEN_FILES
trailer.
Those checkers are equally annoying and easy to run locally, they take a path to the modified file and say "good" / "bad".
Willem de Bruijn
maintainerQuoted 10 lines · Jakub Kicinski
Quoted 8 lines · On Sat, 04 Apr 2026 22:20:15 -0400 Willem de Bruijn wrote:
tools/testing/selftests/drivers/net/Makefile TEST_PROGS := \ · line 31
Quoted 3 lines
tools/testing/selftests/drivers/net/Makefile +3
-0+YNL_GEN_FILES := \ + psp_responder \ + so_txtimeThis should just go under
TEST_GEN_FILES(sashiko)I don't quite understand the
check_selftestcheck_new_files_makefilefailure.
Quoted 8 lines
Glancing at the code you were missing the
# end of YNL_GEN_FILEStrailer.
Those checkers are equally annoying and easy to run locally, they take a path to the modified file and say "good" / "bad".
Thanks. Indeed, I only learned about this yesterday. Ran it before v3. Was super easy. Sharing for anyone else new to this:
git format-patch -1
mkdir /tmp/patches
mv 000* /tmp/patches
cd /tmp
git clone https://github.com/linux-netdev/nipa.git
cd nipa
./ingest_mdir.py --mdir /tmp/patches --tree ~/src/kernel/netdev/nn -t patch/check_selftest
--- output
Saving output and logs to: /tmp/tmp7zb9n8ka
Tree name unknown
[1] selftests/net: convert so_txtime to drv-net
Series level tests:
Patch level tests:
check_selftest OKAY Good format (5); New files in Makefile checked (1)