selftests/sched_ext: Improve runner error reporting for invalid arguments
Subsystems (2)
PATCH 1/1 selftests/sched_ext: Improve runner error reporting for invalid arguments
Report an error for 'sudo ./runner foo' (positional arg instead of -t) and for 'sudo ./runner -t foo' when the filter matches no tests.
Previously both cases produced no error output.
--- tools/testing/selftests/sched_ext/runner.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/testing/selftests/sched_ext/runner.c +15 -0
@@ -164,6 +164,12 @@ int main(int argc, char **argv) } } +if (optind < argc) { +fprintf (stderr,"Unexpected argument '%s'. Use -t to filter tests.\n" , + argv[optind]); +return 1 ; + } +for (i =0 ; i < __scx_num_tests; i++) {enum scx_test_status status;struct scx_test *test = &__scx_tests[i];
@@ -207,6 +213,15 @@ int main(int argc, char **argv)break ; } } + +if (filter && testnum ==0 && !exit_req) { +fprintf (stderr,"No tests matched filter '%s'\n" , filter); +fprintf (stderr,"Available tests (use -l to list):\n" ); +for (i =0 ; i < __scx_num_tests; i++) +fprintf (stderr," %s\n" , __scx_tests[i].name); +return 1 ; + } +printf ("\n\n=============================\n\n" );printf ("RESULTS:\n\n" );printf ("PASSED: %u\n" , passed);
Signature · 1 line
2.48.1
Tejun Heo
reviewerHello,
tools/testing/selftests/sched_ext/runner.c int main(int argc, char **argv) · line 217
Quoted 1 line · Cheng-Yang Chou
tools/testing/selftests/sched_ext/runner.c +1
-0+if (filter && testnum ==0 && !exit_req) {
testnum is also bumped by the print_skipped path, so with -s -t nomatch this check never fires.
Thanks.
--
tejun
PATCH v2 1/1 selftests/sched_ext: Improve runner error reporting for invalid arguments
Report an error for './runner foo' (positional arg instead of -t) and for './runner -t foo' when the filter matches no tests. Previously both cases produced no error output.
Pre-scan the test list before the main loop so the error is reported immediately, avoiding spurious SKIP output from '-s' when no tests match.
---
v2: Pre-scan before the main loop instead of checking testnum after,
as testnum is also bumped by the print_skipped path. (Tejun Heo)
tools/testing/selftests/sched_ext/runner.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tools/testing/selftests/sched_ext/runner.c +20 -0
@@ -164,6 +164,26 @@ int main(int argc, char **argv) } } +if (optind < argc) { +fprintf (stderr,"Unexpected argument '%s'. Use -t to filter tests.\n" , + argv[optind]); +return 1 ; + } + +if (filter) { +for (i =0 ; i < __scx_num_tests; i++) { +if (!should_skip_test (&__scx_tests[i], filter)) +break ; + } +if (i == __scx_num_tests) { +fprintf (stderr,"No tests matched filter '%s'\n" , filter); +fprintf (stderr,"Available tests (use -l to list):\n" ); +for (i =0 ; i < __scx_num_tests; i++) +fprintf (stderr," %s\n" , __scx_tests[i].name); +return 1 ; + } + } +for (i =0 ; i < __scx_num_tests; i++) {enum scx_test_status status;struct scx_test *test = &__scx_tests[i];
Signature · 1 line
2.48.1
Hello,
Quoted 3 lines · Cheng-Yang Chou
Report an error for './runner foo' (positional arg instead of -t) and for './runner -t foo' when the filter matches no tests. Previously both cases produced no error output.
Applied to sched_ext/for-7.1.
Thanks.
--
tejun