Skip to contentSkip to conversation

test/ringbuf-read: Delete `.ringbuf-read.%d` before exit

PATCH Applied Ammar Faizi 3 participants 3 messages Sep 5, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 test/ringbuf-read: Delete `.ringbuf-read.%d` before exit

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]>
---
 test/ringbuf-read.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
test/ringbuf-read.c +12 -7
index 673f2de..8616a49 100644
@@ -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

Signature · 1 line
Ammar Faizi
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Ammar Faizi

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
Quoted 8 lines

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]>

tq

-- Viro

maintainer Applied
#2 lore raw
In reply to Ammar Faizi
Quoted 4 lines · Ammar Faizi

From: Ammar Faizi <[email protected]>

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

Quoted 8 lines

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

[...]

Applied, thanks!

[1/1] test/ringbuf-read: Delete .ringbuf-read.%d before exit

      commit: 0535620c15e1133f9c19aefe9e928e0607e6c2b2

Best regards,

Signature · 1 line
Jens Axboe