public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	Pavel Begunkov <[email protected]>,
	io-uring Mailing List <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>,
	Kanna Scarlet <[email protected]>,
	Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH liburing v2] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit
Date: Mon,  5 Sep 2022 16:33:17 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

From: Ammar Faizi <[email protected]>

Running test/ringbuf-read.t leaves untracked files in git status:

  Untracked files:
    (use "git add <file>..." to include in what will be committed)
          .ringbuf-read.163521
          .ringbuf-read.163564
          .ringbuf-read.163605
          .ringbuf-read.163648

Make sure we unlink it properly. While in there, fix the exit code,
use T_EXIT_*.

v2:
  - Use T_EXIT_* for exit code (comment from Alviro).

Cc: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 test/ringbuf-read.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/test/ringbuf-read.c b/test/ringbuf-read.c
index 673f2de..8616a49 100644
--- a/test/ringbuf-read.c
+++ b/test/ringbuf-read.c
@@ -133,63 +133,68 @@ static int test(const char *filename, int dio, int async)
 
 int main(int argc, char *argv[])
 {
 	char buf[BUF_SIZE];
 	char fname[80];
 	int ret, fd, i, do_unlink;
 
 	if (argc > 1) {
 		strcpy(fname, argv[1]);
 		do_unlink = 0;
 	} else {
 		sprintf(fname, ".ringbuf-read.%d", getpid());
 		t_create_file(fname, FSIZE);
 		do_unlink = 1;
 	}
 
 	fd = open(fname, O_WRONLY);
 	if (fd < 0) {
 		perror("open");
 		goto err;
 	}
 	for (i = 0; i < NR_BUFS; i++) {
 		memset(buf, i + 1, BUF_SIZE);
 		ret = write(fd, buf, BUF_SIZE);
 		if (ret != BUF_SIZE) {
 			fprintf(stderr, "bad file prep write\n");
+			close(fd);
 			goto err;
 		}
 	}
 	close(fd);
 
 	ret = test(fname, 1, 0);
 	if (ret) {
 		fprintf(stderr, "dio test failed\n");
-		return ret;
+		goto err;
 	}
 	if (no_buf_ring)
-		return 0;
+		goto pass;
 
 	ret = test(fname, 0, 0);
 	if (ret) {
 		fprintf(stderr, "buffered test failed\n");
-		return ret;
+		goto err;
 	}
 
 	ret = test(fname, 1, 1);
 	if (ret) {
 		fprintf(stderr, "dio async test failed\n");
-		return ret;
+		goto err;
 	}
 
 	ret = test(fname, 0, 1);
 	if (ret) {
 		fprintf(stderr, "buffered async test failed\n");
-		return ret;
+		goto err;
 	}
 
-	return 0;
+pass:
+	ret = T_EXIT_PASS;
+	goto out;
 err:
+	ret = T_EXIT_FAIL;
+out:
 	if (do_unlink)
 		unlink(fname);
-	return 1;
+	return ret;
 }

base-commit: 3bd7d6b27e6b7d7950bba1491bc9c385378fe4dd
-- 
Ammar Faizi


             reply	other threads:[~2022-09-05  9:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05  9:33 Ammar Faizi [this message]
2022-09-05  9:52 ` [PATCH liburing v2] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit Alviro Iskandar Setiawan
2022-09-05 17:42 ` 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] \
    [email protected] \
    [email protected] \
    [email protected] \
    [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