Re: [PATCH v3 08/12] amd-pstate-ut: Add ability to run a single testcase

From: Mario Limonciello (AMD) (kernel.org)

Date: Mon Mar 23 2026 - 16:28:26 EST




On 3/20/2026 9:43 AM, Gautham R. Shenoy wrote:
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 "run_only" that allows users to run a
single test from the array by specifying the test name string.

Signed-off-by: Gautham R. Shenoy <gautham.shenoy@xxxxxxx>
---
drivers/cpufreq/amd-pstate-ut.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
index 447b9aa5ce40..35e453a49c0f 100644
--- a/drivers/cpufreq/amd-pstate-ut.c
+++ b/drivers/cpufreq/amd-pstate-ut.c
@@ -35,6 +35,10 @@
#include "amd-pstate.h"
+static char *run_only;
+module_param(run_only, charp, 0444);
+MODULE_PARM_DESC(run_only,
+ "Run only the named test case (default: run all)");

This default shows the end effect; but it doesn't make sense for this parameter IMO.

How about instead if you had a semicolon delimitted list and then defaulted an empty list to mean all tests? Something like this:

static char *test_list;
module_param(test_list, charp, 0444)
MODULE_PARM_DESC(test_list,
"Semicolon delimitted list of tests to run (empty means run all tests)");

struct amd_pstate_ut_struct {
const char *name;
@@ -275,7 +279,12 @@ static int __init amd_pstate_ut_init(void)
u32 i = 0, arr_size = ARRAY_SIZE(amd_pstate_ut_cases);
for (i = 0; i < arr_size; i++) {
- int ret = amd_pstate_ut_cases[i].func(i);
+ int ret;
+
+ if (run_only && strcmp(run_only, amd_pstate_ut_cases[i].name))
+ continue;
+
+ ret = amd_pstate_ut_cases[i].func(i);

If you take my suggestion then you would split this on semicolon or end of string and then allow matching multiple.

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