* [PATCH v3 2/2] selftests/lib.mk: Introduce check to validate required dependencies
@ 2025-01-16 20:09 Siddharth Menon
0 siblings, 0 replies; 2+ messages in thread
From: Siddharth Menon @ 2025-01-16 20:09 UTC (permalink / raw)
To: linux-kselftest
Cc: shuah, skhan, pmladek, mbenes, linux-kernel, Siddharth Menon
Currently, kselftests does not have a generalised mechanism to skip compilation
and run tests when required kernel configuration flags are missing.
This patch introduces a check to validate the presence of required config flags
specified in the selftest config files. In case scripts/config or the current
kernel config is not found, this check is skipped.
In order to skip checking for config options required to compile the test,
set the environment variable SKIP_CHECKS=1.
example usage:
```
make SKIP_CHECKS=1 -C livepatch/
```
Suggested-by: Petr Mladek <pmladek@suse.com>
Suggested-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Siddharth Menon <simeddon@gmail.com>
---
v1->v2:
- Moved the logic to check for required configurations
to an external script
v2 -> v3:
- Add SKIP_CHECKS flag to skip checking the dependencies
if required
- Updated the test skip statement to be more meaningful
tools/testing/selftests/lib.mk | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
mode change 100644 => 100755 tools/testing/selftests/lib.mk
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
old mode 100644
new mode 100755
index d6edcfcb5be8..0e11d1d3bab8
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -97,7 +97,18 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
-all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \
+TEST_DIR := $(shell pwd)
+
+check_kselftest_deps:
+ifneq ($(SKIP_CHECKS),1)
+ @$(selfdir)/check_kselftest_deps.pl $(TEST_DIR) $(CC) || { \
+ echo "Skipping test: $(notdir $(TEST_DIR)) (missing required kernel features)"; \
+ exit 1; \
+ }
+endif
+
+
+all: check_kselftest_deps $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \
$(if $(TEST_GEN_MODS_DIR),gen_mods_dir)
define RUN_TESTS
@@ -228,4 +239,4 @@ $(OUTPUT)/%:%.S
$(LINK.S) $^ $(LDLIBS) -o $@
endif
-.PHONY: run_tests all clean install emit_tests gen_mods_dir clean_mods_dir
+.PHONY: run_tests all clean install emit_tests gen_mods_dir clean_mods_dir check_kselftest_deps
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v3 2/2] selftests/lib.mk: Introduce check to validate required dependencies
2025-02-27 5:29 [PATCH v3 0/2 RESEND] update kselftest framework to check for required configs Siddharth Menon
@ 2025-02-27 5:29 ` Siddharth Menon
0 siblings, 0 replies; 2+ messages in thread
From: Siddharth Menon @ 2025-02-27 5:29 UTC (permalink / raw)
To: linux-kselftest, shuah
Cc: skhan, pmladek, mbenes, linux-kernel, Siddharth Menon
Currently, kselftests does not have a generalised mechanism to skip compilation
and run tests when required kernel configuration flags are missing.
This patch introduces a check to validate the presence of required config flags
specified in the selftest config files. In case scripts/config or the current
kernel config is not found, this check is skipped.
In order to skip checking for config options required to compile the test,
set the environment variable SKIP_CHECKS=1.
example usage:
```
make SKIP_CHECKS=1 -C livepatch/
```
Suggested-by: Petr Mladek <pmladek@suse.com>
Suggested-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Siddharth Menon <simeddon@gmail.com>
---
v1->v2:
- Moved the logic to check for required configurations
to an external script
v2 -> v3:
- Add SKIP_CHECKS flag to skip checking the dependencies
if required
- Updated the test skip statement to be more meaningful
tools/testing/selftests/lib.mk | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index d6edcfcb5be8..0e11d1d3bab8 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -97,7 +97,18 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
-all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \
+TEST_DIR := $(shell pwd)
+
+check_kselftest_deps:
+ifneq ($(SKIP_CHECKS),1)
+ @$(selfdir)/check_kselftest_deps.pl $(TEST_DIR) $(CC) || { \
+ echo "Skipping test: $(notdir $(TEST_DIR)) (missing required kernel features)"; \
+ exit 1; \
+ }
+endif
+
+
+all: check_kselftest_deps $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \
$(if $(TEST_GEN_MODS_DIR),gen_mods_dir)
define RUN_TESTS
@@ -228,4 +239,4 @@ $(OUTPUT)/%:%.S
$(LINK.S) $^ $(LDLIBS) -o $@
endif
-.PHONY: run_tests all clean install emit_tests gen_mods_dir clean_mods_dir
+.PHONY: run_tests all clean install emit_tests gen_mods_dir clean_mods_dir check_kselftest_deps
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-27 5:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 20:09 [PATCH v3 2/2] selftests/lib.mk: Introduce check to validate required dependencies Siddharth Menon
-- strict thread matches above, loose matches on Subject: below --
2025-02-27 5:29 [PATCH v3 0/2 RESEND] update kselftest framework to check for required configs Siddharth Menon
2025-02-27 5:29 ` [PATCH v3 2/2] selftests/lib.mk: Introduce check to validate required dependencies Siddharth Menon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).