Skip to content

Commit 13c1383

Browse files
acmelnamhyung
authored andcommitted
perf test: Introduce --list-workloads to list the available workloads
Using it: $ perf test -w noplop No workload found: noplop $ $ perf test -w Error: switch `w' requires a value Usage: perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}] -w, --workload <work> workload to run for testing, use '--list-workloads' to list the available ones. $ $ perf test --list-workloads noploop thloop leafloop sqrtloop brstack datasym landlock $ Would be good at some point to have a description in 'struct test_workload'. Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Reviewed-by: James Clark <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Clark Williams <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 18b63d6 commit 13c1383

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tools/perf/tests/builtin-test.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,17 @@ static int perf_test__list(int argc, const char **argv)
505505
return 0;
506506
}
507507

508+
static int workloads__fprintf_list(FILE *fp)
509+
{
510+
struct test_workload *twl;
511+
int printed = 0;
512+
513+
workloads__for_each(twl)
514+
printed += fprintf(fp, "%s\n", twl->name);
515+
516+
return printed;
517+
}
518+
508519
static int run_workload(const char *work, int argc, const char **argv)
509520
{
510521
struct test_workload *twl;
@@ -535,6 +546,7 @@ int cmd_test(int argc, const char **argv)
535546
};
536547
const char *skip = NULL;
537548
const char *workload = NULL;
549+
bool list_workloads = false;
538550
const struct option test_options[] = {
539551
OPT_STRING('s', "skip", &skip, "tests", "tests to skip"),
540552
OPT_INCR('v', "verbose", &verbose,
@@ -544,7 +556,8 @@ int cmd_test(int argc, const char **argv)
544556
OPT_BOOLEAN('p', "parallel", &parallel, "Run the tests in parallel"),
545557
OPT_BOOLEAN('S', "sequential", &sequential,
546558
"Run the tests one after another rather than in parallel"),
547-
OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"),
559+
OPT_STRING('w', "workload", &workload, "work", "workload to run for testing, use '--list-workloads' to list the available ones."),
560+
OPT_BOOLEAN(0, "list-workloads", &list_workloads, "List the available builtin workloads to use with -w/--workload"),
548561
OPT_STRING(0, "dso", &dso_to_test, "dso", "dso to test"),
549562
OPT_STRING(0, "objdump", &test_objdump_path, "path",
550563
"objdump binary to use for disassembly and annotations"),
@@ -570,6 +583,11 @@ int cmd_test(int argc, const char **argv)
570583
if (workload)
571584
return run_workload(workload, argc, argv);
572585

586+
if (list_workloads) {
587+
workloads__fprintf_list(stdout);
588+
return 0;
589+
}
590+
573591
if (dont_fork)
574592
sequential = true;
575593
else if (parallel)

0 commit comments

Comments
 (0)