Message ID | 1641881435-2351-2-git-send-email-xuyang2018.jy@fujitsu.com |
---|---|
State | Accepted |
Headers | show |
Series | [v4,1/5] lib/tst_kconfig: Modify the return type of tst_kconfig_check function | expand |
Hi Xu, > 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. very nit: I'd write it a bit simpler. Maybe: Add environment variable to disable kernel config check functionality. It is useful for embedded platforms which don't have kernel config installed. > +++ 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). s/empty/not set/ ? maybe: Skip kernel config check if variable set (not set by default). ... > +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"); I suppose you expect tests / library use kconfig_skip_check() in the future for some detection. If not I'd move tst_res(TINFO, ...) into kconfig_skip_check(). Otherwise LGTM. Reviewed-by: Petr Vorel <pvorel@suse.cz> Kind regards, Petr
Hi Petr > Hi Xu, > >> 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. > > very nit: I'd write it a bit simpler. Maybe: > Add environment variable to disable kernel config check functionality. > It is useful for embedded platforms which don't have kernel config installed. > >> +++ 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). > s/empty/not set/ ? > maybe: Skip kernel config check if variable set (not set by default). > Sounds reasonable. > ... > >> +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"); > I suppose you expect tests / library use kconfig_skip_check() in the future for > some detection. If not I'd move tst_res(TINFO, ...) into kconfig_skip_check(). I don't have this plan. So move it into kconfig_skip_check(). Best Regards Yang Xu > > Otherwise LGTM. > > Reviewed-by: Petr Vorel<pvorel@suse.cz> > > Kind regards, > Petr
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");