diff mbox series

[liburing,6/6] tests: correctly exit with failure in a looped test

Message ID 20220706034059.2817423-7-eschwartz93@gmail.com (mailing list archive)
State New
Headers show
Series More wor on updating exit codes to use | expand

Commit Message

Eli Schwartz July 6, 2022, 3:40 a.m. UTC
A common test pattern in this project is to test a couple related things
in a single test binary, and return failure on the first one that fails,
if any. Tracking subtest failures cannot be done well with simple exit()
statuses, though it can using something like TAP and parsing a generated
report.

However, this test simply set the value of `ret`, then proceeded to
another test. If the first failed and the second succeeded, we would log
a failure but then return a success.

Just return immediately on failure as is done elsewhere.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 test/multicqes_drain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/test/multicqes_drain.c b/test/multicqes_drain.c
index b7448ac..1423f92 100644
--- a/test/multicqes_drain.c
+++ b/test/multicqes_drain.c
@@ -373,7 +373,7 @@  int main(int argc, char *argv[])
 		ret = test_simple_drain(&ring);
 		if (ret) {
 			fprintf(stderr, "test_simple_drain failed\n");
-			break;
+			return T_EXIT_FAIL;
 		}
 	}
 
@@ -381,8 +381,8 @@  int main(int argc, char *argv[])
 		ret = test_generic_drain(&ring);
 		if (ret) {
 			fprintf(stderr, "test_generic_drain failed\n");
-			break;
+			return T_EXIT_FAIL;
 		}
 	}
-	return ret;
+	return T_EXIT_PASS;
 }