]> granicus.if.org Git - libevent/commitdiff
test: retriable tests are marked failed only when all attempts have failed
authorThomas Perrot <thomas.perrot@bootlin.com>
Wed, 29 Sep 2021 11:50:35 +0000 (13:50 +0200)
committerAzat Khuzhin <azat@libevent.org>
Sat, 2 Oct 2021 07:40:26 +0000 (10:40 +0300)
Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
test/tinytest.c
test/tinytest.h

index 76b2f02e461462d1ae9c2b703543c1fd081ed213..3bc7f9f653c3aa7ad536729117759865ccab4b52 100644 (file)
@@ -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) {
index d321dd4675423a778f2e3d836f95dd70bd8d9804..c276b5339331e3718458d96b1a3ff3b5d5755cc4 100644 (file)
@@ -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);