Skip to content

Commit a73bca3

Browse files
Shizhao Chenhtejun
authored andcommitted
sched_ext: Add option -l in selftest runner to list all available tests
The selftest runner currently allows selecting tests via the -t option. This patch adds a new -l option that lists all available tests, providing users with an overview of the tests they can choose from. This enhancement is especially useful for scripting and automation purposes, making it easier to discover and run tests. Signed-off-by: Shizhao Chen <shichen@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 382d7ef commit a73bca3

File tree

1 file changed

+13
-2
lines changed
  • tools/testing/selftests/sched_ext

1 file changed

+13
-2
lines changed

tools/testing/selftests/sched_ext/runner.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ const char help_fmt[] =
2222
"\n"
2323
" -t TEST Only run tests whose name includes this string\n"
2424
" -s Include print output for skipped tests\n"
25+
" -l List all available tests\n"
2526
" -q Don't print the test descriptions during run\n"
2627
" -h Display this help and exit\n";
2728

2829
static volatile int exit_req;
29-
static bool quiet, print_skipped;
30+
static bool quiet, print_skipped, list;
3031

3132
#define MAX_SCX_TESTS 2048
3233

@@ -133,14 +134,17 @@ int main(int argc, char **argv)
133134

134135
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
135136

136-
while ((opt = getopt(argc, argv, "qst:h")) != -1) {
137+
while ((opt = getopt(argc, argv, "qslt:h")) != -1) {
137138
switch (opt) {
138139
case 'q':
139140
quiet = true;
140141
break;
141142
case 's':
142143
print_skipped = true;
143144
break;
145+
case 'l':
146+
list = true;
147+
break;
144148
case 't':
145149
filter = optarg;
146150
break;
@@ -154,6 +158,13 @@ int main(int argc, char **argv)
154158
enum scx_test_status status;
155159
struct scx_test *test = &__scx_tests[i];
156160

161+
if (list) {
162+
printf("%s\n", test->name);
163+
if (i == (__scx_num_tests - 1))
164+
return 0;
165+
continue;
166+
}
167+
157168
if (filter && should_skip_test(test, filter)) {
158169
/*
159170
* Printing the skipped tests and their preambles can

0 commit comments

Comments
 (0)