From 3daebf308a01b4b2d3fb867be3d6631f7b5a2dbb Mon Sep 17 00:00:00 2001 From: Thomas Perrot Date: Wed, 29 Sep 2021 13:50:35 +0200 Subject: [PATCH] test: retriable tests are marked failed only when all attempts have failed Signed-off-by: Thomas Perrot --- test/tinytest.c | 13 ++++++------- test/tinytest.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/tinytest.c b/test/tinytest.c index 76b2f02e..3bc7f9f6 100644 --- a/test/tinytest.c +++ b/test/tinytest.c @@ -312,7 +312,8 @@ testcase_run_forked_(const struct testgroup_t *group, int testcase_run_one(const struct testgroup_t *group, - const struct testcase_t *testcase) + const struct testcase_t *testcase, + const int test_attempts) { enum outcome outcome; @@ -350,7 +351,7 @@ testcase_run_one(const struct testgroup_t *group, if (opt_verbosity>0 && !opt_forked) puts("SKIPPED"); } else { - if (!opt_forked) + if (!opt_forked && (testcase->flags & TT_RETRIABLE) && !test_attempts) printf("\n [%s FAILED]\n", testcase->name); } @@ -549,18 +550,18 @@ 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 attempts = opt_retries; + int attempts = (testcase->flags & TT_RETRIABLE) ? opt_retries : 0; int test_ret_err; if (!(testcase->flags & TT_ENABLED_)) continue; for (;;) { - test_ret_err = testcase_run_one(group, testcase); + test_ret_err = testcase_run_one(group, testcase, attempts); if (test_ret_err == OK) break; - if (!(testcase->flags & TT_RETRIABLE)) + if (!attempts--) break; printf("\n [RETRYING %s (attempts left %i, delay %i sec)]\n", testcase->name, attempts, opt_retries_delay); #ifdef _WIN32 @@ -568,8 +569,6 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups) #else sleep(opt_retries_delay); #endif - if (!attempts--) - break; } switch (test_ret_err) { diff --git a/test/tinytest.h b/test/tinytest.h index d321dd46..c276b533 100644 --- a/test/tinytest.h +++ b/test/tinytest.h @@ -92,7 +92,7 @@ char *tinytest_format_hex_(const void *, unsigned long); tinytest_set_flag_(groups, named, 1, TT_SKIP) /** Run a single testcase in a single group. */ -int testcase_run_one(const struct testgroup_t *,const struct testcase_t *); +int testcase_run_one(const struct testgroup_t *,const struct testcase_t *, const int test_attempts); void tinytest_set_aliases(const struct testlist_alias_t *aliases); -- 2.40.0