summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAzat Khuzhin <azat@libevent.org>2021-09-19 13:18:40 +0300
committerAzat Khuzhin <azat@libevent.org>2021-09-19 13:49:18 +0300
commit90846c30ff0313a3c81074ea8b8a1250195103cc (patch)
treed0f75ccb229053875335d348f11e53d02c86f613 /test
parentd7d6af7578f85a0c090e2ba4d4936c169db6a731 (diff)
downloadlibevent-90846c30ff0313a3c81074ea8b8a1250195103cc.tar.gz
test: add --retries-delay (and set to 1 second by default)
In attemp to address failures of dns/tcp_* tests under windows [1]. [1]: https://github.com/azat/libevent/runs/3644218468?check_suite_focus=true
Diffstat (limited to 'test')
-rw-r--r--test/tinytest.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/tinytest.c b/test/tinytest.c
index 5314c424..76b2f02e 100644
--- a/test/tinytest.c
+++ b/test/tinytest.c
@@ -73,6 +73,7 @@ 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 */
+static unsigned int opt_retries_delay = 1; /**< How much seconds to delay before retrying */
const char *verbosity_flag = "";
const struct testlist_alias_t *cfg_aliases=NULL;
@@ -399,7 +400,15 @@ 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>] [--retries <n>]");
+ puts("Options are:");
+ puts(" --verbose");
+ puts(" --quiet");
+ puts(" --terse");
+ puts(" --no-fork");
+ puts(" --timeout <sec>");
+ puts(" --retries <n>");
+ puts(" --retries-delay <n>");
+ puts("");
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.");
@@ -510,6 +519,13 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
return -1;
}
opt_retries = (unsigned)atoi(v[i]);
+ } else if (!strcmp(v[i], "--retries-delay")) {
+ ++i;
+ if (i >= c) {
+ fprintf(stderr, "--retries-delay requires argument\n");
+ return -1;
+ }
+ opt_retries_delay = (unsigned)atoi(v[i]);
} else {
fprintf(stderr, "Unknown option %s. Try --help\n", v[i]);
return -1;
@@ -546,7 +562,12 @@ 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, attempts);
+ printf("\n [RETRYING %s (attempts left %i, delay %i sec)]\n", testcase->name, attempts, opt_retries_delay);
+#ifdef _WIN32
+ Sleep(opt_retries_delay * 1000);
+#else
+ sleep(opt_retries_delay);
+#endif
if (!attempts--)
break;
}