From: Richard Palethorpe <rpalethorpe@suse.de>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Add epoll_wait07 test
Date: Thu, 20 Oct 2022 10:27:02 +0100 [thread overview]
Message-ID: <87h6zyvm7w.fsf@suse.de> (raw)
In-Reply-To: <20221010145243.3133-1-andrea.cervesato@suse.com>
Hello,
Andrea Cervesato via ltp <ltp@lists.linux.it> writes:
> This test verifies EPOLLONESHOT functionality.
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> .../kernel/syscalls/epoll_wait/.gitignore | 1 +
> .../kernel/syscalls/epoll_wait/epoll_wait07.c | 86 +++++++++++++++++++
> 2 files changed, 87 insertions(+)
> create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait07.c
>
> diff --git a/testcases/kernel/syscalls/epoll_wait/.gitignore b/testcases/kernel/syscalls/epoll_wait/.gitignore
> index 8c5ed7c5c..66ac18ae2 100644
> --- a/testcases/kernel/syscalls/epoll_wait/.gitignore
> +++ b/testcases/kernel/syscalls/epoll_wait/.gitignore
> @@ -4,3 +4,4 @@ epoll_wait03
> epoll_wait04
> epoll_wait05
> epoll_wait06
> +epoll_wait07
> diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait07.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait07.c
> new file mode 100644
> index 000000000..760ab6c10
> --- /dev/null
> +++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait07.c
> @@ -0,0 +1,86 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2022 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Verify that EPOLLONESHOT is correctly handled by epoll_wait.
> + * We open a channel, write on it multiple times and we verify that EPOLLOUT
> + * has been received only once.
Without EPOLLONESHOT or EPOLLET, EPOLLOUT will fire constantly on a pipe
who's buffer is not full. Writing to it will have no effect unless you
listen on the other end for EPOLLIN.
So in this test you don't need to write to the pipe unless I am
mistaken.
> + */
> +
> +#include <poll.h>
> +#include <sys/epoll.h>
> +#include "tst_test.h"
> +
> +#define WRITE_SIZE 2048
> +
> +static int fds[2];
> +static int epfd;
> +
> +static void cleanup(void)
> +{
> + if (epfd > 0)
> + SAFE_CLOSE(epfd);
> +
> + if (fds[0] > 0)
> + SAFE_CLOSE(fds[0]);
> +
> + if (fds[1] > 0)
> + SAFE_CLOSE(fds[1]);
> +}
> +
> +static void run(void)
> +{
> + int res;
> + char buff[WRITE_SIZE];
> + struct epoll_event evt_receive;
> + struct epoll_event evt_request;
> +
> + SAFE_PIPE(fds);
> +
> + evt_request.events = EPOLLOUT | EPOLLONESHOT;
> + evt_request.data.fd = fds[1];
> +
> + epfd = epoll_create(2);
> + if (epfd == -1)
> + tst_brk(TBROK | TERRNO, "fail to create epoll
> instance");
Same as other test, please use the SAFE_EPOLL_* functions I just merged.
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-10-20 10:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 14:52 [LTP] [PATCH v1] Add epoll_wait07 test Andrea Cervesato via ltp
2022-10-20 9:27 ` Richard Palethorpe [this message]
2022-10-28 8:43 ` Andrea Cervesato via ltp
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=87h6zyvm7w.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=andrea.cervesato@suse.com \
--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