Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Siddharth Menon <simeddon@gmail.com>
To: simeddon@gmail.com, shuah@kernel.org
Cc: skhan@linuxfoundation.org, pmladek@suse.com, mbenes@suse.cz,
	linux-kselftest@vger.kernel.org
Subject: [PATCH v2 2/2] selftests/lib.mk: Introduce check to validate required configs
Date: Sat, 21 Dec 2024 01:05:36 +0530	[thread overview]
Message-ID: <20241220193536.13781-3-simeddon@gmail.com> (raw)
In-Reply-To: <20241220193536.13781-1-simeddon@gmail.com>

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 view the missing config options required to compile the test,
set the environment variable LOCALMODCONFIG_DEBUG=1.

example usage:
```
LOCALMODCONFIG_DEBUG=1 make -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 config checking logic to a separate perl script
 tools/testing/selftests/lib.mk | 11 +++++++++--
 1 file changed, 9 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..98dda6d8d702
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -97,7 +97,14 @@ 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_config_deps:
+	@$(selfdir)/mktest.pl $(TEST_DIR)/config || \
+	{ echo "Skipping test: $(notdir $(TEST_DIR))"; exit 1; }
+
+
+all: check_config_deps $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \
 	$(if $(TEST_GEN_MODS_DIR),gen_mods_dir)
 
 define RUN_TESTS
@@ -228,4 +235,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_config_deps
-- 
2.39.5


  parent reply	other threads:[~2024-12-20 19:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 19:35 [PATCH v2 0/2] update kselftest framework to check for required configs Siddharth Menon
2024-12-20 19:35 ` [PATCH v2 1/2] selftests: Introduce script to validate " Siddharth Menon
2025-01-07 13:44   ` Petr Mladek
2024-12-20 19:35 ` Siddharth Menon [this message]
2025-01-07 13:53   ` [PATCH v2 2/2] selftests/lib.mk: Introduce check " Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220193536.13781-3-simeddon@gmail.com \
    --to=simeddon@gmail.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox