Skip to contentSkip to conversation

selftests/drivers/net: include lib/sh/*.sh

PATCH Applied Hangbin Liu 6 participants 7 messages Sep 7 – Sep 9

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/drivers/net: include lib/sh/*.sh

From: Hangbin Liu <[email protected]>

When I tried to install and run bonding selftests via:

  make INSTALL_PATH=/tmp/kself TARGETS=drivers/net/bonding \
     -C tools/testing/selftests install

Some tests fail because net/lib/sh/defer.sh is missing:

/tmp/kself/net/forwarding/../lib.sh: line 5: /tmp/kself/net/lib/sh/defer.sh: No such file or directory

One option is to add defer.sh directly to TEST_INCLUDES. Alternatively, follow the approach from commit f72aa1b27628 ("selftests: net: include lib/sh/*.sh with lib.sh"), which pulls in all .sh files to accommodate future changes to the library directory.

This patch adds a wildcard to include all shell files for drivers/net tests that consume net lib.sh. TEST_INCLUDES is also sorted to avoid ordering‑related problems for future modifications. The team driver is not affected by this bug, but we use the wildcard for it as well, rather than listing only defer.sh.

Fixes a6e263f125cd ("selftests: net: lib: Introduce deferred commands")

---
Since this is a trivial fix, I have also updated the virtio_net part within this patch. Please let me know if I should split the virtio_net changes into a separate patch.

Before posting the patch, I ran make install for each subtest and verified that defer.sh gets installed.

---
 tools/testing/selftests/drivers/net/Makefile            | 1 +
 tools/testing/selftests/drivers/net/bonding/Makefile    | 3 ++-
 tools/testing/selftests/drivers/net/dsa/Makefile        | 1 +
 tools/testing/selftests/drivers/net/hw/Makefile         | 3 ++-
 tools/testing/selftests/drivers/net/netconsole/Makefile | 3 ++-
 tools/testing/selftests/drivers/net/team/Makefile       | 4 ++--
 tools/testing/selftests/drivers/net/virtio_net/Makefile | 1 +
 7 files changed, 11 insertions(+), 5 deletions(-)
tools/testing/selftests/drivers/net/Makefile +1 -0
index d5bf4cb638a8..ab39c2e508f0 100644
@@ -3,6 +3,7 @@ CFLAGS += $(KHDR_INCLUDES)
 
 TEST_INCLUDES := $(wildcard lib/py/*.py) \
 		 $(wildcard lib/sh/*.sh) \
+		 $(wildcard ../../net/lib/sh/*.sh) \
 		 ../../net/lib.sh \
 
 TEST_GEN_FILES := \
tools/testing/selftests/drivers/net/bonding/Makefile +2 -1
index 6364ca02642d..e337c099fb40 100644
@@ -27,9 +27,10 @@ TEST_FILES := \
 # end of TEST_FILES
 
 TEST_INCLUDES := \
-	../../../net/lib.sh \
+	$(wildcard ../../../net/lib/sh/*.sh) \
 	../lib/sh/lib_netcons.sh \
 	../../../net/forwarding/lib.sh \
+	../../../net/lib.sh \
 # end of TEST_INCLUDES
 
 include ../../../lib.mk
tools/testing/selftests/drivers/net/dsa/Makefile +1 -0
index 7994bd0e5c44..7893011b3842 100644
@@ -19,6 +19,7 @@ TEST_FILES := \
 # end of TEST_FILES
 
 TEST_INCLUDES := \
+	$(wildcard ../../../net/lib/sh/*.sh) \
 	../../../net/forwarding/bridge_locked_port.sh \
 	../../../net/forwarding/bridge_mdb.sh \
 	../../../net/forwarding/bridge_mld.sh \
tools/testing/selftests/drivers/net/hw/Makefile +2 -1
index 78bb0169350b..17c7e878ca42 100644
@@ -64,10 +64,11 @@ TEST_FILES := \
 
 TEST_INCLUDES := \
 	$(wildcard lib/py/*.py ../lib/py/*.py) \
-	../../../net/lib.sh \
+	$(wildcard ../../../net/lib/sh/*.sh) \
 	../../../net/forwarding/ipip_lib.sh \
 	../../../net/forwarding/lib.sh \
 	../../../net/forwarding/tc_common.sh \
+	../../../net/lib.sh \
 	#
 
 # YNL files, must be before "include ..lib.mk"
tools/testing/selftests/drivers/net/netconsole/Makefile +2 -1
index f0674c0017fc..c7972a40babf 100644
@@ -1,8 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 
 TEST_INCLUDES := \
-	../../../net/lib.sh \
+	$(wildcard ../../../net/lib/sh/*.sh) \
 	../lib/sh/lib_netcons.sh \
+	../../../net/lib.sh \
 # end of TEST_INCLUDES
 
 TEST_PROGS := \
tools/testing/selftests/drivers/net/team/Makefile +2 -2
index 7c58cf82121e..e40c83a92724 100644
@@ -13,12 +13,12 @@ TEST_PROGS := \
 # end of TEST_PROGS
 
 TEST_INCLUDES := \
-	team_lib.sh \
+	$(wildcard ../../../net/lib/sh/*.sh) \
 	../bonding/lag_lib.sh \
 	../../../net/forwarding/lib.sh \
 	../../../net/in_netns.sh \
 	../../../net/lib.sh \
-	../../../net/lib/sh/defer.sh \
+	team_lib.sh \
 # end of TEST_INCLUDES
 
 include ../../../lib.mk
tools/testing/selftests/drivers/net/virtio_net/Makefile +1 -0
index 868ece3fea1f..df34e29b5680 100644
@@ -5,6 +5,7 @@ TEST_PROGS = basic_features.sh
 TEST_FILES = virtio_net_common.sh
 
 TEST_INCLUDES = \
+	$(wildcard ../../../net/lib/sh/*.sh) \
 	../../../net/forwarding/lib.sh \
 	../../../net/lib.sh \
 # end of TEST_INCLUDES

---
base-commit: 38b6be101006d3e7af972999f45d4f1e8250587a
change-id: 20260904-selftest_lib_defer-0174ce436d8a

Best regards,

Signature · 1 line
Hangbin Liu <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Hangbin Liu

From: Hangbin Liu <[email protected]>

When I tried to install and run bonding selftests via:

  make INSTALL_PATH=/tmp/kself TARGETS=drivers/net/bonding \
     -C tools/testing/selftests install

Some tests fail because net/lib/sh/defer.sh is missing:

/tmp/kself/net/forwarding/../lib.sh: line 5: /tmp/kself/net/lib/sh/defer.sh: No such file or directory

One option is to add defer.sh directly to TEST_INCLUDES. Alternatively, follow the approach from commit f72aa1b27628 ("selftests: net: include lib/sh/*.sh with lib.sh"), which pulls in all .sh files to accommodate future changes to the library directory.

Quoted 8 lines

This patch adds a wildcard to include all shell files for drivers/net tests that consume net lib.sh. TEST_INCLUDES is also sorted to avoid ordering‑related problems for future modifications. The team driver is not affected by this bug, but we use the wildcard for it as well, rather than listing only defer.sh.

Fixes a6e263f125cd ("selftests: net: lib: Introduce deferred commands")
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Hangbin Liu
Quoted 16 lines · Hangbin Liu

From: Hangbin Liu <[email protected]>

When I tried to install and run bonding selftests via:

  make INSTALL_PATH=/tmp/kself TARGETS=drivers/net/bonding \
     -C tools/testing/selftests install

Some tests fail because net/lib/sh/defer.sh is missing:

/tmp/kself/net/forwarding/../lib.sh: line 5: /tmp/kself/net/lib/sh/defer.sh: No such file or directory

One option is to add defer.sh directly to TEST_INCLUDES. Alternatively, follow the approach from commit f72aa1b27628 ("selftests: net: include lib/sh/*.sh with lib.sh"), which pulls in all .sh files to accommodate future changes to the library directory.

Quoted 8 lines

This patch adds a wildcard to include all shell files for drivers/net tests that consume net lib.sh. TEST_INCLUDES is also sorted to avoid ordering‑related problems for future modifications. The team driver is not affected by this bug, but we use the wildcard for it as well, rather than listing only defer.sh.

Fixes a6e263f125cd ("selftests: net: lib: Introduce deferred commands")
Reviewed-by on v1 1/1
#3 lore raw
In reply to Hangbin Liu

Hi Hangbin,

Quoted 16 lines · Hangbin Liu

From: Hangbin Liu <[email protected]>

When I tried to install and run bonding selftests via:

  make INSTALL_PATH=/tmp/kself TARGETS=drivers/net/bonding \
     -C tools/testing/selftests install

Some tests fail because net/lib/sh/defer.sh is missing:

/tmp/kself/net/forwarding/../lib.sh: line 5: /tmp/kself/net/lib/sh/defer.sh: No such file or directory

One option is to add defer.sh directly to TEST_INCLUDES. Alternatively, follow the approach from commit f72aa1b27628 ("selftests: net: include lib/sh/*.sh with lib.sh"), which pulls in all .sh files to accommodate future changes to the library directory.

Quoted 5 lines

This patch adds a wildcard to include all shell files for drivers/net tests that consume net lib.sh. TEST_INCLUDES is also sorted to avoid ordering‑related problems for future modifications. The team driver is not affected by this bug, but we use the wildcard for it as well, rather than listing only defer.sh.

Thank you for fixing that!

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#4 lore raw
In reply to Hangbin Liu
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 0

- [Medium] Incomplete fix:
tools/testing/selftests/drivers/net/netdevsim/Makefile is the only…

--

selftests/drivers/net: include lib/sh/*.sh

This adds $(wildcard ../../net/lib/sh/*.sh) to TEST_INCLUDES in the drivers/net selftest Makefiles so that net/lib/sh/defer.sh gets installed by "make install", and sorts the TEST_INCLUDES lists while at it.

tools/testing/selftests/drivers/net/Makefile CFLAGS += $(KHDR_INCLUDES) · line 9

Quoted 12 lines
tools/testing/selftests/drivers/net/Makefile +1 -0
index d5bf4cb638a8c..ab39c2e508f0a 100644
@@ -3,6 +3,7 @@ CFLAGS += $(KHDR_INCLUDES)
 
 TEST_INCLUDES := $(wildcard lib/py/*.py) \
 		 $(wildcard lib/sh/*.sh) \
+		 $(wildcard ../../net/lib/sh/*.sh) \
 		 ../../net/lib.sh \
 
 TEST_GEN_FILES := \

[Severity: Medium]
Was drivers/net/netdevsim intentionally left out? It is the only Makefile under tools/testing/selftests/drivers/net/ that this patch does not touch, and it defines no TEST_INCLUDES at all:

tools/testing/selftests/drivers/net/netdevsim/Makefile:

	TEST_PROGS := \
		devlink.sh \
		...
		peer.sh \
		...
	# end of TEST_PROGS

	TEST_FILES := \
		ethtool-common.sh
	# end of TEST_FILES

	include ../../../lib.mk

Its installed scripts do consume the net shell libraries. peer.sh does:

	lib_dir=$(dirname $0)/../../../net
	source $lib_dir/lib.sh

and devlink.sh, devlink_in_netns.sh, devlink_trap.sh, fib.sh, fib_notifications.sh, hw_stats_l3.sh, nexthop.sh and psample.sh do:

	lib_dir=$(dirname $0)/../../../net/forwarding
	source $lib_dir/lib.sh

which reaches net/lib.sh, and that unconditionally sources defer.sh:

tools/testing/selftests/net/lib.sh:

	net_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
	source "$net_dir/lib/sh/defer.sh"

There is also no automatic fallback for this target, since the top-level Makefile only matches the exact strings net, drivers/net and drivers/net/hw:

tools/testing/selftests/Makefile:

	# Networking tests want the net/lib target, include it automatically
	ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),)
	ifeq ($(filter net/lib,$(TARGETS)),)
		INSTALL_DEP_TARGETS := net/lib
	endif
	endif

So does the failure quoted in the changelog still reproduce with:

	make INSTALL_PATH=/tmp/kself TARGETS=drivers/net/netdevsim \
		-C tools/testing/selftests install

The commit message says the patch "adds a wildcard to include all shell files for drivers/net tests that consume net lib.sh" — should that claim be narrowed, or netdevsim covered too?

Note the gap in netdevsim is wider than defer.sh: adding only $(wildcard ../../../net/lib/sh/*.sh) would not be enough, since ../../../net/lib.sh and ../../../net/forwarding/lib.sh are not installed either (plus devlink_lib.sh, fib_offload_lib.sh and tc_common.sh, which several of those scripts source).

For reference, drivers/net/dsa is also not in the default TARGETS list and this patch does cover it, and drivers/net/{mlxsw,ocelot,microchip} have no Makefile so they are not installable targets at all.

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907-selftest_lib_defer-v1-1-8af94645aaa3%40kylinos.cn
#5 lore raw
Quoted 35 lines · On Tue, Sep 08, 2026 at 07:29:16AM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 0

- [Medium] Incomplete fix:
tools/testing/selftests/drivers/net/netdevsim/Makefile is the only…

--

selftests/drivers/net: include lib/sh/*.sh

This adds $(wildcard ../../net/lib/sh/*.sh) to TEST_INCLUDES in the drivers/net selftest Makefiles so that net/lib/sh/defer.sh gets installed by "make install", and sorts the TEST_INCLUDES lists while at it.

tools/testing/selftests/drivers/net/Makefile CFLAGS += $(KHDR_INCLUDES) · line 9

Quoted 12 lines
tools/testing/selftests/drivers/net/Makefile +1 -0
index d5bf4cb638a8c..ab39c2e508f0a 100644
@@ -3,6 +3,7 @@ CFLAGS += $(KHDR_INCLUDES)
 
 TEST_INCLUDES := $(wildcard lib/py/*.py) \
 		 $(wildcard lib/sh/*.sh) \
+		 $(wildcard ../../net/lib/sh/*.sh) \
 		 ../../net/lib.sh \
 
 TEST_GEN_FILES := \

[Severity: Medium]
Was drivers/net/netdevsim intentionally left out? It is the only Makefile under tools/testing/selftests/drivers/net/ that this patch does not touch, and it defines no TEST_INCLUDES at all:

tools/testing/selftests/drivers/net/netdevsim/Makefile:

Quoted 12 lines
	TEST_PROGS := \
		devlink.sh \
		...
		peer.sh \
		...
	# end of TEST_PROGS

	TEST_FILES := \
		ethtool-common.sh
	# end of TEST_FILES

	include ../../../lib.mk

Yes, netdevsim doesn't have TEST_INCLUDES at all. I think it deserves its own separate patch.

Thanks
Hangbin

#6 lore raw
In reply to Hangbin Liu
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 07 Sep 2026 15:28:09 +0800 you wrote:

From: Hangbin Liu <[email protected]>

When I tried to install and run bonding selftests via:

  make INSTALL_PATH=/tmp/kself TARGETS=drivers/net/bonding \
     -C tools/testing/selftests install

[...]

Here is the summary with links:
- [net] selftests/drivers/net: include lib/sh/*.sh

    https://git.kernel.org/netdev/net-next/c/52176ca4e4d0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html