1 From 36ebd92fa53c0097f1e2f9ec5aa5b5c6ec1b411d Mon Sep 17 00:00:00 2001
2 From: Thomas Perrot <thomas.perrot@bootlin.com>
3 Date: Wed, 29 Sep 2021 13:50:35 +0200
4 Subject: [PATCH] test: retriable tests are marked failed only when all
9 Upstream-status: Pending
11 Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
13 test/tinytest.c | 13 ++++++-------
14 test/tinytest.h | 2 +-
15 2 files changed, 7 insertions(+), 8 deletions(-)
17 diff --git a/test/tinytest.c b/test/tinytest.c
18 index 85dfe74a720e..bf2882418eb6 100644
21 @@ -310,7 +310,8 @@ testcase_run_forked_(const struct testgroup_t *group,
24 testcase_run_one(const struct testgroup_t *group,
25 - const struct testcase_t *testcase)
26 + const struct testcase_t *testcase,
27 + const int test_attempts)
31 @@ -348,7 +349,7 @@ testcase_run_one(const struct testgroup_t *group,
32 if (opt_verbosity>0 && !opt_forked)
36 + if (!opt_forked && (testcase->flags & TT_RETRIABLE) && !test_attempts)
37 printf("\n [%s FAILED]\n", testcase->name);
40 @@ -525,22 +526,20 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
41 struct testgroup_t *group = &groups[i];
42 for (j = 0; group->cases[j].name; ++j) {
43 struct testcase_t *testcase = &group->cases[j];
44 - int test_attempts = 3;
45 + int test_attempts = (testcase->flags & TT_RETRIABLE) ? 3: 1;
48 if (!(testcase->flags & TT_ENABLED_))
52 - test_ret_err = testcase_run_one(group, testcase);
53 + test_ret_err = testcase_run_one(group, testcase, test_attempts);
55 if (test_ret_err == OK)
57 - if (!(testcase->flags & TT_RETRIABLE))
58 + if (!--test_attempts)
60 printf("\n [RETRYING %s (%i)]\n", testcase->name, test_attempts);
61 - if (!test_attempts--)
65 switch (test_ret_err) {
66 diff --git a/test/tinytest.h b/test/tinytest.h
67 index d321dd467542..c276b5339331 100644
70 @@ -92,7 +92,7 @@ char *tinytest_format_hex_(const void *, unsigned long);
71 tinytest_set_flag_(groups, named, 1, TT_SKIP)
73 /** Run a single testcase in a single group. */
74 -int testcase_run_one(const struct testgroup_t *,const struct testcase_t *);
75 +int testcase_run_one(const struct testgroup_t *,const struct testcase_t *, const int test_attempts);
77 void tinytest_set_aliases(const struct testlist_alias_t *aliases);