[LTP] [PATCH 1/1] Makefile: Add make 'modules' target

Petr Vorel pvorel@suse.cz
Fri Aug 1 11:42:05 CEST 2025


LTP contains few kernel modules and tests which are using them.  These
require to be built with the same kernel headers as the running kernel
(SUT). Sometimes the best way to achieve this is to compile them on the
SUT. Add make 'modules' target to make it easier to build them.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi all,

We build these modules in openQA during testing.  Hope you don't mind to
keep the list of directories with kernel modules in LTP (instead of
maintaining it outside). And hopefully it helps others which might face
the same problem.

I tempted to add also 'make install' to the target to shortcut
'make modules && make modules install' to just 'make modules', but that
would not be a clean and consistent approach.

Kind regards,
Petr

 INSTALL  |  8 ++++++++
 Makefile | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/INSTALL b/INSTALL
index cbe27f32ea..a7d48a45b3 100644
--- a/INSTALL
+++ b/INSTALL
@@ -165,6 +165,14 @@ PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./c
 * Arch Linux
 PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
 
+Kernel modules
+--------------
+
+LTP contains few kernel modules and tests which are using them.
+These require to be built with the same kernel headers as the running kernel (SUT).
+Sometimes the best way to achieve this is to compile them on the SUT.
+'make modules' target is a shortcut to build these kernel modules and tests.
+
 Android Users
 -------------
 
diff --git a/Makefile b/Makefile
index eab40da8a6..9042bdc945 100644
--- a/Makefile
+++ b/Makefile
@@ -212,6 +212,20 @@ endif
 test-metadata: metadata-all
 	$(MAKE) -C $(abs_srcdir)/metadata test
 
+MODULE_DIRS := commands/insmod \
+	testcases/kernel/firmware \
+	testcases/kernel/device-drivers \
+	testcases/kernel/syscalls/delete_module \
+	testcases/kernel/syscalls/finit_module \
+	testcases/kernel/syscalls/init_module
+
+.PHONY: modules
+modules:
+	@$(foreach dir,$(MODULE_DIRS),\
+		echo "Build $(dir)";\
+		$(MAKE) -C $(abs_srcdir)/$(dir); \
+)
+
 ## Help
 .PHONY: help
 help:
-- 
2.50.1



More information about the ltp mailing list