Add more epoll tests
v2 cover Add more epoll tests
This patchset adds much more epoll tests, with that the coverage is mostly complete so that we can remove the old and ugly epoll-ltp test.
v2:
- fixed typos pointed out by ltp-agent
Cyril Hrubis (8):
syscalls: Add epoll_create03
syscalls: Add epoll_wait08
syscalls: Add epoll_wait09
syscalls: Add epoll_ctl06
syscalls: Add epoll_wait10
syscalls: Add epoll_wait11
syscalls: Add epoll_wait12
syscalls: Remove old epoll-ltp test
runtest/syscalls | 12 +- testcases/kernel/syscalls/epoll/.gitignore | 1 - testcases/kernel/syscalls/epoll/Makefile | 8 - testcases/kernel/syscalls/epoll/README.1ST | 38 - testcases/kernel/syscalls/epoll/epoll-ltp.c | 738 ------------------ .../kernel/syscalls/epoll_create/.gitignore | 1 + .../syscalls/epoll_create/epoll_create03.c | 72 ++ .../kernel/syscalls/epoll_ctl/.gitignore | 1 + .../kernel/syscalls/epoll_ctl/epoll_ctl06.c | 71 ++ .../kernel/syscalls/epoll_wait/.gitignore | 5 + .../kernel/syscalls/epoll_wait/epoll_wait08.c | 69 ++ .../kernel/syscalls/epoll_wait/epoll_wait09.c | 132 ++++ .../kernel/syscalls/epoll_wait/epoll_wait10.c | 107 +++ .../kernel/syscalls/epoll_wait/epoll_wait11.c | 94 +++ .../kernel/syscalls/epoll_wait/epoll_wait12.c | 112 +++ 15 files changed, 675 insertions(+), 786 deletions(-) delete mode 100644 testcases/kernel/syscalls/epoll/.gitignore delete mode 100644 testcases/kernel/syscalls/epoll/Makefile delete mode 100644 testcases/kernel/syscalls/epoll/README.1ST delete mode 100644 testcases/kernel/syscalls/epoll/epoll-ltp.c create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create03.c create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait08.c create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait09.c create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait10.c create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait11.c create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait12.c
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/8 syscalls: Add epoll_create03
Test that checks that we get EMFILE when limit on per-process file descriptors is hit.
--- runtest/syscalls | 2 + .../kernel/syscalls/epoll_create/.gitignore | 1 + .../syscalls/epoll_create/epoll_create03.c | 72 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create03.c
runtest/syscalls +2 -0
@@ -177,6 +177,8 @@ dup3_02 dup3_02 epoll_create01 epoll_create01 epoll_create02 epoll_create02 +epoll_create03 epoll_create03 + epoll_create1_01 epoll_create1_01 epoll_create1_02 epoll_create1_02 epoll01 epoll-ltp
testcases/kernel/syscalls/epoll_create/.gitignore +1 -0
@@ -1,2 +1,3 @@ epoll_create01 epoll_create02 +epoll_create03
testcases/kernel/syscalls/epoll_create/epoll_create03.c new file +72 -0
72 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/8] syscalls: Add epoll_create03
Hi Cyril,
LGTM, thanks!
testcases/kernel/syscalls/epoll_create/epoll_create03.c line 7
Quoted 3 lines
testcases/kernel/syscalls/epoll_create/epoll_create03.c new file +3
-0+ +/*\ +* Verify that epoll_create() fails with EMFILE when the per-process limit on
nit (please fix before merge):
:manpage:epoll_create(2)
to have link to the man page in the test catalog
https://man7.org/linux/man-pages/man2/epoll_create.2.html
https://github.com/linux-test-project/ltp-agent/pull/4
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] syscalls: Add epoll_create03
In reply to Cyril HrubisHi Cyril,
--- [PATCH 2/8] ---
Quoted 5 lines · Cyril Hrubis
syscalls: Add
epoll_wait08+ * - Create an epoll instance and register a socket fd for EPOLLIN.
+ * - Fork a child that waits for the parent to enterepoll_wait, then sends
+ * SIGUSR1 to interrupt it.
The algorithm comment is wrong on two counts. No fd is registered with the epoll instance — setup() only calls SAFE_EPOLL_CREATE1(). And it is the child that blocks in epoll_wait, not the parent; the parent sends SIGUSR1.
--- [PATCH 6/8] ---
Quoted 4 lines · Cyril Hrubis
syscalls: Add
epoll_wait11+ * - The child's
epoll_waitshould return with EPOLLHUP and the child reports
+ * the result via its exit code.
The child reports via tst_res(TPASS/TFAIL, ...) before exit(0), not via the exit code. Fix the comment accordingly.
---
Note:
Our agent completed the review of the patch. The full review can be found at: https://patchwork.ozlabs.org/project/ltp/list/?series=501188
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/8] syscalls: Add epoll_create03
In reply to Cyril Hrubis--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/8 syscalls: Add epoll_wait08
In reply to Cyril HrubisTests that epoll_wait() can be interrupted by a signal and returns EINTR.
--- runtest/syscalls | 3 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait08.c | 69 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait08.c
runtest/syscalls +3 -0
@@ -187,6 +187,7 @@ epoll_ctl02 epoll_ctl02 epoll_ctl03 epoll_ctl03 epoll_ctl04 epoll_ctl04 epoll_ctl05 epoll_ctl05 + epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03
@@ -194,6 +195,8 @@ epoll_wait04 epoll_wait04 epoll_wait05 epoll_wait05 epoll_wait06 epoll_wait06 epoll_wait07 epoll_wait07 +epoll_wait08 epoll_wait08 + epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02 epoll_pwait03 epoll_pwait03
testcases/kernel/syscalls/epoll_wait/.gitignore +1 -0
@@ -5,3 +5,4 @@ epoll_wait04 epoll_wait05 epoll_wait06 epoll_wait07 +epoll_wait08
testcases/kernel/syscalls/epoll_wait/epoll_wait08.c new file +69 -0
69 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/8] syscalls: Add epoll_wait08
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/8 syscalls: Add epoll_wait09
In reply to Cyril HrubisTest checks that events from recursive epoll are propagated correctly.
--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait09.c | 132 ++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait09.c
runtest/syscalls +1 -0
@@ -196,6 +196,7 @@ epoll_wait05 epoll_wait05 epoll_wait06 epoll_wait06 epoll_wait07 epoll_wait07 epoll_wait08 epoll_wait08 +epoll_wait09 epoll_wait09 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02
testcases/kernel/syscalls/epoll_wait/.gitignore +1 -0
@@ -6,3 +6,4 @@ epoll_wait05 epoll_wait06 epoll_wait07 epoll_wait08 +epoll_wait09
testcases/kernel/syscalls/epoll_wait/epoll_wait09.c new file +132 -0
132 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 3/8] syscalls: Add epoll_wait09
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/8 syscalls: Add epoll_ctl06
In reply to Cyril HrubisTest that iterates over different types of file descriptors, attempts to add them to epoll and expects either success or a failure based on the type of the file descriptor.
--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_ctl/.gitignore | 1 + .../kernel/syscalls/epoll_ctl/epoll_ctl06.c | 71 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
runtest/syscalls +1 -0
@@ -187,6 +187,7 @@ epoll_ctl02 epoll_ctl02 epoll_ctl03 epoll_ctl03 epoll_ctl04 epoll_ctl04 epoll_ctl05 epoll_ctl05 +epoll_ctl06 epoll_ctl06 epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02
testcases/kernel/syscalls/epoll_ctl/.gitignore +1 -0
@@ -3,3 +3,4 @@ epoll_ctl02 epoll_ctl03 epoll_ctl04 epoll_ctl05 +epoll_ctl06
testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c new file +71 -0
71 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 4/8] syscalls: Add epoll_ctl06
Quoted 6 lines · Cyril Hrubis
testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c new file +6
-0+static int exp_errno (enum tst_fd_type type) +{ +switch (type) { +case TST_FD_FILE : +case TST_FD_DIR : +case TST_FD_DEV_ZERO :
testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c line 38
Quoted 10 lines
testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c new file +9
-0+case TST_FD_PROC_MAPS : +case TST_FD_MEMFD : +case TST_FD_MEMFD_SECRET : +return EPERM ; +case TST_FD_PATH : +case TST_FD_OPEN_TREE : +case TST_FD_FSOPEN : +case TST_FD_FSPICK : +return EBADF ;
Looks like these two fs epoll verifying return EPERM:
epoll_ctl06.c:55: TFAIL: epoll_ctl() on fsopen expected EBADF: EPERM (1) epoll_ctl06.c:55: TFAIL: epoll_ctl() on fspick expected EBADF: EPERM (1)
--
Regards,
Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 5/8 syscalls: Add epoll_wait10
In reply to Cyril HrubisFunctional test for EPOLLPRI using /proc/mounts that produces POLLPRI when a filesystem is mounted/umounted.
--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait10.c | 107 ++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait10.c
runtest/syscalls +1 -0
@@ -198,6 +198,7 @@ epoll_wait06 epoll_wait06 epoll_wait07 epoll_wait07 epoll_wait08 epoll_wait08 epoll_wait09 epoll_wait09 +epoll_wait10 epoll_wait10 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02
testcases/kernel/syscalls/epoll_wait/.gitignore +1 -0
@@ -7,3 +7,4 @@ epoll_wait06 epoll_wait07 epoll_wait08 epoll_wait09 +epoll_wait10
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +107 -0
107 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 5/8] syscalls: Add epoll_wait10
Hi Cyril,
Quoted 85 lines
Functional test for EPOLLPRI using
/proc/mountsthat produces POLLPRI when a filesystem is mounted/umounted.Signed-off-by Cyril Hrubis <[email protected]>--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait10.c | 107 ++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait10.cruntest/syscalls +1
-0@@ -198,6 +198,7 @@ epoll_wait06 epoll_wait06 epoll_wait07 epoll_wait07 epoll_wait08 epoll_wait08 epoll_wait09 epoll_wait09 +epoll_wait10 epoll_wait10 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02testcases/kernel/syscalls/epoll_wait/.gitignore +1
-0@@ -7,3 +7,4 @@ epoll_wait06 epoll_wait07 epoll_wait08 epoll_wait09 +epoll_wait10testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +47
-0@@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2026 Cyril Hrubis <[email protected]> +*/ + +/*\ +* Verify that epoll_wait with EPOLLPRI detects changes to /proc/mounts. +* +* The kernel generates a poll notification (POLLPRI/EPOLLERR) on +* /proc/mounts whenever the mount namespace changes. This test verifies +* that epoll can observe these notifications. +* +* [Algorithm] +* +* - Open /proc/mounts and register it with an epoll instance for EPOLLPRI. +* - Fork a child that mounts and then unmounts a tmpfs filesystem, using +* checkpoints to synchronize with the parent. +* - After each mount namespace change the parent calls epoll_wait and verifies +* it returns an event. +* +* Needs root to call mount/umount. +*/ + +#include <sys/epoll.h> + +#include "tst_test.h" +#include "tst_epoll.h" + +#define MNTPOINT "mnt_epoll" + +static int efd =-1 , mnt_fd =-1 ; + +static void setup (void ) +{ +SAFE_MKDIR (MNTPOINT ,0777 ); + + mnt_fd =SAFE_OPEN ("/proc/mounts" ,O_RDONLY ); + + efd =SAFE_EPOLL_CREATE1 (0 ); + +struct epoll_event ev = { + .events =EPOLLPRI , + .data.fd = mnt_fd, + }; + +SAFE_EPOLL_CTL (efd,EPOLL_CTL_ADD , mnt_fd, &ev); +}
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c line 57
Quoted 10 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +10
-0+ +static void check_epoll_event (const char *desc) +{ +struct epoll_event ret_ev; +char buf[1024 ]; + +TEST (epoll_wait (efd, &ret_ev,1 ,1000 )); +if (TST_RET <1 ) { +tst_res (TFAIL |TTERRNO , +"epoll_wait() after %s returned %li" , desc,TST_RET );
return; here.
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c line 65
Quoted 8 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +8
-0+ }else if (!(ret_ev.events & (EPOLLPRI |EPOLLERR ))) { +tst_res (TFAIL , +"after %s: events %x, expected EPOLLPRI or EPOLLERR" , + desc, ret_ev.events); + }else { +tst_res (TPASS , +"epoll_wait() reported event after %s" , desc); + }
And here I would use TST_EXP_* instead. But feel free to ignore.
Quoted 48 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +42
-0+ +/* Re-read /proc/self/mounts to clear the notification */ +SAFE_LSEEK (mnt_fd,0 ,SEEK_SET ); +while (SAFE_READ (0 , mnt_fd, buf,sizeof (buf)) >0 ) + ; +} + +static void run (void ) +{ +if (!SAFE_FORK ()) { +SAFE_MOUNT ("none" ,MNTPOINT ,"tmpfs" ,0 ,NULL ); +TST_CHECKPOINT_WAKE_AND_WAIT (0 ); +SAFE_UMOUNT (MNTPOINT ); +TST_CHECKPOINT_WAKE (0 ); +exit (0 ); + } + +TST_CHECKPOINT_WAIT (0 ); +check_epoll_event ("mount" ); + +TST_CHECKPOINT_WAKE_AND_WAIT (0 ); +check_epoll_event ("umount" ); +} + +static void cleanup (void ) +{ +if (efd !=-1 ) +SAFE_CLOSE (efd); + +if (mnt_fd !=-1 ) +SAFE_CLOSE (mnt_fd); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .needs_root =1 , + .forks_child =1 , + .needs_checkpoints =1 , + .needs_tmpdir =1 , +};Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Besides these observations:
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 5/8] syscalls: Add epoll_wait10
Hi!
Quoted 11 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c line 57
Quoted 9 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +9
-0+static void check_epoll_event (const char *desc) +{ +struct epoll_event ret_ev; +char buf[1024 ]; + +TEST (epoll_wait (efd, &ret_ev,1 ,1000 )); +if (TST_RET <1 ) { +tst_res (TFAIL |TTERRNO , +"epoll_wait() after %s returned %li" , desc,TST_RET );return; here.
Notice that we need to drain the notification a the bottom, so the best we can do is goto drain;
Quoted 10 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c line 65
Quoted 8 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait10.c new file +8
-0+ }else if (!(ret_ev.events & (EPOLLPRI |EPOLLERR ))) { +tst_res (TFAIL , +"after %s: events %x, expected EPOLLPRI or EPOLLERR" , + desc, ret_ev.events); + }else { +tst_res (TPASS , +"epoll_wait() reported event after %s" , desc); + }And here I would use TST_EXP_* instead. But feel free to ignore.
However I will shorten this part to TST_EXP_EXPR() so that we have only one else branch.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 6/8 syscalls: Add epoll_wait11
In reply to Cyril HrubisA test that checks that EPOLLHUP is generated properly when a pipe is closed while epoll_wait() waits on the read end of a pipe.
--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait11.c | 94 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait11.c
runtest/syscalls +1 -0
@@ -199,6 +199,7 @@ epoll_wait07 epoll_wait07 epoll_wait08 epoll_wait08 epoll_wait09 epoll_wait09 epoll_wait10 epoll_wait10 +epoll_wait11 epoll_wait11 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02
testcases/kernel/syscalls/epoll_wait/.gitignore +1 -0
@@ -8,3 +8,4 @@ epoll_wait07 epoll_wait08 epoll_wait09 epoll_wait10 +epoll_wait11
testcases/kernel/syscalls/epoll_wait/epoll_wait11.c new file +94 -0
94 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 6/8] syscalls: Add epoll_wait11
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 7/8 syscalls: Add epoll_wait12
In reply to Cyril HrubisA test for EPOLLERR when we are waiting to write into a pipe and the read end is closed.
--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait12.c | 112 ++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait12.c
runtest/syscalls +1 -0
@@ -200,6 +200,7 @@ epoll_wait08 epoll_wait08 epoll_wait09 epoll_wait09 epoll_wait10 epoll_wait10 epoll_wait11 epoll_wait11 +epoll_wait12 epoll_wait12 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02
testcases/kernel/syscalls/epoll_wait/.gitignore +1 -0
@@ -9,3 +9,4 @@ epoll_wait08 epoll_wait09 epoll_wait10 epoll_wait11 +epoll_wait12
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +112 -0
112 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 7/8] syscalls: Add epoll_wait12
Hi Cyril,
Quoted 67 lines
A test for EPOLLERR when we are waiting to write into a pipe and the read end is closed.
Signed-off-by Cyril Hrubis <[email protected]>--- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait12.c | 112 ++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait12.cruntest/syscalls +1
-0@@ -200,6 +200,7 @@ epoll_wait08 epoll_wait08 epoll_wait09 epoll_wait09 epoll_wait10 epoll_wait10 epoll_wait11 epoll_wait11 +epoll_wait12 epoll_wait12 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02testcases/kernel/syscalls/epoll_wait/.gitignore +1
-0@@ -9,3 +9,4 @@ epoll_wait08 epoll_wait09 epoll_wait10 epoll_wait11 +epoll_wait12testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +29
-0@@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) Linux Test Project, 2026 +*/ + +/*\ +* Verify that epoll_wait reports EPOLLERR when the read end of a pipe is +* closed while a child process is blocked in epoll_wait on the write end. +* +* [Algorithm] +* +* - Create a pipe and fill it completely so the write end is not writable. +* - Register the write end with an epoll instance for EPOLLOUT. +* - Fork a child that closes its copy of the read end and blocks in +* epoll_wait waiting for the pipe to become writable. +* - Parent waits for the child to enter sleep state, then closes the read +* end. +* - The child's epoll_wait should return with EPOLLERR set. +*/ + +#include <sys/epoll.h> +#include <poll.h> + +#include "tst_test.h" +#include "tst_epoll.h" + +static int efd =-1 , fds[2 ] = {-1 ,-1 }; + +static void fill_pipe (int fd)
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c line 39
Quoted 10 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +10
-0+{ +char buf[4096 ]; +struct pollfd pfd = {.fd = fd, .events =POLLOUT }; +int nfd; + +memset (buf,'a' ,sizeof (buf)); + + do { + SAFE_WRITE(SAFE_WRITE_ANY, fd, buf, sizeof(buf)); + nfd = poll(&pfd, 1, 0);
Why we don't have a SAFE_POLL() ? I just noticed how many times we are following a manual errors handling pattern inside the tests.
Quoted 16 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +16
-0+if (nfd ==-1 ) +tst_brk (TBROK |TERRNO ,"poll()" ); + }while (nfd >0 ); +} + +static void run (void ) +{ +pid_t pid; + +SAFE_PIPE (fds); +fill_pipe (fds[1 ]); + + efd =SAFE_EPOLL_CREATE1 (0 ); + +struct epoll_event ev = { + .events =EPOLLOUT ,
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c line 65
Quoted 10 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +10
-0+ .data.fd = fds[1], + }; + +SAFE_EPOLL_CTL (efd,EPOLL_CTL_ADD , fds[1 ], &ev); + + pid =SAFE_FORK (); +if (!pid) { +SAFE_CLOSE (fds[0 ]); + +TEST (epoll_wait (efd, &ev,1 ,5000 ));
We have SAFE_EPOLL_WAIT(), is there a reason why not to use it? Do we want to track the TST_RET ?
Quoted 53 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +47
-0+if (TST_RET !=1 ) { +tst_res (TFAIL |TTERRNO , +"epoll_wait() returned %li, expected 1" , +TST_RET ); +exit (0 ); + } + +if (ev.data.fd != fds[1 ]) { +tst_res (TFAIL ,"epoll.data.fd %d, expected %d" , + ev.data.fd, fds[1 ]); +exit (0 ); + } + +if (!(ev.events &EPOLLERR )) { +tst_res (TFAIL ,"events %x, EPOLLERR not set" , + ev.events); +exit (0 ); + } + +tst_res (TPASS , +"epoll_wait() reported EPOLLERR on broken pipe" ); +exit (0 ); + } + +TST_PROCESS_STATE_WAIT (pid,'S' ,0 ); +SAFE_CLOSE (fds[0 ]); +SAFE_CLOSE (fds[1 ]); +SAFE_CLOSE (efd); +} + +static void cleanup (void ) +{ +if (fds[1 ] !=-1 ) +SAFE_CLOSE (fds[1 ]); + +if (fds[0 ] !=-1 ) +SAFE_CLOSE (fds[0 ]); + +if (efd !=-1 ) +SAFE_CLOSE (efd); +} + +static struct tst_test test = { + .test_all = run, + .cleanup = cleanup, + .forks_child =1 , +};Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 7/8] syscalls: Add epoll_wait12
Hi!
Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +8
-0+static int efd =-1 , fds[2 ] = {-1 ,-1 }; + +static void fill_pipe (int fd) +{ +char buf[4096 ]; +struct pollfd pfd = {.fd = fd, .events =POLLOUT }; +int nfd; +
Quoted 8 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c line 39
Quoted 5 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +5
-0+memset (buf,'a' ,sizeof (buf)); + + do { + SAFE_WRITE(SAFE_WRITE_ANY, fd, buf, sizeof(buf)); + nfd = poll(&pfd, 1, 0);Why we don't have a
SAFE_POLL()? I just noticed how many times we are following a manual errors handling pattern inside the tests.
I will add it in the v3.
Quoted 21 lines
Quoted 21 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +21
-0+if (nfd ==-1 ) +tst_brk (TBROK |TERRNO ,"poll()" ); + }while (nfd >0 ); +} + +static void run (void ) +{ +pid_t pid; + +SAFE_PIPE (fds); +fill_pipe (fds[1 ]); + + efd =SAFE_EPOLL_CREATE1 (0 ); + +struct epoll_event ev = { + .events =EPOLLOUT , + .data.fd = fds[1 ], + }; + +SAFE_EPOLL_CTL (efd,EPOLL_CTL_ADD , fds[1 ], &ev); +
Quoted 8 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c line 65
Quoted 5 lines
testcases/kernel/syscalls/epoll_wait/epoll_wait12.c new file +5
-0+ pid =SAFE_FORK (); +if (!pid) { +SAFE_CLOSE (fds[0 ]); + +TEST (epoll_wait (efd, &ev,1 ,5000 ));We have
SAFE_EPOLL_WAIT(), is there a reason why not to use it? Do we want to track theTST_RET?
We do not use SAFE_MACROS() for the syscall that we test, because we want to report the failure as TFAIL and not as TBROK.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 8/8 syscalls: Remove old epoll-ltp test
In reply to Cyril HrubisNow that the epoll coverate is greater than it ever was we can remove the old and ugly epoll-ltp test.
--- runtest/syscalls | 2 +- testcases/kernel/syscalls/epoll/.gitignore | 1 - testcases/kernel/syscalls/epoll/Makefile | 8 - testcases/kernel/syscalls/epoll/README.1ST | 38 - testcases/kernel/syscalls/epoll/epoll-ltp.c | 738 -------------------- 5 files changed, 1 insertion(+), 786 deletions(-) delete mode 100644 testcases/kernel/syscalls/epoll/.gitignore delete mode 100644 testcases/kernel/syscalls/epoll/Makefile delete mode 100644 testcases/kernel/syscalls/epoll/README.1ST delete mode 100644 testcases/kernel/syscalls/epoll/epoll-ltp.c
runtest/syscalls +1 -1
@@ -181,7 +181,7 @@ epoll_create03 epoll_create03 epoll_create1_01 epoll_create1_01 epoll_create1_02 epoll_create1_02 -epoll01 epoll-ltp + epoll_ctl01 epoll_ctl01 epoll_ctl02 epoll_ctl02 epoll_ctl03 epoll_ctl03
testcases/kernel/syscalls/epoll/.gitignore deleted +0 -1
@@ -1 +0,0 @@ -/epoll-ltp
testcases/kernel/syscalls/epoll/Makefile deleted +0 -8
@@ -1,8 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (c) International Business Machines Corp., 2001 - -top_srcdir ?= ../../../.. - -include $(top_srcdir)/include/mk/testcases.mk - -include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/epoll/README.1ST deleted +0 -38
@@ -1,38 +0,0 @@ -Epoll Setup - - - ** Directions for glibc version of 2.3.2 or higher ** - -Epoll support is currently implemented in glibc 2.3.2, therefore if you have a$ -glibc version of 2.3.2 or higher then do the following steps: - -1. Download and untar the epoll library from: - http://www.xmailserver.org/linux-patches/epoll-lib-0.11.tar.gz -2. Copy <epoll-lib_directory>/include/epoll.h /usr/include -3. Compile epoll-ltp.c in the <ltp_dir>testcases/kernel/syscall/epoll - - - - ** Older version of glibc ** -To compile the epoll-ltp successfully the following libraries are needed: - -Epoll library http://www.xmailserver.org/linux-patches/epoll-lib-0.11.tar.gz -Portable Coroutine Library (PCL) http://www.xmailserver.org/libpcl.html - - -1. Download and untar the PCL library -2. Run ./configure -3. Run make -4. Run make install -5. Copy <libpcl_directory>/pcl/.libs/libpcl.* /lib -6. Download and untar the epoll library -7. *You may have to modify the makefile in <epoll-lib_directory>/Makefile and <epoll-lib_directory>/examples/Makefile with the following -- KERNELDIR = kernel_directory -- #all: .depend $(TARGET) epoll-example change this line to$ -- all: .$(TARGET) epoll-example -- #include .depend comment out this line -8. Copy <epoll-lib_directory>/include/epoll.h /usr/include -9. <epoll-lib_directory> make -10. Copy <epoll-lib_directory>/lib/libepoll* /lib -11. Compile epoll-ltp.c in the <ltp_dir>testcases/kernel/syscall/epoll -
testcases/kernel/syscalls/epoll/epoll-ltp.c deleted +0 -738
738 lines not on this page · raw message
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 8/8] syscalls: Remove old epoll-ltp test
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
The patch-set is generally ok, but there are multiple issues on the Copyright part. Please take a look at that because sometimes it shows Linux Test Project copyright and sometimes Cyril Hrubis copyright.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 4 lines
The patch-set is generally ok, but there are multiple issues on the Copyright part. Please take a look at that because sometimes it shows Linux Test Project copyright and sometimes Cyril Hrubis copyright.
There are couple of other things to fix, mainly the failure pointed out by Li. I will fix all these and send v3.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp