* [PATCH liburing v1] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit
@ 2022-09-05 7:12 Ammar Faizi
2022-09-05 8:42 ` Alviro Iskandar Setiawan
0 siblings, 1 reply; 3+ messages in thread
From: Ammar Faizi @ 2022-09-05 7:12 UTC (permalink / raw)
To: Jens Axboe
Cc: Ammar Faizi, Pavel Begunkov, io-uring Mailing List,
GNU/Weeb Mailing List, Kanna Scarlet, Muhammad Rizki
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.
Signed-off-by: Ammar Faizi <[email protected]>
---
test/ringbuf-read.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/test/ringbuf-read.c b/test/ringbuf-read.c
index 673f2de..060eb1d 100644
--- a/test/ringbuf-read.c
+++ b/test/ringbuf-read.c
@@ -133,63 +133,64 @@ 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;
+ ret = 1;
+ goto out;
}
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");
- goto err;
+ ret = 1;
+ close(fd);
+ goto out;
}
}
close(fd);
ret = test(fname, 1, 0);
if (ret) {
fprintf(stderr, "dio test failed\n");
- return ret;
+ goto out;
+ }
+ if (no_buf_ring) {
+ ret = 0;
+ goto out;
}
- if (no_buf_ring)
- return 0;
ret = test(fname, 0, 0);
if (ret) {
fprintf(stderr, "buffered test failed\n");
- return ret;
+ goto out;
}
ret = test(fname, 1, 1);
if (ret) {
fprintf(stderr, "dio async test failed\n");
- return ret;
+ goto out;
}
ret = test(fname, 0, 1);
- if (ret) {
+ if (ret)
fprintf(stderr, "buffered async test failed\n");
- return ret;
- }
-
- return 0;
-err:
+out:
if (do_unlink)
unlink(fname);
- return 1;
+ return ret;
}
base-commit: 3bd7d6b27e6b7d7950bba1491bc9c385378fe4dd
--
Ammar Faizi
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH liburing v1] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit
2022-09-05 7:12 [PATCH liburing v1] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit Ammar Faizi
@ 2022-09-05 8:42 ` Alviro Iskandar Setiawan
2022-09-05 8:45 ` Ammar Faizi
0 siblings, 1 reply; 3+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-09-05 8:42 UTC (permalink / raw)
To: Ammar Faizi
Cc: Jens Axboe, Pavel Begunkov, io-uring Mailing List,
GNU/Weeb Mailing List, Kanna Scarlet, Muhammad Rizki
On Mon, Sep 5, 2022 at 2:12 PM Ammar Faizi wrote:
> fd = open(fname, O_WRONLY);
> if (fd < 0) {
> perror("open");
> - goto err;
> + ret = 1;
> + goto out;
> }
> 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");
> - goto err;
> + ret = 1;
> + close(fd);
> + goto out;
> }
> }
should use T_EXIT_* for ret?
-- Viro
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH liburing v1] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit
2022-09-05 8:42 ` Alviro Iskandar Setiawan
@ 2022-09-05 8:45 ` Ammar Faizi
0 siblings, 0 replies; 3+ messages in thread
From: Ammar Faizi @ 2022-09-05 8:45 UTC (permalink / raw)
To: Alviro Iskandar Setiawan
Cc: Jens Axboe, Pavel Begunkov, io-uring Mailing List,
GNU/Weeb Mailing List, Kanna Scarlet, Muhammad Rizki
On 9/5/22 3:42 PM, Alviro Iskandar Setiawan wrote:
> On Mon, Sep 5, 2022 at 2:12 PM Ammar Faizi wrote:
>> fd = open(fname, O_WRONLY);
>> if (fd < 0) {
>> perror("open");
>> - goto err;
>> + ret = 1;
>> + goto out;
>> }
>> 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");
>> - goto err;
>> + ret = 1;
>> + close(fd);
>> + goto out;
>> }
>> }
>
> should use T_EXIT_* for ret?
Yes, we should. I forgot, will send a v2.
--
Ammar Faizi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-05 8:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05 7:12 [PATCH liburing v1] test/ringbuf-read: Delete `.ringbuf-read.%d` before exit Ammar Faizi
2022-09-05 8:42 ` Alviro Iskandar Setiawan
2022-09-05 8:45 ` Ammar Faizi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox