}
bool kunit_enabled(void);
+const char *kunit_action(void);
void kunit_init_test(struct kunit *test, const char *name, char *log);
void __kunit_test_suites_exit(struct kunit_suite **suites, int num_suites);
void kunit_exec_run_tests(struct kunit_suite_set *suite_set, bool builtin);
+void kunit_exec_list_tests(struct kunit_suite_set *suite_set, bool include_attr);
#if IS_BUILTIN(CONFIG_KUNIT)
int kunit_run_all_tests(void);
extern struct kunit_suite * const __kunit_suites_start[];
extern struct kunit_suite * const __kunit_suites_end[];
+static char *action_param;
+
+module_param_named(action, action_param, charp, 0400);
+MODULE_PARM_DESC(action,
+ "Changes KUnit executor behavior, valid values are:\n"
+ "<none>: run the tests like normal\n"
+ "'list' to list test names instead of running them.\n"
+ "'list_attr' to list test names and attributes instead of running them.\n");
+
+const char *kunit_action(void)
+{
+ return action_param;
+}
+
#if IS_BUILTIN(CONFIG_KUNIT)
static char *filter_glob_param;
-static char *action_param;
static char *filter_param;
static char *filter_action_param;
module_param_named(filter_glob, filter_glob_param, charp, 0);
MODULE_PARM_DESC(filter_glob,
"Filter which KUnit test suites/tests run at boot-time, e.g. list* or list*.*del_test");
-module_param_named(action, action_param, charp, 0);
-MODULE_PARM_DESC(action,
- "Changes KUnit executor behavior, valid values are:\n"
- "<none>: run the tests like normal\n"
- "'list' to list test names instead of running them.\n"
- "'list_attr' to list test names and attributes instead of running them.\n");
module_param_named(filter, filter_param, charp, 0);
MODULE_PARM_DESC(filter,
"Filter which KUnit test suites/tests run at boot-time using attributes, e.g. speed>slow");
__kunit_test_suites_init(suite_set->start, num_suites);
}
-#if IS_BUILTIN(CONFIG_KUNIT)
-
-static void kunit_exec_list_tests(struct kunit_suite_set *suite_set,
- bool include_attr)
+void kunit_exec_list_tests(struct kunit_suite_set *suite_set, bool include_attr)
{
struct kunit_suite * const *suites;
struct kunit_case *test_case;
}
}
+#if IS_BUILTIN(CONFIG_KUNIT)
+
int kunit_run_all_tests(void)
{
struct kunit_suite_set suite_set = {
struct kunit_suite_set suite_set = {
mod->kunit_suites, mod->kunit_suites + mod->num_kunit_suites,
};
-
- kunit_exec_run_tests(&suite_set, false);
+ const char *action = kunit_action();
+
+ if (!action)
+ kunit_exec_run_tests(&suite_set, false);
+ else if (!strcmp(action, "list"))
+ kunit_exec_list_tests(&suite_set, false);
+ else if (!strcmp(action, "list_attr"))
+ kunit_exec_list_tests(&suite_set, true);
+ else
+ pr_err("kunit: unknown action '%s'\n", action);
}
static void kunit_module_exit(struct module *mod)
{
- __kunit_test_suites_exit(mod->kunit_suites, mod->num_kunit_suites);
+ const char *action = kunit_action();
+
+ if (!action)
+ __kunit_test_suites_exit(mod->kunit_suites,
+ mod->num_kunit_suites);
}
static int kunit_module_notify(struct notifier_block *nb, unsigned long val,