From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V3 2/3] syscalls: select: Verify that data is available to read
Date: Wed, 14 Oct 2020 14:13:43 +0200 [thread overview]
Message-ID: <20201014121343.GD31816@yuki.lan> (raw)
In-Reply-To: <fb31dd18ad396ab602ba8957ee01a666f79ad9bb.1599558175.git.viresh.kumar@linaro.org>
Hi!
> select() returns a positive value on success if timeout hasn't happened,
> else returns 0. Check that and send some data to the write file
> descriptor for the same.
>
> Acked-by: Li Wang <liwang@redhat.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> testcases/kernel/syscalls/select/select01.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/select/select01.c b/testcases/kernel/syscalls/select/select01.c
> index 1213aa931251..c6b30aa67dd7 100644
> --- a/testcases/kernel/syscalls/select/select01.c
> +++ b/testcases/kernel/syscalls/select/select01.c
> @@ -25,25 +25,32 @@ static struct select_info {
> int *nfds;
> fd_set *readfds;
> fd_set *writefds;
> + int *writefd;
> char *desc;
> } tests[] = {
> - {&fd_reg, &readfds_reg, NULL, "with regular file"},
> - {&fds_pipe[1], &readfds_pipe, &writefds_pipe, "with system pipe"},
> - {&fd_npipe, &readfds_npipe, &writefds_npipe, "with named pipe (FIFO)"},
> + {&fd_reg, &readfds_reg, NULL, NULL, "with regular file"},
> + {&fds_pipe[1], &readfds_pipe, &writefds_pipe, &fds_pipe[1], "with system pipe"},
> + {&fd_npipe, &readfds_npipe, &writefds_npipe, &fd_npipe, "with named pipe (FIFO)"},
> };
>
> static void run(unsigned int n)
> {
> struct select_info *tc = &tests[n];
> struct timeval timeout;
> + char buf;
>
> timeout.tv_sec = 0;
> timeout.tv_usec = 100000;
>
> + if (tc->writefd)
> + SAFE_WRITE(0, *tc->writefd, &buf, sizeof(buf));
I'm not sure why we are writing data here. For both the pipe and fifo
the select() will return that we can write there, hence the return would
be non-zero regardless.
Also I would like to be more specific. E.g. expecting specific return
instead of just non-zero and also making sure the right bits are enabled
in the fd sets.
> TEST(do_select(*tc->nfds + 1, tc->readfds, tc->writefds, 0, &timeout));
>
> if (TST_RET == -1)
> tst_res(TFAIL | TTERRNO, "select() failed %s", tc->desc);
> + else if (!TST_RET)
> + tst_res(TFAIL, "select() timed out %s", tc->desc);
> else
> tst_res(TPASS, "select() passed %s", tc->desc);
> }
> --
> 2.25.0.rc1.19.g042ed3e048af
>
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2020-10-14 12:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 9:44 [LTP] [PATCH V3 1/3] syscalls: select: Merge few tests and migrate to new format Viresh Kumar
2020-09-08 9:44 ` [LTP] [PATCH V3 2/3] syscalls: select: Verify that data is available to read Viresh Kumar
2020-10-14 12:13 ` Cyril Hrubis [this message]
2020-10-19 10:10 ` Viresh Kumar
2020-10-20 13:06 ` Cyril Hrubis
2020-10-21 4:32 ` [LTP] [PATCH V4 " Viresh Kumar
2020-10-21 12:04 ` Cyril Hrubis
2020-10-22 4:54 ` Viresh Kumar
2020-10-22 10:13 ` Cyril Hrubis
2020-09-08 9:44 ` [LTP] [PATCH V3 3/3] syscalls: select: Rename select04.c to select02.c Viresh Kumar
2020-10-14 12:15 ` Cyril Hrubis
2020-10-19 11:37 ` Viresh Kumar
2020-10-20 13:06 ` Cyril Hrubis
2020-10-21 5:32 ` [LTP] [PATCH V2 4/4] syscalls: select: Add failure tests Viresh Kumar
2020-10-21 14:54 ` Cyril Hrubis
2020-10-06 7:59 ` [LTP] [PATCH V3 1/3] syscalls: select: Merge few tests and migrate to new format Viresh Kumar
2020-10-14 12:05 ` Cyril Hrubis
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=20201014121343.GD31816@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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;
as well as URLs for NNTP newsgroup(s).