Skip to content

Commit 7bc16e7

Browse files
t-8chshuahkh
authored andcommitted
kunit: Make filter parameters configurable via Kconfig
Enable the preset of filter parameters from kconfig options, similar to how other KUnit configuration parameters are handled already. This is useful to run a subset of tests even if the cmdline is not readily modifyable. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 9de5f84 commit 7bc16e7

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

lib/kunit/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,30 @@ config KUNIT_AUTORUN_ENABLED
9393
In most cases this should be left as Y. Only if additional opt-in
9494
behavior is needed should this be set to N.
9595

96+
config KUNIT_DEFAULT_FILTER_GLOB
97+
string "Default value of the filter_glob module parameter"
98+
help
99+
Sets the default value of kunit.filter_glob. If set to a non-empty
100+
string only matching tests are executed.
101+
102+
If unsure, leave empty so all tests are executed.
103+
104+
config KUNIT_DEFAULT_FILTER
105+
string "Default value of the filter module parameter"
106+
help
107+
Sets the default value of kunit.filter. If set to a non-empty
108+
string only matching tests are executed.
109+
110+
If unsure, leave empty so all tests are executed.
111+
112+
config KUNIT_DEFAULT_FILTER_ACTION
113+
string "Default value of the filter_action module parameter"
114+
help
115+
Sets the default value of kunit.filter_action. If set to a non-empty
116+
string only matching tests are executed.
117+
118+
If unsure, leave empty so all tests are executed.
119+
96120
config KUNIT_DEFAULT_TIMEOUT
97121
int "Default value of the timeout module parameter"
98122
default 300

lib/kunit/executor.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ bool kunit_autorun(void)
4545
return autorun_param;
4646
}
4747

48-
static char *filter_glob_param;
49-
static char *filter_param;
50-
static char *filter_action_param;
48+
#define PARAM_FROM_CONFIG(config) (config[0] ? config : NULL)
49+
50+
static char *filter_glob_param = PARAM_FROM_CONFIG(CONFIG_KUNIT_DEFAULT_FILTER_GLOB);
51+
static char *filter_param = PARAM_FROM_CONFIG(CONFIG_KUNIT_DEFAULT_FILTER);
52+
static char *filter_action_param = PARAM_FROM_CONFIG(CONFIG_KUNIT_DEFAULT_FILTER_ACTION);
5153

5254
module_param_named(filter_glob, filter_glob_param, charp, 0600);
5355
MODULE_PARM_DESC(filter_glob,

0 commit comments

Comments
 (0)