Commit 14850821 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'selftests-TEST_INCLUDES'

Benjamin Poirier says:

====================
selftests: Add TEST_INCLUDES directive and adjust tests to use it

After commit 25ae948b ("selftests/net: add lib.sh") but before commit
2114e833 ("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 2114e833.

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 2114e833 ("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 2114e833
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: default avatarDavid S. Miller <davem@davemloft.net>
parents bc34d10c 521ed1ce
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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
+6 −1
Original line number Diff line number Diff line
@@ -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 * $$?));		\
+5 −2
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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()
{
+1 −1
Original line number Diff line number Diff line
@@ -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)"
Loading