summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/libevent/libevent/0004-test-retriable-tests-are-marked-failed-only-when-all-a.patch
blob: 26b707ad316128228af02cf067cd44464ab3e67a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From 36ebd92fa53c0097f1e2f9ec5aa5b5c6ec1b411d Mon Sep 17 00:00:00 2001
From: Thomas Perrot <thomas.perrot@bootlin.com>
Date: Wed, 29 Sep 2021 13:50:35 +0200
Subject: [PATCH] test: retriable tests are marked failed only when all
 attempts have failed

Fixes: #1193

Upstream-Status: Backport [https://github.com/libevent/libevent/commit/3daebf308a01b4b2d3fb867be3d6631f7b5a2dbb]

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
---
 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 85dfe74a720e..bf2882418eb6 100644
--- a/test/tinytest.c
+++ b/test/tinytest.c
@@ -310,7 +310,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;
 
@@ -348,7 +349,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);
 	}
 
@@ -525,22 +526,20 @@ 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 test_attempts = (testcase->flags & TT_RETRIABLE) ? 3: 1;
 			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, test_attempts);
 
 				if (test_ret_err == OK)
 					break;
-				if (!(testcase->flags & TT_RETRIABLE))
+				if (!--test_attempts)
 					break;
 				printf("\n  [RETRYING %s (%i)]\n", testcase->name, test_attempts);
-				if (!test_attempts--)
-					break;
 			}
 
 			switch (test_ret_err) {
diff --git a/test/tinytest.h b/test/tinytest.h
index d321dd467542..c276b5339331 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.31.1