Skip to content

Commit c6a2b75

Browse files
gautshensuperm1
authored andcommitted
amd-pstate-ut: Add module parameter to select testcases
Currently when amd-pstate-ut test module is loaded, it runs all the tests from amd_pstate_ut_cases[] array. Add a module parameter named "test_list" that accepts a comma-delimited list of test names, allowing users to run a selected subset of tests. When the parameter is omitted or empty, all tests are run as before. Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
1 parent 30c63f7 commit c6a2b75

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

drivers/cpufreq/amd-pstate-ut.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535

3636
#include "amd-pstate.h"
3737

38+
static char *test_list;
39+
module_param(test_list, charp, 0444);
40+
MODULE_PARM_DESC(test_list,
41+
"Comma-delimited list of tests to run (empty means run all tests)");
3842

3943
struct amd_pstate_ut_struct {
4044
const char *name;
@@ -58,6 +62,25 @@ static struct amd_pstate_ut_struct amd_pstate_ut_cases[] = {
5862
{"amd_pstate_ut_check_driver", amd_pstate_ut_check_driver }
5963
};
6064

65+
static bool test_in_list(const char *list, const char *name)
66+
{
67+
size_t name_len = strlen(name);
68+
const char *p = list;
69+
70+
while (*p) {
71+
const char *sep = strchr(p, ',');
72+
size_t token_len = sep ? sep - p : strlen(p);
73+
74+
if (token_len == name_len && !strncmp(p, name, token_len))
75+
return true;
76+
if (!sep)
77+
break;
78+
p = sep + 1;
79+
}
80+
81+
return false;
82+
}
83+
6184
static bool get_shared_mem(void)
6285
{
6386
bool result = false;
@@ -275,7 +298,13 @@ static int __init amd_pstate_ut_init(void)
275298
u32 i = 0, arr_size = ARRAY_SIZE(amd_pstate_ut_cases);
276299

277300
for (i = 0; i < arr_size; i++) {
278-
int ret = amd_pstate_ut_cases[i].func(i);
301+
int ret;
302+
303+
if (test_list && *test_list &&
304+
!test_in_list(test_list, amd_pstate_ut_cases[i].name))
305+
continue;
306+
307+
ret = amd_pstate_ut_cases[i].func(i);
279308

280309
if (ret)
281310
pr_err("%-4d %-20s\t fail: %d!\n", i+1, amd_pstate_ut_cases[i].name, ret);

0 commit comments

Comments
 (0)