public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] Add epoll_create1_03 test
@ 2022-10-07  8:34 Andrea Cervesato via ltp
  2022-10-10  6:23 ` Avinesh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2022-10-07  8:34 UTC (permalink / raw)
  To: ltp

The test verifies epoll_create1 will raises EMFILE when
/proc/sys/fs/epoll/max_user_watches is reached.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 .../syscalls/epoll_create1/epoll_create1_03.c | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c

diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c
new file mode 100644
index 000000000..7f51edf7a
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that epoll_create1 returns -1 and set errno to EMFILE when maximum
+ * number of epoll watchers is reached.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "lapi/epoll.h"
+#include "lapi/syscalls.h"
+
+static void run(void)
+{
+	int i, max_inst;
+
+	SAFE_FILE_LINES_SCANF("/proc/sys/fs/epoll/max_user_watches", "%d", &max_inst);
+
+	for (i = 0; i < max_inst; i++)
+		TST_EXP_PASS_SILENT(epoll_create1(0) == 0);
+
+	TST_EXP_FAIL(epoll_create1(0), EMFILE);
+}
+
+static struct tst_test test = {
+	.min_kver = "2.6.27",
+	.test_all = run,
+};
-- 
2.35.3


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

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

end of thread, other threads:[~2022-10-10  7:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07  8:34 [LTP] [PATCH v1] Add epoll_create1_03 test Andrea Cervesato via ltp
2022-10-10  6:23 ` Avinesh Kumar
2022-10-10  7:09   ` Andrea Cervesato via ltp

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