Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Gautham R. Shenoy and committed by
Mario Limonciello (AMD)
c6a2b750 30c63f72

+30 -1
+30 -1
drivers/cpufreq/amd-pstate-ut.c
··· 35 35 36 36 #include "amd-pstate.h" 37 37 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)"); 38 42 39 43 struct amd_pstate_ut_struct { 40 44 const char *name; ··· 61 57 {"amd_pstate_ut_check_freq", amd_pstate_ut_check_freq }, 62 58 {"amd_pstate_ut_check_driver", amd_pstate_ut_check_driver } 63 59 }; 60 + 61 + static bool test_in_list(const char *list, const char *name) 62 + { 63 + size_t name_len = strlen(name); 64 + const char *p = list; 65 + 66 + while (*p) { 67 + const char *sep = strchr(p, ','); 68 + size_t token_len = sep ? sep - p : strlen(p); 69 + 70 + if (token_len == name_len && !strncmp(p, name, token_len)) 71 + return true; 72 + if (!sep) 73 + break; 74 + p = sep + 1; 75 + } 76 + 77 + return false; 78 + } 64 79 65 80 static bool get_shared_mem(void) 66 81 { ··· 298 275 u32 i = 0, arr_size = ARRAY_SIZE(amd_pstate_ut_cases); 299 276 300 277 for (i = 0; i < arr_size; i++) { 301 - int ret = amd_pstate_ut_cases[i].func(i); 278 + int ret; 279 + 280 + if (test_list && *test_list && 281 + !test_in_list(test_list, amd_pstate_ut_cases[i].name)) 282 + continue; 283 + 284 + ret = amd_pstate_ut_cases[i].func(i); 302 285 303 286 if (ret) 304 287 pr_err("%-4d %-20s\t fail: %d!\n", i+1, amd_pstate_ut_cases[i].name, ret);