Skip to contentSkip to conversation

Add epoll_create1_03 test

PATCH In review Andrea Cervesato via ltp 2 participants 3 messages Oct 7, 2022 – Oct 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add epoll_create1_03 test

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

---
 .../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
testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +34 -0
new file mode 100644
index 000000000..7f51edf7a
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [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,
+};
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Andrea,

Quoted 31 lines · IST Andrea Cervesato via ltp

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

---
 .../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
testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +16 -0
new file mode 100644
index 000000000..7f51edf7a
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [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"

testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c line 26

Quoted 10 lines
testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +10 -0
+#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);

I don't think this is correct,
epoll_create1(0) will return a file descriptor (a nonnegative integer). And IIUC, TST_EXP_PASS* macros take a function call only and not a compare statement.

testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c line 34

Quoted 9 lines
testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +8 -0
+
+	TST_EXP_FAIL(epoll_create1(0), EMFILE);
+}
+
+static struct tst_test test = {
+	.min_kver = "2.6.27",
+	.test_all = run,
+};

Also,
Test reports TBROK if run for more than one iteration -

$ ./epoll_create1_03 -i2
tst_test.c:1526: TINFO: Timeout per run is 0h 00m 30s
epoll_create1_03.c:28: TPASS: epoll_create1(0) : EMFILE (24)
epoll_create1_03.c:23: TBROK: Failed to open FILE '/proc/sys/fs/epoll/max_user_watches' for reading: EMFILE (24)

Kind Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Avinesh,

as I mentioned in the previous message, this patch has to be ignored.

Andrea

Quoted 71 lines · Avinesh Kumar

Hi Andrea,

Quoted 31 lines · IST Andrea Cervesato via ltp

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

---
  .../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

testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +16 -0
new file mode 100644
index 000000000..7f51edf7a
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [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"

testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c line 26

Quoted 10 lines
testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +10 -0
+#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);

I don't think this is correct,
epoll_create1(0) will return a file descriptor (a nonnegative integer). And IIUC, TST_EXP_PASS* macros take a function call only and not a compare statement.

testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c line 34

Quoted 9 lines
testcases/kernel/syscalls/epoll_create1/epoll_create1_03.c new file +8 -0
+
+	TST_EXP_FAIL(epoll_create1(0), EMFILE);
+}
+
+static struct tst_test test = {
+	.min_kver = "2.6.27",
+	.test_all = run,
+};

Also,
Test reports TBROK if run for more than one iteration -

$ ./epoll_create1_03 -i2
tst_test.c:1526: TINFO: Timeout per run is 0h 00m 30s
epoll_create1_03.c:28: TPASS: epoll_create1(0) : EMFILE (24)
epoll_create1_03.c:23: TBROK: Failed to open FILE '/proc/sys/fs/epoll/max_user_watches' for reading: EMFILE (24)

Kind Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp