Skip to contentSkip to conversation

build: run make check on test sources in kernel module directories

PATCH Applied Andrea Cervesato 4 participants 4 messages Jun 10 – Jun 15

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: run make check on test sources in kernel module directories

From: Andrea Cervesato <[email protected]>

In directories that build a kernel module, module.mk set CHECK_TARGETS with ':=' before env_post.mk could populate it via '?=', leaving it empty so 'make check' never ran sparse/checkpatch on the test sources. The filter also used a '%.ko' pattern that never matched any 'check-<name>' entry.

Drop the broken assignment from module.mk and instead exclude the kernel module sources (MODULE_SOURCES) in env_post.mk once CHECK_TARGETS has been populated, so test sources are checked while kernel module code is skipped.

---
 include/mk/env_post.mk | 2 +-
 include/mk/module.mk   | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
include/mk/env_post.mk +1 -1
index 726b9a9e7526562f4f6e8363da394485c805fa88..43983197638a2ba42a9c1a20e072fa3179e04344 100644
@@ -70,7 +70,7 @@ endif # END $(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS)
 endif
 
 CHECK_TARGETS			?= $(addprefix check-,$(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c)))))
-CHECK_TARGETS			:= $(filter-out $(addprefix check-, $(FILTER_OUT_MAKE_TARGETS)), $(CHECK_TARGETS))
+CHECK_TARGETS			:= $(filter-out $(addprefix check-, $(FILTER_OUT_MAKE_TARGETS) $(notdir $(basename $(MODULE_SOURCES)))), $(CHECK_TARGETS))
 CHECK_HEADER_TARGETS		?= $(addprefix check-,$(notdir $(sort $(wildcard $(abs_srcdir)/*.h))))
 CHECK				?= $(abs_top_srcdir)/tools/sparse/sparse-ltp
 CHECK_NOFLAGS			?= CHECKPATCH_CONFIG_DIR="$(abs_top_srcdir)" $(abs_top_srcdir)/scripts/checkpatch.pl -f --root $(abs_top_srcdir)
include/mk/module.mk +0 -2
index 3e97f01289e2eb4f5a494c55a83022860b37a835..8949d9067ca6afdb790de122ff4ff56e38a54066 100644
@@ -51,8 +51,6 @@ endif
 
 CLEAN_TARGETS += .dep_modules *.mod built-in.a
 
-CHECK_TARGETS := $(filter-out %.ko, $(CHECK_TARGETS))
-
 MODULE_SOURCES := $(patsubst %.ko,%.c,$(filter %.ko, $(MAKE_TARGETS)))
 
 # Ignoring the exit status of commands is done to be forward compatible with

---
base-commit: c1b71bf7ebb6a58507e4998faf5c74154f595f96
change-id: 20260610-fix_buildsystem_modules-a5df16c4fdae

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Andrea,

Quoted 1 line · Andrea Cervesato

build: run make check on test sources in kernel module directories

Verdict: Reviewed

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrea Cervesato

Hi!

Quoted 8 lines

In directories that build a kernel module, module.mk set CHECK_TARGETS with ':=' before env_post.mk could populate it via '?=', leaving it empty so 'make check' never ran sparse/checkpatch on the test sources. The filter also used a '%.ko' pattern that never matched any 'check-<name>' entry.

Drop the broken assignment from module.mk and instead exclude the kernel module sources (MODULE_SOURCES) in env_post.mk once CHECK_TARGETS has been populated, so test sources are checked while kernel module code is skipped.

Also I guess that we may want to run vanilla checkpatch for the module sources, but that would require a bigger changes I suppose.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp