Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 test/litest.c | 62 +++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index c0b515b..d581018 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -456,12 +456,6 @@ struct libinput_interface interface = {
        .close_restricted = close_restricted,
 };
 
-static const struct option opts[] = {
-       { "list", 0, 0, 'l' },
-       { "verbose", 0, 0, 'v' },
-       { 0, 0, 0, 0}
-};
-
 static int
 litest_run(int argc, char **argv)
 {
@@ -482,27 +476,6 @@ litest_run(int argc, char **argv)
                        srunner_add_suite(sr, s->suite);
        }
 
-       while(1) {
-               int c;
-               int option_index = 0;
-
-               c = getopt_long(argc, argv, "", opts, &option_index);
-               if (c == -1)
-                       break;
-               switch(c) {
-                       case 'l':
-                               litest_list_tests(&all_tests);
-                               return 0;
-                       case 'v':
-                               verbose = 1;
-                               break;
-                       default:
-                               fprintf(stderr, "usage: %s [--list]\n", 
argv[0]);
-                               return 1;
-
-               }
-       }
-
        if (getenv("LITEST_VERBOSE"))
                verbose = 1;
 
@@ -1887,9 +1860,44 @@ litest_semi_mt_touch_up(struct litest_device *d,
        litest_event(d, EV_SYN, SYN_REPORT, 0);
 }
 
+static int
+litest_parse_argv(int argc, char **argv)
+{
+       static const struct option opts[] = {
+               { "list", 0, 0, 'l' },
+               { "verbose", 0, 0, 'v' },
+               { 0, 0, 0, 0}
+       };
+
+       while(1) {
+               int c;
+               int option_index = 0;
+
+               c = getopt_long(argc, argv, "", opts, &option_index);
+               if (c == -1)
+                       break;
+               switch(c) {
+               case 'l':
+                       litest_list_tests(&all_tests);
+                       exit(0);
+               case 'v':
+                       verbose = 1;
+                       break;
+               default:
+                       fprintf(stderr, "usage: %s [--list]\n", argv[0]);
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
 int
 main(int argc, char **argv)
 {
+       if (litest_parse_argv(argc, argv) != 0)
+               return EXIT_FAILURE;
+
        litest_setup_tests();
 
        return litest_run(argc, argv);
-- 
2.3.5

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to