diff options
author | Azat Khuzhin <azat@libevent.org> | 2021-09-19 13:15:02 +0300 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2021-09-19 13:47:32 +0300 |
commit | d7d6af7578f85a0c090e2ba4d4936c169db6a731 (patch) | |
tree | 5a4e1ca8355678bc6c702eee599efabf1e589c4f /test | |
parent | 7179ceddf0fdb18c8175c80cae651c1795c3e355 (diff) | |
download | libevent-d7d6af7578f85a0c090e2ba4d4936c169db6a731.tar.gz |
test: add --retries argument
Diffstat (limited to 'test')
-rw-r--r-- | test/tinytest.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/tinytest.c b/test/tinytest.c index 85dfe74a..5314c424 100644 --- a/test/tinytest.c +++ b/test/tinytest.c @@ -72,6 +72,7 @@ static int opt_forked = 0; /**< True iff we're called from inside a win32 fork*/ static int opt_nofork = 0; /**< Suppress calls to fork() for debugging. */ static int opt_verbosity = 1; /**< -==quiet,0==terse,1==normal,2==verbose */ static unsigned int opt_timeout = DEFAULT_TESTCASE_TIMEOUT; /**< Timeout for every test (using alarm()) */ +static unsigned int opt_retries = 3; /**< How much test with TT_RETRIABLE should be retried */ const char *verbosity_flag = ""; const struct testlist_alias_t *cfg_aliases=NULL; @@ -398,7 +399,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] [--timeout <sec>]"); + puts("Options are: [--verbose|--quiet|--terse] [--no-fork] [--timeout <sec>] [--retries <n>]"); 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."); @@ -502,6 +503,13 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups) return -1; } opt_timeout = (unsigned)atoi(v[i]); + } else if (!strcmp(v[i], "--retries")) { + ++i; + if (i >= c) { + fprintf(stderr, "--retries requires argument\n"); + return -1; + } + opt_retries = (unsigned)atoi(v[i]); } else { fprintf(stderr, "Unknown option %s. Try --help\n", v[i]); return -1; @@ -525,7 +533,7 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups) struct testgroup_t *group = &groups[i]; for (j = 0; group->cases[j].name; ++j) { struct testcase_t *testcase = &group->cases[j]; - int test_attempts = 3; + int attempts = opt_retries; int test_ret_err; if (!(testcase->flags & TT_ENABLED_)) @@ -538,8 +546,8 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups) break; if (!(testcase->flags & TT_RETRIABLE)) break; - printf("\n [RETRYING %s (%i)]\n", testcase->name, test_attempts); - if (!test_attempts--) + printf("\n [RETRYING %s (%i)]\n", testcase->name, attempts); + if (!attempts--) break; } |