Skip to contentSkip to conversation

selftests/Make: Recursively build TARGETS list

PATCH New Dmitry Safonov 1 participant 3 messages Sep 19, 2022

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

v2 cover selftests/Make: Recursively build TARGETS list

Version 2 changes:
- fix make install in sub-directories with TARGETS, but with no TEST_LIST defined, i.e. selftests/net directory (reported-by: kernel test robot <[email protected]>)
- vfork_exec selftest is about to be reverted, don't add .gitignore entry

From [1]:

Quoted 2 lines

Please look into a wayto invoke all of them instead of adding individual net/* to the main Makefile. This list seems to be growing. :)

I might have misunderstood what was suggested... Here is an attempt to let sub-selftests define their own $(TARGETS) directories.

[1]: https://lore.kernel.org/all/[email protected]/T/#u

Version 1: https://lore.kernel.org/all/[email protected]/T/#u

Dmitry Safonov (2):
selftests/Make: Recursively build TARGETS list
selftests/.gitignore: Add io_uring_zerocopy_tx

 tools/testing/selftests/Makefile             | 71 ++++----------------
 tools/testing/selftests/drivers/Makefile     |  7 ++
 tools/testing/selftests/filesystems/Makefile |  4 ++
 tools/testing/selftests/lib.mk               | 60 ++++++++++++++++-
 tools/testing/selftests/net/.gitignore       |  1 +
 tools/testing/selftests/net/Makefile         |  4 ++
 6 files changed, 87 insertions(+), 60 deletions(-)
 create mode 100644 tools/testing/selftests/drivers/Makefile

base-commit: 521a547ced6477c54b4b0cc206000406c221b4d6

Signature · 1 line
2.37.2
#1 lore raw

PATCH v2 1/2 selftests/Make: Recursively build TARGETS list

From [1]:

Quoted 2 lines

Please look into a wayto invoke all of them instead of adding individual net/* to the main Makefile. This list seems to be growing. :)

I might have misunderstood what was suggested... Here is an attempt to let sub-selftests define their own $(TARGETS) directories.

[1]: https://lore.kernel.org/all/[email protected]/T/#u

Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 tools/testing/selftests/Makefile             | 71 ++++----------------
 tools/testing/selftests/drivers/Makefile     |  7 ++
 tools/testing/selftests/filesystems/Makefile |  4 ++
 tools/testing/selftests/lib.mk               | 60 ++++++++++++++++-
 tools/testing/selftests/net/Makefile         |  4 ++
 5 files changed, 86 insertions(+), 60 deletions(-)
 create mode 100644 tools/testing/selftests/drivers/Makefile
tools/testing/selftests/Makefile +12 -59
index c2064a35688b..69bb25f7b3b8 100644
@@ -10,15 +10,10 @@ TARGETS += core
 TARGETS += cpufreq
 TARGETS += cpu-hotplug
 TARGETS += damon
-TARGETS += drivers/dma-buf
-TARGETS += drivers/s390x/uvdevice
-TARGETS += drivers/net/bonding
+TARGETS += drivers
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
-TARGETS += filesystems/binderfs
-TARGETS += filesystems/epoll
-TARGETS += filesystems/fat
 TARGETS += firmware
 TARGETS += fpu
 TARGETS += ftrace
@@ -44,9 +39,6 @@ TARGETS += move_mount_set_group
 TARGETS += mqueue
 TARGETS += nci
 TARGETS += net
-TARGETS += net/af_unix
-TARGETS += net/forwarding
-TARGETS += net/mptcp
 TARGETS += netfilter
 TARGETS += nsfs
 TARGETS += pidfd
@@ -93,16 +85,14 @@ TARGETS_HOTPLUG += memory-hotplug
 # BPF since it has cutting edge build time dependencies which require
 # more effort to install.
 SKIP_TARGETS ?= bpf
-ifneq ($(SKIP_TARGETS),)
-	TMP := $(filter-out $(SKIP_TARGETS), $(TARGETS))
-	override TARGETS := $(TMP)
-endif
+export SKIP_TARGETS
 
 # User can set FORCE_TARGETS to 1 to require all targets to be successfully
 # built; make will fail if any of the targets cannot be built. If
 # FORCE_TARGETS is not set (the default), make will succeed if at least one
 # of the targets gets built.
 FORCE_TARGETS ?=
+export FORCE_TARGETS
 
 # Clear LDFLAGS and MAKEFLAGS when implicit rules are missing.  This provides
 # implicit rules to sub-test Makefiles which avoids build failures in test
@@ -145,6 +135,7 @@ endif
 # Prepare for headers install
 include $(top_srcdir)/scripts/subarch.include
 ARCH           ?= $(SUBARCH)
+export abs_objtree
 export BUILD
 export KHDR_INCLUDES
 
@@ -152,23 +143,7 @@ export KHDR_INCLUDES
 # all isn't the first target in the file.
 .DEFAULT_GOAL := all
 
-all:
-	@ret=1;							\
-	for TARGET in $(TARGETS); do				\
-		BUILD_TARGET=$$BUILD/$$TARGET;			\
-		mkdir $$BUILD_TARGET  -p;			\
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET	\
-				O=$(abs_objtree)		\
-				$(if $(FORCE_TARGETS),|| exit);	\
-		ret=$$((ret * $$?));				\
-	done; exit $$ret;
-
-run_tests: all
-	@for TARGET in $(TARGETS); do \
-		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests \
-				O=$(abs_objtree);		    \
-	done;
+OUTPUT := $(BUILD)
 
 hotplug:
 	@for TARGET in $(TARGETS_HOTPLUG); do \
@@ -204,8 +179,9 @@ KSFT_INSTALL_PATH := $(abspath $(KSFT_INSTALL_PATH))
 INSTALL_PATH := $(KSFT_INSTALL_PATH)
 ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
 TEST_LIST := $(INSTALL_PATH)/kselftest-list.txt
+export TEST_LIST
 
-install: all
+main_install: all
 ifdef INSTALL_PATH
 	@# Ask all targets to install their files
 	mkdir -p $(INSTALL_PATH)/kselftest
@@ -214,31 +190,14 @@ ifdef INSTALL_PATH
 	install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/
 	install -m 744 run_kselftest.sh $(INSTALL_PATH)/
 	rm -f $(TEST_LIST)
-	@ret=1;	\
-	for TARGET in $(TARGETS); do \
-		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \
-				O=$(abs_objtree)		\
-				$(if $(FORCE_TARGETS),|| exit);	\
-		ret=$$((ret * $$?));		\
-	done; exit $$ret;
-
-
-	@# Ask all targets to emit their test scripts
-	@# While building kselftest-list.text skip also non-existent TARGET dirs:
-	@# they could be the result of a build failure and should NOT be
-	@# included in the generated runlist.
-	for TARGET in $(TARGETS); do \
-		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		[ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \
-		echo -ne "Emit Tests for $$TARGET\n"; \
-		$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
-			-C $$TARGET emit_tests >> $(TEST_LIST); \
-	done;
 else
 	$(error Error: set INSTALL_PATH to use install)
 endif
 
+include lib.mk
+
+install: main_install
+
 FORMAT ?= .gz
 TAR_PATH = $(abspath ${INSTALL_PATH}/kselftest-packages/kselftest.tar${FORMAT})
 gen_tar: install
@@ -246,10 +205,4 @@ gen_tar: install
 	@tar caf ${TAR_PATH} --exclude=kselftest-packages -C ${INSTALL_PATH} .
 	@echo "Created ${TAR_PATH}"
 
-clean:
-	@for TARGET in $(TARGETS); do \
-		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
-	done;
-
-.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
+.PHONY: run_tests hotplug run_hotplug clean_hotplug run_pstore_crash gen_tar
tools/testing/selftests/drivers/Makefile new file +7 -0
new file mode 100644
index 000000000000..4d4693c8efbc
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+
+TARGETS += dma-buf
+TARGETS += s390x/uvdevice
+TARGETS += net/bonding
+
+include ../lib.mk
tools/testing/selftests/filesystems/Makefile +4 -0
index 129880fb42d3..04fde0107d7a 100644
@@ -4,4 +4,8 @@ CFLAGS += -I../../../../usr/include/
 TEST_GEN_PROGS := devpts_pts
 TEST_GEN_PROGS_EXTENDED := dnotify_test
 
+TARGETS += binderfs
+TARGETS += epoll
+TARGETS += fat
+
 include ../lib.mk
tools/testing/selftests/lib.mk +59 -1

98 lines not on this page · raw message

tools/testing/selftests/net/Makefile +4 -0
index c0ee2955fe54..ef768c0992f5 100644
@@ -66,6 +66,10 @@ TEST_GEN_FILES += io_uring_zerocopy_tx
 
 TEST_FILES := settings
 
+TARGETS += af_unix
+TARGETS += forwarding
+TARGETS += mptcp
+
 include ../lib.mk
 
 include bpf/Makefile
Signature · 1 line
2.37.2
#2 lore raw

PATCH v2 2/2 selftests/.gitignore: Add io_uring_zerocopy_tx

In reply to Dmitry Safonov
Fixes d8b6171bd58a ("selftests/io_uring: test zerocopy send")
---
 tools/testing/selftests/net/.gitignore | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/net/.gitignore +1 -0
index de7d5cc15f85..e17b4f1ad770 100644
@@ -3,6 +3,7 @@ cmsg_sender
 fin_ack_lat
 gro
 hwtstamp_config
+io_uring_zerocopy_tx
 ioam6_parser
 ip_defrag
 ipsec
Signature · 1 line
2.37.2