[LTP] [PATCH v4 2/5] lib: Introduce KCONFIG_SKIP_CHECK environment variable

Yang Xu xuyang2018.jy@fujitsu.com
Tue Jan 11 07:10:32 CET 2022


This environment variable is designed to add kernel config check functionality
switch. So we can skip kconfig check completely and it is useful especially
for the embedded platforms that they don't have kernel config.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 doc/user-guide.txt |  1 +
 lib/tst_kconfig.c  | 20 ++++++++++++++++++++
 lib/tst_test.c     |  1 +
 3 files changed, 22 insertions(+)

diff --git a/doc/user-guide.txt b/doc/user-guide.txt
index 494652618..6b80bb699 100644
--- a/doc/user-guide.txt
+++ b/doc/user-guide.txt
@@ -10,6 +10,7 @@ For running LTP network tests see `testcases/network/README.md`.
 |==============================================================================
 | 'KCONFIG_PATH'        | The path to the kernel config file, (if not set, it tries
                           the usual paths '/boot/config-RELEASE' or '/proc/config.gz').
+| 'KCONFIG_SKIP_CHECK'  | Skip kernel config check, the default is empty (don't skip).
 | 'LTPROOT'             | Prefix for installed LTP, the default is '/opt/ltp'.
 | 'LTP_COLORIZE_OUTPUT' | Force colorized output behaviour. 'y' or '1': always colorize
                           'n' or '0': never colorize.
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index 7d7aecfc1..d0c9b24c2 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -15,6 +15,16 @@
 #include "tst_kconfig.h"
 #include "tst_bool_expr.h"
 
+static int kconfig_skip_check(void)
+{
+	char *skipped = getenv("KCONFIG_SKIP_CHECK");
+
+	if (skipped)
+		return 1;
+
+	return 0;
+}
+
 static const char *kconfig_path(char *path_buf, size_t path_buf_len)
 {
 	const char *path = getenv("KCONFIG_PATH");
@@ -485,6 +495,11 @@ int tst_kconfig_check(const char *const kconfigs[])
 	unsigned int i, var_cnt;
 	int ret = 0;
 
+	if (kconfig_skip_check()) {
+		tst_res(TINFO, "Skipping kernel config check as requested");
+		return 0;
+	}
+
 	for (i = 0; i < expr_cnt; i++) {
 		exprs[i] = tst_bool_expr_parse(kconfigs[i]);
 
@@ -526,6 +541,11 @@ char tst_kconfig_get(const char *confname)
 {
 	struct tst_kconfig_var var;
 
+	if (kconfig_skip_check()) {
+		tst_res(TINFO, "Skipping kernel config check as requested");
+		return 0;
+	}
+
 	var.id_len = strlen(confname);
 
 	if (var.id_len >= sizeof(var.id))
diff --git a/lib/tst_test.c b/lib/tst_test.c
index d5cefadaa..db19d0d68 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -479,6 +479,7 @@ static void print_help(void)
 	fprintf(stderr, "Environment Variables\n");
 	fprintf(stderr, "---------------------\n");
 	fprintf(stderr, "KCONFIG_PATH         Specify kernel config file\n");
+	fprintf(stderr, "KCONFIG_SKIP_CHECK   Skip kernel config check (the default is empty means don't skip)\n");
 	fprintf(stderr, "LTPROOT              Prefix for installed LTP (default: /opt/ltp)\n");
 	fprintf(stderr, "LTP_COLORIZE_OUTPUT  Force colorized output behaviour (y/1 always, n/0: never)\n");
 	fprintf(stderr, "LTP_DEV              Path to the block device to be used (for .needs_device)\n");
-- 
2.23.0



More information about the ltp mailing list