[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231222135836.992841-11-bpoirier@nvidia.com>
Date: Fri, 22 Dec 2023 08:58:36 -0500
From: Benjamin Poirier <bpoirier@...dia.com>
To: netdev@...r.kernel.org
Cc: Shuah Khan <shuah@...nel.org>,
Petr Machata <petrm@...dia.com>,
Hangbin Liu <liuhangbin@...il.com>,
Vladimir Oltean <vladimir.oltean@....com>
Subject: [RFC PATCH net-next 10/10] selftests: dsa: Replace symlinks by wrapper script
Since commit 25ae948b4478 ("selftests/net: add lib.sh"), when exporting the
dsa tests and running them, the tests which import net/forwarding/lib.sh
(via the lib.sh symlink) fail to import net/lib.sh. This is especially a
problem for the tc_actions.sh test which uses `busywait` from net/lib.sh:
$ make install TARGETS="drivers/net/dsa"
$ cd kselftest_install/drivers/net/dsa
$ ./tc_actions.sh veth{0..3}
lib.sh: line 38: /src/linux/tools/testing/selftests/kselftest_install/drivers/net/dsa/../lib.sh: No such file or directory
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
TEST: gact drop and ok (skip_hw) [FAIL]
Packet was not dropped
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
TEST: mirred egress flower redirect (skip_hw) [FAIL]
Did not match incoming redirect packet
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
TEST: mirred egress flower mirror (skip_hw) [FAIL]
Did not match incoming mirror packet
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
TEST: mirred egress matchall mirror (skip_hw) [FAIL]
Did not match incoming mirror packet
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
TEST: mirred_egress_to_ingress (skip_hw) [FAIL]
didn't mirror first packet
tc_common.sh: line 15: busywait: command not found
tc_common.sh: line 15: busywait: command not found
TEST: mirred_egress_to_ingress_tcp (skip_hw) [FAIL]
didn't mirred redirect ICMP
INFO: Could not test offloaded functionality
(I manually created the veth interfaces just to demonstrate running the
test.)
The dsa tests which are symlinks of tests from net/forwarding/ (like
tc_actions.sh) become regular files after export (because `rsync
--copy-unsafe-links` is used) and expect to source lib.sh
(net/forwarding/lib.sh) from the same directory. That lib.sh then expects
to source net/lib.sh from the parent directory but this does not work
because net/lib.sh is not present under drivers/net/.
Since the tests in net/forwarding/ are not meant to be copied and run from
another directory, the failure to source net/lib.sh is solved by replacing
the test symlinks by a wrapper script which runs the original tests under
net/forwarding/. The links to shared library scripts can then be removed
and all the files needed from parent directories are added to
TEST_INCLUDES.
Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
Suggested-by: Hangbin Liu <liuhangbin@...il.com>
Signed-off-by: Benjamin Poirier <bpoirier@...dia.com>
---
.../testing/selftests/drivers/net/dsa/Makefile | 18 ++++++++++++++++--
.../drivers/net/dsa/bridge_locked_port.sh | 2 +-
.../selftests/drivers/net/dsa/bridge_mdb.sh | 2 +-
.../selftests/drivers/net/dsa/bridge_mld.sh | 2 +-
.../drivers/net/dsa/bridge_vlan_aware.sh | 2 +-
.../drivers/net/dsa/bridge_vlan_mcast.sh | 2 +-
.../drivers/net/dsa/bridge_vlan_unaware.sh | 2 +-
tools/testing/selftests/drivers/net/dsa/lib.sh | 1 -
.../drivers/net/dsa/local_termination.sh | 2 +-
.../selftests/drivers/net/dsa/no_forwarding.sh | 2 +-
.../drivers/net/dsa/run_net_forwarding_test.sh | 9 +++++++++
.../selftests/drivers/net/dsa/tc_actions.sh | 2 +-
.../selftests/drivers/net/dsa/tc_common.sh | 1 -
.../drivers/net/dsa/test_bridge_fdb_stress.sh | 2 +-
14 files changed, 35 insertions(+), 14 deletions(-)
delete mode 120000 tools/testing/selftests/drivers/net/dsa/lib.sh
create mode 100755 tools/testing/selftests/drivers/net/dsa/run_net_forwarding_test.sh
delete mode 120000 tools/testing/selftests/drivers/net/dsa/tc_common.sh
diff --git a/tools/testing/selftests/drivers/net/dsa/Makefile b/tools/testing/selftests/drivers/net/dsa/Makefile
index c393e7b73805..8259eac80c3b 100644
--- a/tools/testing/selftests/drivers/net/dsa/Makefile
+++ b/tools/testing/selftests/drivers/net/dsa/Makefile
@@ -11,8 +11,22 @@ TEST_PROGS = bridge_locked_port.sh \
tc_actions.sh \
test_bridge_fdb_stress.sh
-TEST_PROGS_EXTENDED := lib.sh tc_common.sh
+TEST_FILES := \
+ run_net_forwarding_test.sh \
+ forwarding.config
-TEST_FILES := forwarding.config
+TEST_INCLUDES := \
+ net/forwarding/bridge_locked_port.sh \
+ net/forwarding/bridge_mdb.sh \
+ net/forwarding/bridge_mld.sh \
+ net/forwarding/bridge_vlan_aware.sh \
+ net/forwarding/bridge_vlan_mcast.sh \
+ net/forwarding/bridge_vlan_unaware.sh \
+ net/forwarding/lib.sh \
+ net/forwarding/local_termination.sh \
+ net/forwarding/no_forwarding.sh \
+ net/forwarding/tc_actions.sh \
+ net/forwarding/tc_common.sh \
+ net/lib.sh
include ../../../lib.mk
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh b/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
index f5eb940c4c7c..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
@@ -1 +1 @@
-../../../net/forwarding/bridge_locked_port.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh b/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
index 76492da525f7..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
@@ -1 +1 @@
-../../../net/forwarding/bridge_mdb.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh b/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
index 81a7e0df0474..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
@@ -1 +1 @@
-../../../net/forwarding/bridge_mld.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
index 9831ed74376a..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
@@ -1 +1 @@
-../../../net/forwarding/bridge_vlan_aware.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
index 7f3c3f0bf719..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
@@ -1 +1 @@
-../../../net/forwarding/bridge_vlan_mcast.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
index bf1a57e6bde1..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
@@ -1 +1 @@
-../../../net/forwarding/bridge_vlan_unaware.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/lib.sh b/tools/testing/selftests/drivers/net/dsa/lib.sh
deleted file mode 120000
index 39c96828c5ef..000000000000
--- a/tools/testing/selftests/drivers/net/dsa/lib.sh
+++ /dev/null
@@ -1 +0,0 @@
-../../../net/forwarding/lib.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/local_termination.sh b/tools/testing/selftests/drivers/net/dsa/local_termination.sh
index c08166f84501..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/local_termination.sh
+++ b/tools/testing/selftests/drivers/net/dsa/local_termination.sh
@@ -1 +1 @@
-../../../net/forwarding/local_termination.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh b/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
index b9757466bc97..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
+++ b/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
@@ -1 +1 @@
-../../../net/forwarding/no_forwarding.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/run_net_forwarding_test.sh b/tools/testing/selftests/drivers/net/dsa/run_net_forwarding_test.sh
new file mode 100755
index 000000000000..4106c0a102ea
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/run_net_forwarding_test.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+libdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
+testname=$(basename "${BASH_SOURCE[0]}")
+
+source "$libdir"/forwarding.config
+cd "$libdir"/../../../net/forwarding/ || exit 1
+source "./$testname" "$@"
diff --git a/tools/testing/selftests/drivers/net/dsa/tc_actions.sh b/tools/testing/selftests/drivers/net/dsa/tc_actions.sh
index 306213d9430e..d16a65e7595d 120000
--- a/tools/testing/selftests/drivers/net/dsa/tc_actions.sh
+++ b/tools/testing/selftests/drivers/net/dsa/tc_actions.sh
@@ -1 +1 @@
-../../../net/forwarding/tc_actions.sh
\ No newline at end of file
+run_net_forwarding_test.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/tc_common.sh b/tools/testing/selftests/drivers/net/dsa/tc_common.sh
deleted file mode 120000
index bc3465bdc36b..000000000000
--- a/tools/testing/selftests/drivers/net/dsa/tc_common.sh
+++ /dev/null
@@ -1 +0,0 @@
-../../../net/forwarding/tc_common.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh b/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh
index 92acab83fbe2..74682151d04d 100755
--- a/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh
+++ b/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh
@@ -19,7 +19,7 @@ REQUIRE_JQ="no"
REQUIRE_MZ="no"
NETIF_CREATE="no"
lib_dir=$(dirname "$0")
-source "$lib_dir"/lib.sh
+source "$lib_dir"/../../../net/forwarding/lib.sh
cleanup() {
echo "Cleaning up"
--
2.43.0
Powered by blists - more mailing lists