]> granicus.if.org Git - libevent/commitdiff
tinytest: fix parsing --timeout argument
authorAzat Khuzhin <azat@libevent.org>
Sun, 24 Mar 2019 17:36:16 +0000 (20:36 +0300)
committerAzat Khuzhin <azat@libevent.org>
Sun, 24 Mar 2019 17:39:20 +0000 (20:39 +0300)
Fixes: 15b2f41d ("tinytest: implement per-test timeout (via alarm() under !win32 only)")
test/tinytest.c

index 1588e89a27d522162fc83301fc9e24df4aec71b1..a94fb9d4832d632724548b3facdb76e188f2cae5 100644 (file)
@@ -339,7 +339,7 @@ tinytest_set_flag_(struct testgroup_t *groups, const char *arg, int set, unsigne
 static void
 usage(struct testgroup_t *groups, int list_groups)
 {
-       puts("Options are: [--verbose|--quiet|--terse] [--no-fork]");
+       puts("Options are: [--verbose|--quiet|--terse] [--no-fork] [--timeout <sec>]");
        puts("  Specify tests by name, or using a prefix ending with '..'");
        puts("  To skip a test, prefix its name with a colon.");
        puts("  To enable a disabled test, prefix its name with a plus.");
@@ -437,7 +437,8 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
                        } else if (!strcmp(v[i], "--list-tests")) {
                                usage(groups, 1);
                        } else if (!strcmp(v[i], "--timeout")) {
-                               if (i < c) {
+                               ++i;
+                               if (i >= c) {
                                        fprintf(stderr, "--timeout requires argument\n");
                                        return -1;
                                }