public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Poirier <bpoirier@nvidia.com>
To: netdev@vger.kernel.org
Cc: Shuah Khan <shuah@kernel.org>, Petr Machata <petrm@nvidia.com>,
	Hangbin Liu <liuhangbin@gmail.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [RFC PATCH net-next 10/10] selftests: dsa: Replace symlinks by wrapper script
Date: Fri, 22 Dec 2023 08:58:36 -0500	[thread overview]
Message-ID: <20231222135836.992841-11-bpoirier@nvidia.com> (raw)
In-Reply-To: <20231222135836.992841-1-bpoirier@nvidia.com>

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@gmail.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.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


  parent reply	other threads:[~2023-12-22 14:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 13:58 [RFC PATCH net-next 00/10] selftests: Add TEST_INCLUDES directive and adjust tests to use it Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 01/10] selftests: bonding: Change script interpreter Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 02/10] selftests: forwarding: Remove executable bits from lib.sh Benjamin Poirier
2023-12-27 19:24   ` Vladimir Oltean
2023-12-22 13:58 ` [RFC PATCH net-next 03/10] selftests: forwarding: Import top-level lib.sh through absolute path Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 04/10] selftests: forwarding: Simplify forwarding.config import logic Benjamin Poirier
2023-12-27 19:27   ` Vladimir Oltean
2023-12-28 19:07     ` Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 05/10] selftests: Introduce Makefile variable to list shared bash scripts Benjamin Poirier
2023-12-27 19:43   ` Vladimir Oltean
2023-12-27 19:47     ` Vladimir Oltean
2023-12-28 19:28       ` Benjamin Poirier
2023-12-28 20:38         ` Vladimir Oltean
2023-12-22 13:58 ` [RFC PATCH net-next 06/10] selftests: forwarding: Add net/lib.sh to TEST_INCLUDES Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 07/10] selftests: bonding: Add lib.sh scripts " Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 08/10] selftests: team: " Benjamin Poirier
2023-12-22 13:58 ` [RFC PATCH net-next 09/10] selftests: team: Add shared library script " Benjamin Poirier
2023-12-22 13:58 ` Benjamin Poirier [this message]
2023-12-27 20:11   ` [RFC PATCH net-next 10/10] selftests: dsa: Replace symlinks by wrapper script Vladimir Oltean
2023-12-28 19:36     ` Benjamin Poirier
2023-12-28 20:33       ` Vladimir Oltean
2023-12-23  9:27 ` [RFC PATCH net-next 00/10] selftests: Add TEST_INCLUDES directive and adjust tests to use it Hangbin Liu

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=20231222135836.992841-11-bpoirier@nvidia.com \
    --to=bpoirier@nvidia.com \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=vladimir.oltean@nxp.com \
    /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