Add epoll_wait07 test
PATCH 1/1 Add epoll_wait07 test
This test verifies EPOLLONESHOT functionality.
--- .../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
testcases/kernel/syscalls/epoll_wait/.gitignore +1 -0
@@ -4,3 +4,4 @@ epoll_wait03 epoll_wait04 epoll_wait05 epoll_wait06 +epoll_wait07
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +86 -0
86 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 25 lines · Andrea Cervesato via ltp
This test verifies EPOLLONESHOT functionality.
Signed-off-by Andrea Cervesato <[email protected]>--- .../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.ctestcases/kernel/syscalls/epoll_wait/.gitignore +1
-0@@ -4,3 +4,4 @@ epoll_wait03 epoll_wait04 epoll_wait05 epoll_wait06 +epoll_wait07testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +1
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c line 11
Quoted 10 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +10
-0+/* +* Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* [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.
Quoted 38 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +38
-0+*/ + +#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
Quoted 1 line
instance");
Same as other test, please use the SAFE_EPOLL_* functions I just merged.
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
Quoted 43 lines · Richard Palethorpe
Hello,
Quoted 25 lines · Andrea Cervesato via ltp
This test verifies EPOLLONESHOT functionality.
Signed-off-by Andrea Cervesato <[email protected]>--- .../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.ctestcases/kernel/syscalls/epoll_wait/.gitignore +1
-0@@ -4,3 +4,4 @@ epoll_wait03 epoll_wait04 epoll_wait05 epoll_wait06 +epoll_wait07testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +1
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later testcases/kernel/syscalls/epoll_wait/epoll_wait07.c line 11
Quoted 10 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +10
-0+/* +* Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* [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.
Quoted 3 lines
So in this test you don't need to write to the pipe unless I am mistaken.
I see there's not a real difference between EPOLLIN or EPOLLOUT in this case. We can listen to EPOLLIN, write to pipe stdin buffer once and call epoll_wait two times. The result will be the same, since EPOLLIN event has been triggered only once. We have many options, I choose the one which forces two EPOLLOUT events, but the same can be done with EPOLLIN in this case.
To check, you can remove EPOLLONESHOT flag and run test without it.
Quoted 32 lines
Quoted 32 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +32
-0+*/ + +#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); +
Quoted 9 lines
Quoted 7 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait07.c new file +6
-0+ 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 epollinstance");
Same as other test, please use the SAFE_EPOLL_* functions I just merged.
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp