From: Richard Palethorpe <rpalethorpe@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: mszeredi@redhat.com, brauner@kernel.org, Jan Kara <jack@suse.cz>,
Matthew Wilcox <willy@infradead.org>,
viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/4] syscalls: readahead01: Make use of tst_fd
Date: Tue, 24 Oct 2023 10:31:07 +0100 [thread overview]
Message-ID: <87bkcouzqo.fsf@suse.de> (raw)
In-Reply-To: <20231016123320.9865-3-chrubis@suse.cz>
Hello,
Cyril Hrubis <chrubis@suse.cz> writes:
> TODO:
> - readahead() on /proc/self/maps seems to succeed
> - readahead() on pipe write end, O_PATH file and open_tree() fd returns EBADFD
>
> Are these to be expected?
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> .../kernel/syscalls/readahead/readahead01.c | 54 ++++++++++---------
> 1 file changed, 29 insertions(+), 25 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c
> index bdef7945d..6dd5086e5 100644
> --- a/testcases/kernel/syscalls/readahead/readahead01.c
> +++ b/testcases/kernel/syscalls/readahead/readahead01.c
> @@ -30,43 +30,47 @@
>
> static void test_bad_fd(void)
> {
> - char tempname[PATH_MAX] = "readahead01_XXXXXX";
> - int fd;
> + int fd[2];
> +
> + TST_EXP_FAIL(readahead(-1, 0, getpagesize()), EBADF,
> + "readahead() with fd = -1");
>
> - tst_res(TINFO, "%s -1", __func__);
> - TST_EXP_FAIL(readahead(-1, 0, getpagesize()), EBADF);
> + SAFE_PIPE(fd);
> + SAFE_CLOSE(fd[0]);
> + SAFE_CLOSE(fd[1]);
Would it make more sense to just close one of the ends?
Or to open a file with write only?
I wonder whether we still need test_bad_fd at all? Perhaps all the cases
should be integrated into TST_FD_FOREACH?
The rest looks good.
>
> - tst_res(TINFO, "%s O_WRONLY", __func__);
> - fd = mkstemp(tempname);
> - if (fd == -1)
> - tst_res(TFAIL | TERRNO, "mkstemp failed");
> - SAFE_CLOSE(fd);
> - fd = SAFE_OPEN(tempname, O_WRONLY);
> - TST_EXP_FAIL(readahead(fd, 0, getpagesize()), EBADF);
> - SAFE_CLOSE(fd);
> - unlink(tempname);
> + TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EBADF,
> + "readahead() with invalid fd");
> }
>
> -static void test_invalid_fd(void)
> +static void test_invalid_fd(struct tst_fd *fd)
> {
> - int fd[2];
> + int exp_errno = EINVAL;
>
> - tst_res(TINFO, "%s pipe", __func__);
> - SAFE_PIPE(fd);
> - TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EINVAL);
> - SAFE_CLOSE(fd[0]);
> - SAFE_CLOSE(fd[1]);
> + switch (fd->type) {
> + /* These two succeed */
> + case TST_FD_FILE:
> + case TST_FD_MEMFD:
> + return;
> + case TST_FD_PIPE_WRITE:
> + case TST_FD_OPEN_TREE:
> + case TST_FD_PATH:
> + exp_errno = EBADF;
> + break;
> + default:
> + break;
> + }
>
> - tst_res(TINFO, "%s socket", __func__);
> - fd[0] = SAFE_SOCKET(AF_INET, SOCK_STREAM, 0);
> - TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EINVAL);
> - SAFE_CLOSE(fd[0]);
> + TST_EXP_FAIL(readahead(fd->fd, 0, getpagesize()), exp_errno,
> + "readahead() on %s", tst_fd_desc(fd));
> }
>
> static void test_readahead(void)
> {
> test_bad_fd();
> - test_invalid_fd();
> +
> + TST_FD_FOREACH(fd)
> + test_invalid_fd(&fd);
> }
>
> static void setup(void)
> --
> 2.41.0
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
WARNING: multiple messages have this Message-ID (diff)
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: mszeredi@redhat.com, brauner@kernel.org, Jan Kara <jack@suse.cz>,
Matthew Wilcox <willy@infradead.org>,
viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/4] syscalls: readahead01: Make use of tst_fd
Date: Tue, 24 Oct 2023 10:31:07 +0100 [thread overview]
Message-ID: <87bkcouzqo.fsf@suse.de> (raw)
In-Reply-To: <20231016123320.9865-3-chrubis@suse.cz>
Hello,
Cyril Hrubis <chrubis@suse.cz> writes:
> TODO:
> - readahead() on /proc/self/maps seems to succeed
> - readahead() on pipe write end, O_PATH file and open_tree() fd returns EBADFD
>
> Are these to be expected?
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> .../kernel/syscalls/readahead/readahead01.c | 54 ++++++++++---------
> 1 file changed, 29 insertions(+), 25 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c
> index bdef7945d..6dd5086e5 100644
> --- a/testcases/kernel/syscalls/readahead/readahead01.c
> +++ b/testcases/kernel/syscalls/readahead/readahead01.c
> @@ -30,43 +30,47 @@
>
> static void test_bad_fd(void)
> {
> - char tempname[PATH_MAX] = "readahead01_XXXXXX";
> - int fd;
> + int fd[2];
> +
> + TST_EXP_FAIL(readahead(-1, 0, getpagesize()), EBADF,
> + "readahead() with fd = -1");
>
> - tst_res(TINFO, "%s -1", __func__);
> - TST_EXP_FAIL(readahead(-1, 0, getpagesize()), EBADF);
> + SAFE_PIPE(fd);
> + SAFE_CLOSE(fd[0]);
> + SAFE_CLOSE(fd[1]);
Would it make more sense to just close one of the ends?
Or to open a file with write only?
I wonder whether we still need test_bad_fd at all? Perhaps all the cases
should be integrated into TST_FD_FOREACH?
The rest looks good.
>
> - tst_res(TINFO, "%s O_WRONLY", __func__);
> - fd = mkstemp(tempname);
> - if (fd == -1)
> - tst_res(TFAIL | TERRNO, "mkstemp failed");
> - SAFE_CLOSE(fd);
> - fd = SAFE_OPEN(tempname, O_WRONLY);
> - TST_EXP_FAIL(readahead(fd, 0, getpagesize()), EBADF);
> - SAFE_CLOSE(fd);
> - unlink(tempname);
> + TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EBADF,
> + "readahead() with invalid fd");
> }
>
> -static void test_invalid_fd(void)
> +static void test_invalid_fd(struct tst_fd *fd)
> {
> - int fd[2];
> + int exp_errno = EINVAL;
>
> - tst_res(TINFO, "%s pipe", __func__);
> - SAFE_PIPE(fd);
> - TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EINVAL);
> - SAFE_CLOSE(fd[0]);
> - SAFE_CLOSE(fd[1]);
> + switch (fd->type) {
> + /* These two succeed */
> + case TST_FD_FILE:
> + case TST_FD_MEMFD:
> + return;
> + case TST_FD_PIPE_WRITE:
> + case TST_FD_OPEN_TREE:
> + case TST_FD_PATH:
> + exp_errno = EBADF;
> + break;
> + default:
> + break;
> + }
>
> - tst_res(TINFO, "%s socket", __func__);
> - fd[0] = SAFE_SOCKET(AF_INET, SOCK_STREAM, 0);
> - TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EINVAL);
> - SAFE_CLOSE(fd[0]);
> + TST_EXP_FAIL(readahead(fd->fd, 0, getpagesize()), exp_errno,
> + "readahead() on %s", tst_fd_desc(fd));
> }
>
> static void test_readahead(void)
> {
> test_bad_fd();
> - test_invalid_fd();
> +
> + TST_FD_FOREACH(fd)
> + test_invalid_fd(&fd);
> }
>
> static void setup(void)
> --
> 2.41.0
--
Thank you,
Richard.
next prev parent reply other threads:[~2023-10-24 9:38 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 12:33 [LTP] [PATCH v2 0/4] Add tst_fd iterator API Cyril Hrubis
2023-10-16 12:33 ` Cyril Hrubis
2023-10-16 12:33 ` [LTP] [PATCH v2 1/4] lib: Add tst_fd iterator Cyril Hrubis
2023-10-16 12:33 ` Cyril Hrubis
2023-10-24 9:39 ` [LTP] " Richard Palethorpe
2023-10-24 9:39 ` Richard Palethorpe
2024-01-05 0:42 ` Petr Vorel
2024-01-05 0:42 ` Petr Vorel
2024-01-15 12:19 ` Cyril Hrubis
2024-01-15 12:19 ` Cyril Hrubis
2024-01-15 22:52 ` Petr Vorel
2024-01-15 22:52 ` Petr Vorel
2023-10-16 12:33 ` [LTP] [PATCH v2 2/4] syscalls: readahead01: Make use of tst_fd Cyril Hrubis
2023-10-16 12:33 ` Cyril Hrubis
2023-10-24 9:31 ` Richard Palethorpe [this message]
2023-10-24 9:31 ` [LTP] " Richard Palethorpe
2023-10-16 12:33 ` [LTP] [PATCH v2 3/4] syscalls: accept: Add tst_fd test Cyril Hrubis
2023-10-16 12:33 ` Cyril Hrubis
2023-10-24 9:26 ` [LTP] " Richard Palethorpe
2023-10-24 9:26 ` Richard Palethorpe
2023-10-24 9:34 ` Cyril Hrubis
2023-10-24 9:34 ` Cyril Hrubis
2023-10-16 12:33 ` [LTP] [PATCH v2 4/4] syscalls: splice07: New splice tst_fd iterator test Cyril Hrubis
2023-10-16 12:33 ` Cyril Hrubis
2023-10-23 15:59 ` [LTP] " Richard Palethorpe
2023-10-23 15:59 ` Richard Palethorpe
2023-10-24 7:56 ` Cyril Hrubis
2023-10-24 7:56 ` Cyril Hrubis
2023-10-24 9:33 ` Jan Kara
2023-10-24 9:33 ` Jan Kara
2024-01-04 23:11 ` Petr Vorel
2024-01-04 23:11 ` Petr Vorel
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 \
--in-reply-to=87bkcouzqo.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=brauner@kernel.org \
--cc=chrubis@suse.cz \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=mszeredi@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.