diff mbox series

[v3,2/4] lib: Introduce KCONFIG_SKIP_CHECK environment variable

Message ID 1641779349-8424-2-git-send-email-xuyang2018.jy@fujitsu.com
State Superseded
Headers show
Series [v3,1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function | expand

Commit Message

Yang Xu Jan. 10, 2022, 1:49 a.m. UTC
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.

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(+)

Comments

Li Wang Jan. 10, 2022, 8:14 a.m. UTC | #1
Reviewed-by: Li Wang <liwang@redhat.com>
Cyril Hrubis Jan. 10, 2022, 12:20 p.m. UTC | #2
Hi!
> 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.
> 
> 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..864467f60 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).
                                                                           ^
									   Space
									   here
									   please
>  | '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..e4264101d 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_check_skipped(void)
                       ^
		       I would have named this same as the variable,
		       i.e. kconfig_skip_check()

Other that these two minor things:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Yang Xu Jan. 11, 2022, 1:38 a.m. UTC | #3
Hi Cyril
> Hi!
>> 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.
>>
>> 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..864467f60 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).
>                                                                             ^
> 									   Space
> 									   here
> 									   please
>>   | '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..e4264101d 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_check_skipped(void)
>                         ^
> 		       I would have named this same as the variable,
> 		       i.e. kconfig_skip_check()

Will fix these two comments in v5, thanks for your review.

Best Regards
Yang Xu
>
> Other that these two minor things:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
>
diff mbox series

Patch

diff --git a/doc/user-guide.txt b/doc/user-guide.txt
index 494652618..864467f60 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..e4264101d 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_check_skipped(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_check_skipped()) {
+		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_check_skipped()) {
+		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..8ac3cdc5c 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");