Commit 602bca69 authored by Peter Hutterer's avatar Peter Hutterer

test: fix --list for the tests

The argument worked, but the test list was empty since b2fd428f.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 8bb67c25
...@@ -696,20 +696,6 @@ is_debugger_attached(void) ...@@ -696,20 +696,6 @@ is_debugger_attached(void)
return rc; return rc;
} }
static void
litest_list_tests(struct list *tests)
{
struct suite *s;
list_for_each(s, tests, node) {
struct test *t;
printf("%s:\n", s->name);
list_for_each(t, &s->tests, node) {
printf(" %s\n", t->name);
}
}
}
static void static void
litest_log_handler(struct libinput *libinput, litest_log_handler(struct libinput *libinput,
enum libinput_log_priority pri, enum libinput_log_priority pri,
...@@ -2155,7 +2141,13 @@ litest_semi_mt_touch_up(struct litest_device *d, ...@@ -2155,7 +2141,13 @@ litest_semi_mt_touch_up(struct litest_device *d,
litest_event(d, EV_SYN, SYN_REPORT, 0); litest_event(d, EV_SYN, SYN_REPORT, 0);
} }
static inline int enum litest_mode {
LITEST_MODE_ERROR,
LITEST_MODE_TEST,
LITEST_MODE_LIST,
};
static inline enum litest_mode
litest_parse_argv(int argc, char **argv) litest_parse_argv(int argc, char **argv)
{ {
enum { enum {
...@@ -2192,31 +2184,52 @@ litest_parse_argv(int argc, char **argv) ...@@ -2192,31 +2184,52 @@ litest_parse_argv(int argc, char **argv)
filter_group = optarg; filter_group = optarg;
break; break;
case OPT_LIST: case OPT_LIST:
litest_list_tests(&all_tests); return LITEST_MODE_LIST;
exit(0);
case OPT_VERBOSE: case OPT_VERBOSE:
verbose = 1; verbose = 1;
break; break;
default: default:
fprintf(stderr, "usage: %s [--list]\n", argv[0]); fprintf(stderr, "usage: %s [--list]\n", argv[0]);
return 1; return LITEST_MODE_ERROR;
} }
} }
return 0; return LITEST_MODE_TEST;
} }
#ifndef LITEST_NO_MAIN #ifndef LITEST_NO_MAIN
static void
litest_list_tests(struct list *tests)
{
struct suite *s;
list_for_each(s, tests, node) {
struct test *t;
printf("%s:\n", s->name);
list_for_each(t, &s->tests, node) {
printf(" %s\n", t->name);
}
}
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
enum litest_mode mode;
list_init(&all_tests); list_init(&all_tests);
if (litest_parse_argv(argc, argv) != 0) mode = litest_parse_argv(argc, argv);
if (mode == LITEST_MODE_ERROR)
return EXIT_FAILURE; return EXIT_FAILURE;
litest_setup_tests(); litest_setup_tests();
if (mode == LITEST_MODE_LIST) {
litest_list_tests(&all_tests);
return EXIT_SUCCESS;
}
return litest_run(argc, argv); return litest_run(argc, argv);
} }
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment