Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/5] Even more epoll tests
@ 2026-07-15  9:41 Cyril Hrubis
  2026-07-15  9:41 ` [LTP] [PATCH 1/5] syscalls: Add epoll_ctl07 Cyril Hrubis
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Cyril Hrubis @ 2026-07-15  9:41 UTC (permalink / raw)
  To: ltp

Even after the patchset there were gaps in the coverage.

Cyril Hrubis (5):
  syscalls: Add epoll_ctl07
  syscalls: Add epoll_wait13
  syscalls: Add epoll_wait14
  syscalls: Add epoll_wait15
  syscalls/epoll_wait15: Add EPOLLEXCLUSIVE test

 runtest/syscalls                              |   5 +
 .../kernel/syscalls/epoll_ctl/.gitignore      |   1 +
 .../kernel/syscalls/epoll_ctl/epoll_ctl07.c   |  60 ++++++++
 .../kernel/syscalls/epoll_wait/.gitignore     |   4 +
 .../kernel/syscalls/epoll_wait/epoll_wait13.c | 143 ++++++++++++++++++
 .../kernel/syscalls/epoll_wait/epoll_wait14.c | 114 ++++++++++++++
 .../kernel/syscalls/epoll_wait/epoll_wait15.c | 102 +++++++++++++
 .../kernel/syscalls/epoll_wait/epoll_wait16.c | 115 ++++++++++++++
 8 files changed, 544 insertions(+)
 create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl07.c
 create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait13.c
 create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait14.c
 create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait15.c
 create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait16.c

-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 1/5] syscalls: Add epoll_ctl07
@ 2026-07-15 12:36 Cyril Hrubis
  2026-07-15 12:59 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2026-07-15 12:36 UTC (permalink / raw)
  To: ltp

The epoll_ctl05 exercies the loop detector with a longer chain this
test does the same but only with two epoll fds.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 runtest/syscalls                              |  1 +
 .../kernel/syscalls/epoll_ctl/.gitignore      |  1 +
 .../kernel/syscalls/epoll_ctl/epoll_ctl07.c   | 60 +++++++++++++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl07.c

diff --git a/runtest/syscalls b/runtest/syscalls
index 789d1550d..9f46e28de 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -188,6 +188,7 @@ epoll_ctl03 epoll_ctl03
 epoll_ctl04 epoll_ctl04
 epoll_ctl05 epoll_ctl05
 epoll_ctl06 epoll_ctl06
+epoll_ctl07 epoll_ctl07
 
 epoll_wait01 epoll_wait01
 epoll_wait02 epoll_wait02
diff --git a/testcases/kernel/syscalls/epoll_ctl/.gitignore b/testcases/kernel/syscalls/epoll_ctl/.gitignore
index 9c555f41b..66da2dbfb 100644
--- a/testcases/kernel/syscalls/epoll_ctl/.gitignore
+++ b/testcases/kernel/syscalls/epoll_ctl/.gitignore
@@ -4,3 +4,4 @@ epoll_ctl03
 epoll_ctl04
 epoll_ctl05
 epoll_ctl06
+epoll_ctl07
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl07.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl07.c
new file mode 100644
index 000000000..6e9b3a1a2
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl07.c
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Cyril Hrubis <chrubis@suse.cz>
+ */
+
+/*\
+ * Verify that :manpage:`epoll_ctl(2)` fails with ELOOP when an
+ * ``EPOLL_CTL_ADD`` operation would create a minimal two-instance cycle of
+ * epoll instances monitoring one another.
+ *
+ * This is the shortest path through the kernel loop detector. The existing
+ * epoll_ctl05 test exercises a long chain closed into a loop.
+ *
+ * [Algorithm]
+ *
+ * - create two epoll instances ep_a and ep_b
+ * - add ep_b into ep_a with EPOLL_CTL_ADD (succeeds)
+ * - add ep_a into ep_b with EPOLL_CTL_ADD, which must fail with ELOOP
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "tst_epoll.h"
+
+static int ep_a = -1, ep_b = -1;
+
+static void setup(void)
+{
+	struct epoll_event ev = {.events = EPOLLIN};
+
+	ep_a = SAFE_EPOLL_CREATE1(0);
+	ep_b = SAFE_EPOLL_CREATE1(0);
+
+	ev.data.fd = ep_b;
+	SAFE_EPOLL_CTL(ep_a, EPOLL_CTL_ADD, ep_b, &ev);
+}
+
+static void cleanup(void)
+{
+	if (ep_a != -1)
+		SAFE_CLOSE(ep_a);
+
+	if (ep_b != -1)
+		SAFE_CLOSE(ep_b);
+}
+
+static void run(void)
+{
+	struct epoll_event ev = {.events = EPOLLIN, .data.fd = ep_a};
+
+	TST_EXP_FAIL(epoll_ctl(ep_b, EPOLL_CTL_ADD, ep_a, &ev), ELOOP,
+		     "epoll_ctl(EPOLL_CTL_ADD) closing a two-instance cycle");
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+};
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-07-15 13:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15  9:41 [LTP] [PATCH 0/5] Even more epoll tests Cyril Hrubis
2026-07-15  9:41 ` [LTP] [PATCH 1/5] syscalls: Add epoll_ctl07 Cyril Hrubis
2026-07-15 11:02   ` [LTP] " linuxtestproject.agent
2026-07-15 11:07     ` Cyril Hrubis
2026-07-15  9:41 ` [LTP] [PATCH 2/5] syscalls: Add epoll_wait13 Cyril Hrubis
2026-07-15  9:41 ` [LTP] [PATCH 3/5] syscalls: Add epoll_wait14 Cyril Hrubis
2026-07-15  9:41 ` [LTP] [PATCH 4/5] syscalls: Add epoll_wait15 Cyril Hrubis
2026-07-15  9:41 ` [LTP] [PATCH 5/5] syscalls/epoll_wait15: Add EPOLLEXCLUSIVE test Cyril Hrubis
2026-07-15 11:25 ` [LTP] [PATCH 0/5] Even more epoll tests Andrea Cervesato via ltp
2026-07-15 11:30   ` Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2026-07-15 12:36 [LTP] [PATCH v2 1/5] syscalls: Add epoll_ctl07 Cyril Hrubis
2026-07-15 12:59 ` [LTP] " linuxtestproject.agent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox