public inbox for [email protected]
 help / color / mirror / Atom feed
From: Eli Schwartz <[email protected]>
To: [email protected]
Subject: [PATCH liburing 6/6] tests: correctly exit with failure in a looped test
Date: Tue,  5 Jul 2022 23:40:58 -0400	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 test/multicqes_drain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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;
 }
-- 
2.35.1



  parent reply	other threads:[~2022-07-06  3:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06  3:40 [PATCH liburing 0/6] More wor on updating exit codes to use Eli Schwartz
2022-07-06  3:40 ` [PATCH liburing 1/6] tests: do not report an error message when return ret that might be a skip Eli Schwartz
2022-07-06  3:40 ` [PATCH liburing 2/6] tests: handle some skips that used a goto to enter cleanup Eli Schwartz
2022-07-06  3:40 ` [PATCH liburing 3/6] tests: more work on updating exit codes to use enum-based status reporting Eli Schwartz
2022-07-06  3:40 ` [PATCH liburing 4/6] tests: mention in a status message that this is a skip Eli Schwartz
2022-07-06  3:40 ` [PATCH liburing 5/6] tests: migrate a skip that used a goto to enter cleanup Eli Schwartz
2022-07-06  3:40 ` Eli Schwartz [this message]
2022-07-06 12:45 ` [PATCH liburing 0/6] More wor on updating exit codes to use Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox