Merge branch 'selftests-TEST_INCLUDES'
Benjamin Poirier says: ==================== selftests: Add TEST_INCLUDES directive and adjust tests to use it After commit 25ae948b4478 ("selftests/net: add lib.sh") but before commit 2114e83381d3 ("selftests: forwarding: Avoid failures to source net/lib.sh"), some net selftests encountered errors when they were being exported and run. This was because the new net/lib.sh was not exported along with the tests. The errors were crudely avoided by duplicating some content between net/lib.sh and net/forwarding/lib.sh in 2114e83381d3. In order to restore the sourcing of net/lib.sh from net/forwarding/lib.sh and remove the duplicated content, this series introduces a new selftests Makefile variable to list extra files to export from other directories and makes use of it to avoid reintroducing the errors mentioned above. v2: * "selftests: Introduce Makefile variable to list shared bash scripts" Fix rst syntax in Documentation/dev-tools/kselftest.rst (Jakub Kicinski) v1: * "selftests: Introduce Makefile variable to list shared bash scripts" Changed TEST_INCLUDES to take relative paths, like other TEST_* variables. Paths are adjusted accordingly in the subsequent patches. (Vladimir Oltean) * selftests: bonding: Change script interpreter selftests: forwarding: Remove executable bits from lib.sh Removed from this series, submitted separately. Since commit 2114e83381d3 ("selftests: forwarding: Avoid failures to source net/lib.sh") resolved the test errors, this version of the series is focused on removing the duplication that was added in that commit. Directly rebasing the series would reintroduce the problems that 2114e83381d3 avoided before fixing them again. In order to prevent such breakage partway through the series, patches are reordered and content changed slightly but there is no diff at the end compared with the simple rebasing approach. I have dropped most review tags on account of this reordering. RFC: https://lore.kernel.org/netdev/20231222135836.992841-1-bpoirier@nvidia.com/ Link: https://lore.kernel.org/netdev/ZXu7dGj7F9Ng8iIX@Laptop-X1/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
1485082114
@ -255,9 +255,21 @@ Contributing new tests (details)
|
||||
|
||||
TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
|
||||
executable which is not tested by default.
|
||||
|
||||
TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
|
||||
test.
|
||||
|
||||
TEST_INCLUDES is similar to TEST_FILES, it lists files which should be
|
||||
included when exporting or installing the tests, with the following
|
||||
differences:
|
||||
|
||||
* symlinks to files in other directories are preserved
|
||||
* the part of paths below tools/testing/selftests/ is preserved when
|
||||
copying the files to the output directory
|
||||
|
||||
TEST_INCLUDES is meant to list dependencies located in other directories of
|
||||
the selftests hierarchy.
|
||||
|
||||
* First use the headers inside the kernel source and/or git repo, and then the
|
||||
system headers. Headers for the kernel release as opposed to headers
|
||||
installed by the distro on the system should be the primary focus to be able
|
||||
|
@ -191,6 +191,8 @@ run_tests: all
|
||||
@for TARGET in $(TARGETS); do \
|
||||
BUILD_TARGET=$$BUILD/$$TARGET; \
|
||||
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests \
|
||||
SRC_PATH=$(shell readlink -e $$(pwd)) \
|
||||
OBJ_PATH=$(BUILD) \
|
||||
O=$(abs_objtree); \
|
||||
done;
|
||||
|
||||
@ -241,7 +243,10 @@ ifdef INSTALL_PATH
|
||||
@ret=1; \
|
||||
for TARGET in $(TARGETS); do \
|
||||
BUILD_TARGET=$$BUILD/$$TARGET; \
|
||||
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \
|
||||
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \
|
||||
INSTALL_PATH=$(INSTALL_PATH)/$$TARGET \
|
||||
SRC_PATH=$(shell readlink -e $$(pwd)) \
|
||||
OBJ_PATH=$(INSTALL_PATH) \
|
||||
O=$(abs_objtree) \
|
||||
$(if $(FORCE_TARGETS),|| exit); \
|
||||
ret=$$((ret * $$?)); \
|
||||
|
@ -15,7 +15,10 @@ TEST_PROGS := \
|
||||
TEST_FILES := \
|
||||
lag_lib.sh \
|
||||
bond_topo_2d1c.sh \
|
||||
bond_topo_3d1c.sh \
|
||||
net_forwarding_lib.sh
|
||||
bond_topo_3d1c.sh
|
||||
|
||||
TEST_INCLUDES := \
|
||||
../../../net/forwarding/lib.sh \
|
||||
../../../net/lib.sh
|
||||
|
||||
include ../../../lib.mk
|
||||
|
@ -11,7 +11,7 @@ ALL_TESTS="
|
||||
REQUIRE_MZ=no
|
||||
NUM_NETIFS=0
|
||||
lib_dir=$(dirname "$0")
|
||||
source "$lib_dir"/net_forwarding_lib.sh
|
||||
source "$lib_dir"/../../../net/forwarding/lib.sh
|
||||
|
||||
bond_check_flags()
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
REQUIRE_MZ=no
|
||||
NUM_NETIFS=0
|
||||
lib_dir=$(dirname "$0")
|
||||
source ${lib_dir}/net_forwarding_lib.sh
|
||||
source "$lib_dir"/../../../net/forwarding/lib.sh
|
||||
|
||||
s_ns="s-$(mktemp -u XXXXXX)"
|
||||
c_ns="c-$(mktemp -u XXXXXX)"
|
||||
|
@ -14,7 +14,7 @@ ALL_TESTS="
|
||||
REQUIRE_MZ=no
|
||||
NUM_NETIFS=0
|
||||
lib_dir=$(dirname "$0")
|
||||
source "$lib_dir"/net_forwarding_lib.sh
|
||||
source "$lib_dir"/../../../net/forwarding/lib.sh
|
||||
|
||||
source "$lib_dir"/lag_lib.sh
|
||||
|
||||
|
@ -23,7 +23,7 @@ REQUIRE_MZ=no
|
||||
REQUIRE_JQ=no
|
||||
NUM_NETIFS=0
|
||||
lib_dir=$(dirname "$0")
|
||||
source "$lib_dir"/net_forwarding_lib.sh
|
||||
source "$lib_dir"/../../../net/forwarding/lib.sh
|
||||
source "$lib_dir"/lag_lib.sh
|
||||
|
||||
cleanup()
|
||||
|
@ -23,7 +23,7 @@ REQUIRE_MZ=no
|
||||
REQUIRE_JQ=no
|
||||
NUM_NETIFS=0
|
||||
lib_dir=$(dirname "$0")
|
||||
source "$lib_dir"/net_forwarding_lib.sh
|
||||
source "$lib_dir"/../../../net/forwarding/lib.sh
|
||||
source "$lib_dir"/lag_lib.sh
|
||||
|
||||
cleanup()
|
||||
|
@ -1 +0,0 @@
|
||||
../../../net/forwarding/lib.sh
|
@ -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
|
||||
|
@ -1 +1 @@
|
||||
../../../net/forwarding/bridge_locked_port.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/bridge_mdb.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/bridge_mld.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/bridge_vlan_aware.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/bridge_vlan_mcast.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/bridge_vlan_unaware.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +0,0 @@
|
||||
../../../net/forwarding/lib.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/local_termination.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +1 @@
|
||||
../../../net/forwarding/no_forwarding.sh
|
||||
run_net_forwarding_test.sh
|
9
tools/testing/selftests/drivers/net/dsa/run_net_forwarding_test.sh
Executable file
9
tools/testing/selftests/drivers/net/dsa/run_net_forwarding_test.sh
Executable file
@ -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" "$@"
|
@ -1 +1 @@
|
||||
../../../net/forwarding/tc_actions.sh
|
||||
run_net_forwarding_test.sh
|
@ -1 +0,0 @@
|
||||
../../../net/forwarding/tc_common.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"
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
TEST_PROGS := dev_addr_lists.sh
|
||||
|
||||
TEST_FILES := \
|
||||
lag_lib.sh \
|
||||
net_forwarding_lib.sh
|
||||
TEST_INCLUDES := \
|
||||
../bonding/lag_lib.sh \
|
||||
../../../net/forwarding/lib.sh \
|
||||
../../../net/lib.sh
|
||||
|
||||
include ../../../lib.mk
|
||||
|
@ -11,9 +11,9 @@ ALL_TESTS="
|
||||
REQUIRE_MZ=no
|
||||
NUM_NETIFS=0
|
||||
lib_dir=$(dirname "$0")
|
||||
source "$lib_dir"/net_forwarding_lib.sh
|
||||
source "$lib_dir"/../../../net/forwarding/lib.sh
|
||||
|
||||
source "$lib_dir"/lag_lib.sh
|
||||
source "$lib_dir"/../bonding/lag_lib.sh
|
||||
|
||||
|
||||
destroy()
|
||||
|
@ -1 +0,0 @@
|
||||
../bonding/lag_lib.sh
|
@ -1 +0,0 @@
|
||||
../../../net/forwarding/lib.sh
|
@ -69,11 +69,29 @@ define RUN_TESTS
|
||||
run_many $(1)
|
||||
endef
|
||||
|
||||
define INSTALL_INCLUDES
|
||||
$(if $(TEST_INCLUDES), \
|
||||
relative_files=""; \
|
||||
for entry in $(TEST_INCLUDES); do \
|
||||
entry_dir=$$(readlink -e "$$(dirname "$$entry")"); \
|
||||
entry_name=$$(basename "$$entry"); \
|
||||
relative_dir=$${entry_dir#"$$SRC_PATH"/}; \
|
||||
if [ "$$relative_dir" = "$$entry_dir" ]; then \
|
||||
echo "Error: TEST_INCLUDES entry \"$$entry\" not located inside selftests directory ($$SRC_PATH)" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
relative_files="$$relative_files $$relative_dir/$$entry_name"; \
|
||||
done; \
|
||||
cd $(SRC_PATH) && rsync -aR $$relative_files $(OBJ_PATH)/ \
|
||||
)
|
||||
endef
|
||||
|
||||
run_tests: all
|
||||
ifdef building_out_of_srctree
|
||||
@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
|
||||
rsync -aq --copy-unsafe-links $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT); \
|
||||
fi
|
||||
@$(INSTALL_INCLUDES)
|
||||
@if [ "X$(TEST_PROGS)" != "X" ]; then \
|
||||
$(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) \
|
||||
$(addprefix $(OUTPUT)/,$(TEST_PROGS))) ; \
|
||||
@ -103,6 +121,7 @@ endef
|
||||
install: all
|
||||
ifdef INSTALL_PATH
|
||||
$(INSTALL_RULE)
|
||||
$(INSTALL_INCLUDES)
|
||||
else
|
||||
$(error Error: set INSTALL_PATH to use install)
|
||||
endif
|
||||
|
@ -129,4 +129,7 @@ TEST_PROGS_EXTENDED := devlink_lib.sh \
|
||||
sch_tbf_etsprio.sh \
|
||||
tc_common.sh
|
||||
|
||||
TEST_INCLUDES := \
|
||||
../lib.sh
|
||||
|
||||
include ../../lib.mk
|
||||
|
@ -29,40 +29,13 @@ STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no}
|
||||
TCPDUMP_EXTRA_FLAGS=${TCPDUMP_EXTRA_FLAGS:=}
|
||||
TROUTE6=${TROUTE6:=traceroute6}
|
||||
|
||||
relative_path="${BASH_SOURCE%/*}"
|
||||
if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
|
||||
relative_path="."
|
||||
net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
|
||||
|
||||
if [[ -f $net_forwarding_dir/forwarding.config ]]; then
|
||||
source "$net_forwarding_dir/forwarding.config"
|
||||
fi
|
||||
|
||||
if [[ -f $relative_path/forwarding.config ]]; then
|
||||
source "$relative_path/forwarding.config"
|
||||
fi
|
||||
|
||||
# Kselftest framework requirement - SKIP code is 4.
|
||||
ksft_skip=4
|
||||
|
||||
busywait()
|
||||
{
|
||||
local timeout=$1; shift
|
||||
|
||||
local start_time="$(date -u +%s%3N)"
|
||||
while true
|
||||
do
|
||||
local out
|
||||
out=$("$@")
|
||||
local ret=$?
|
||||
if ((!ret)); then
|
||||
echo -n "$out"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local current_time="$(date -u +%s%3N)"
|
||||
if ((current_time - start_time > timeout)); then
|
||||
echo -n "$out"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
source "$net_forwarding_dir/../lib.sh"
|
||||
|
||||
##############################################################################
|
||||
# Sanity checks
|
||||
|
@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
source "$relative_path/mirror_lib.sh"
|
||||
source "$net_forwarding_dir/mirror_lib.sh"
|
||||
|
||||
quick_test_span_gre_dir_ips()
|
||||
{
|
||||
|
@ -33,7 +33,7 @@
|
||||
# | |
|
||||
# +-------------------------------------------------------------------------+
|
||||
|
||||
source "$relative_path/mirror_topo_lib.sh"
|
||||
source "$net_forwarding_dir/mirror_topo_lib.sh"
|
||||
|
||||
mirror_gre_topo_h3_create()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user