]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext: Add option -l in selftest runner to list all available tests
authorShizhao Chen <shichen@redhat.com>
Tue, 7 Jan 2025 15:52:19 +0000 (23:52 +0800)
committerTejun Heo <tj@kernel.org>
Tue, 7 Jan 2025 19:42:30 +0000 (09:42 -1000)
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>
tools/testing/selftests/sched_ext/runner.c

index eab48c7ff30942d528c898c2b90c7cc8c9d0b74f..aa2d7d32dda9b6879e4393dc8ff80b0f8431ab7f 100644 (file)
@@ -22,11 +22,12 @@ const char help_fmt[] =
 "\n"
 "  -t TEST       Only run tests whose name includes this string\n"
 "  -s            Include print output for skipped tests\n"
+"  -l            List all available tests\n"
 "  -q            Don't print the test descriptions during run\n"
 "  -h            Display this help and exit\n";
 
 static volatile int exit_req;
-static bool quiet, print_skipped;
+static bool quiet, print_skipped, list;
 
 #define MAX_SCX_TESTS 2048
 
@@ -133,7 +134,7 @@ int main(int argc, char **argv)
 
        libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
 
-       while ((opt = getopt(argc, argv, "qst:h")) != -1) {
+       while ((opt = getopt(argc, argv, "qslt:h")) != -1) {
                switch (opt) {
                case 'q':
                        quiet = true;
@@ -141,6 +142,9 @@ int main(int argc, char **argv)
                case 's':
                        print_skipped = true;
                        break;
+               case 'l':
+                       list = true;
+                       break;
                case 't':
                        filter = optarg;
                        break;
@@ -154,6 +158,13 @@ int main(int argc, char **argv)
                enum scx_test_status status;
                struct scx_test *test = &__scx_tests[i];
 
+               if (list) {
+                       printf("%s\n", test->name);
+                       if (i == (__scx_num_tests - 1))
+                               return 0;
+                       continue;
+               }
+
                if (filter && should_skip_test(test, filter)) {
                        /*
                         * Printing the skipped tests and their preambles can