From: Peter Hutterer Date: Sun, 24 May 2015 22:56:53 +0000 (+1000) Subject: test: fix --list for the tests X-Git-Tag: upstream/0.15.0+92+gec468e8~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=602bca6977d7e97e49ae400a431c313639e631a2;p=platform%2Fupstream%2Flibinput.git test: fix --list for the tests The argument worked, but the test list was empty since b2fd428f96. Signed-off-by: Peter Hutterer --- diff --git a/test/litest.c b/test/litest.c index de53b67d..267487a7 100644 --- a/test/litest.c +++ b/test/litest.c @@ -696,20 +696,6 @@ is_debugger_attached(void) 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 litest_log_handler(struct libinput *libinput, enum libinput_log_priority pri, @@ -2155,7 +2141,13 @@ litest_semi_mt_touch_up(struct litest_device *d, 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) { enum { @@ -2192,31 +2184,52 @@ litest_parse_argv(int argc, char **argv) filter_group = optarg; break; case OPT_LIST: - litest_list_tests(&all_tests); - exit(0); + return LITEST_MODE_LIST; case OPT_VERBOSE: verbose = 1; break; default: fprintf(stderr, "usage: %s [--list]\n", argv[0]); - return 1; + return LITEST_MODE_ERROR; } } - return 0; + return LITEST_MODE_TEST; } #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 main(int argc, char **argv) { + enum litest_mode mode; + 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; litest_setup_tests(); + if (mode == LITEST_MODE_LIST) { + litest_list_tests(&all_tests); + return EXIT_SUCCESS; + } + return litest_run(argc, argv); } #endif