* [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl}
@ 2021-08-17 6:49 Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01 Xie Ziyao
` (6 more replies)
0 siblings, 7 replies; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
Xie Ziyao (7):
epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01
epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02
epoll_ctl: Add test for epoll_ctl03
epoll_create1: Add docparse formatting and cleanup for
epoll_create1_01
epoll_create1: Add test for epoll_create1_02
epoll_create: Add test for epoll_create01
epoll_create: Add test for epoll_create02
runtest/syscalls | 4 +
.../kernel/syscalls/epoll_create/.gitignore | 2 +
.../kernel/syscalls/epoll_create/Makefile | 9 ++
.../syscalls/epoll_create/epoll_create01.c | 40 +++++++++
.../syscalls/epoll_create/epoll_create02.c | 37 ++++++++
.../kernel/syscalls/epoll_create1/.gitignore | 3 +-
.../syscalls/epoll_create1/epoll_create1_01.c | 53 ++++++-----
.../syscalls/epoll_create1/epoll_create1_02.c | 38 ++++++++
.../kernel/syscalls/epoll_ctl/.gitignore | 5 +-
.../kernel/syscalls/epoll_ctl/epoll_ctl01.c | 28 +++---
.../kernel/syscalls/epoll_ctl/epoll_ctl02.c | 87 +++++++------------
.../kernel/syscalls/epoll_ctl/epoll_ctl03.c | 75 ++++++++++++++++
12 files changed, 280 insertions(+), 101 deletions(-)
create mode 100644 testcases/kernel/syscalls/epoll_create/.gitignore
create mode 100644 testcases/kernel/syscalls/epoll_create/Makefile
create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create01.c
create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create02.c
create mode 100644 testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c
create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c
--
2.17.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-24 15:23 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02 Xie Ziyao
` (5 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
Add docparse formatting and fix warnings from checkpatch.pl for
epoll_ctl01.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
.../kernel/syscalls/epoll_ctl/epoll_ctl01.c | 28 +++++++++----------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
index e199ac6ac..099a0f8dd 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
@@ -4,25 +4,22 @@
* Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
*/
-/*
- * Test Name: epoll_ctl01.c
+/*\
+ * [Description]
*
- * Description:
- * Testcase to check the basic functionality of the epoll_ctl(2).
- * 1) when epoll_ctl(2) succeeds to register fd on the epoll instance and
- * associates event with fd, epoll_wait(2) will get registered fd and
- * event correctly.
- * 2) when epoll_ctl(2) succeeds to chage event which is related to fd,
- * epoll_wait(2) will get chaged event correctly.
- * 3) when epoll_ctl(2) succeeds to deregister fd from the epoll instance
- * epoll_wait(2) won't get deregistered fd and event.
+ * Check the basic functionality of the epoll_ctl:
*
+ * - When epoll_ctl succeeds to register fd on the epoll instance and associates
+ * event with fd, epoll_wait will get registered fd and event correctly.
+ * - When epoll_ctl succeeds to change event which is related to fd, epoll_wait
+ * will get changed event correctly.
+ * - When epoll_ctl succeeds to deregister fd from the epoll instance epoll_wait
+ * won't get deregistered fd and event.
*/
-#include <sys/epoll.h>
#include <poll.h>
-#include <string.h>
-#include <errno.h>
+#include <sys/epoll.h>
+
#include "tst_test.h"
static int epfd;
@@ -88,9 +85,10 @@ static void check_epoll_ctl(int opt, int exp_num)
while (events) {
int events_matched = 0;
- memset(res_evs, 0, sizeof(res_evs));
+ memset(res_evs, 0, sizeof(res_evs));
res = epoll_wait(epfd, res_evs, 2, -1);
+
if (res <= 0) {
tst_res(TFAIL | TERRNO, "epoll_wait() returned %i",
res);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01 Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-24 15:24 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
` (4 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
1. Add docparse formatting.
2. Make use of TST_EXP_FAIL(...).
3. Add test for events=NULL.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
.../kernel/syscalls/epoll_ctl/epoll_ctl02.c | 87 +++++++------------
1 file changed, 32 insertions(+), 55 deletions(-)
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
index 280fd6724..f477625a6 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
@@ -4,34 +4,23 @@
* Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
*/
-/*
- * Test Name: epoll_ctl02.c
- *
- * Description:
- * 1) epoll_ctl(2) fails if epfd is a invalid file descriptor.
- * 2) epoll_ctl(2) fails if fd is a invalid file descriptor.
- * 3) epoll_ctl(2) fails if op is not supported by this interface.
- * 4) epoll_ctl(2) fails if fd is the same as epfd.
- * 5) epoll_ctl(2) fails with EPOLL_CTL_DEL if fd is not registered
- * with this epoll instance.
- * 6) epoll_ctl(2) fails with EPOLL_CTL_MOD if fd is not registered
- * with this epoll instance.
- * 7) epoll_ctl(2) fails with EPOLL_CTL_ADD if fd is already registered
- * with this epoll instance.
- *
- * Expected Result:
- * 1) epoll_ctl(2) should return -1 and set errno to EBADF.
- * 2) epoll_ctl(2) should return -1 and set errno to EBADF.
- * 3) epoll_ctl(2) should return -1 and set errno to EINVAL.
- * 4) epoll_ctl(2) should return -1 and set errno to EINVAL.
- * 5) epoll_ctl(2) should return -1 and set errno to ENOENT.
- * 6) epoll_ctl(2) should return -1 and set errno to ENOENT.
- * 7) epoll_ctl(2) should return -1 and set errno to EEXIST.
+/*\
+ * [Description]
*
+ * Verify that,
+ * - epoll_ctl fails with EBADF if epfd is an invalid fd.
+ * - epoll_ctl fails with EBADF if fd is an invalid fd.
+ * - epoll_ctl fails with EINVAL if op is not supported.
+ * - epoll_ctl fails with EINVAL if fd is the same as epfd.
+ * - epoll_ctl fails with EINVAL if events is NULL.
+ * - epoll_ctl fails with ENOENT if fd is not registered with EPOLL_CTL_DEL.
+ * - epoll_ctl fails with ENOENT if fd is not registered with EPOLL_CTL_MOD.
+ * - epoll_ctl fails with EEXIST if fd is already registered with EPOLL_CTL_ADD.
*/
-#include <sys/epoll.h>
+
#include <poll.h>
-#include <errno.h>
+#include <sys/epoll.h>
+
#include "tst_test.h"
static int epfd;
@@ -44,19 +33,21 @@ static struct epoll_event events[2] = {
};
static struct testcase {
- int *epfds;
+ int *epfd;
int opt;
- int *fds;
- struct epoll_event *ts_event;
+ int *fd;
+ struct epoll_event *event;
int exp_err;
-} tcases[] = {
- {&inv, EPOLL_CTL_ADD, &fd[1], &events[1], EBADF},
- {&epfd, EPOLL_CTL_ADD, &inv, &events[1], EBADF},
- {&epfd, -1, &fd[1], &events[1], EINVAL},
- {&epfd, EPOLL_CTL_ADD, &epfd, &events[1], EINVAL},
- {&epfd, EPOLL_CTL_DEL, &fd[1], &events[1], ENOENT},
- {&epfd, EPOLL_CTL_MOD, &fd[1], &events[1], ENOENT},
- {&epfd, EPOLL_CTL_ADD, &fd[0], &events[0], EEXIST}
+ const char *desc;
+} tc[] = {
+ {&inv, EPOLL_CTL_ADD, &fd[1], &events[1], EBADF, "epfd is an invalid fd"},
+ {&epfd, EPOLL_CTL_ADD, &inv, &events[1], EBADF, "fd is an invalid fd"},
+ {&epfd, -1, &fd[1], &events[1], EINVAL, "op is not supported"},
+ {&epfd, EPOLL_CTL_ADD, &epfd, &events[1], EINVAL, "fd is the same as epfd"},
+ {&epfd, EPOLL_CTL_ADD, &fd[1], NULL, EFAULT, "events is NULL"},
+ {&epfd, EPOLL_CTL_DEL, &fd[1], &events[1], ENOENT, "fd is not registered with EPOLL_CTL_DEL"},
+ {&epfd, EPOLL_CTL_MOD, &fd[1], &events[1], ENOENT, "fd is not registered with EPOLL_CTL_MOD"},
+ {&epfd, EPOLL_CTL_ADD, &fd[0], &events[0], EEXIST, "fd is already registered with EPOLL_CTL_ADD"}
};
static void setup(void)
@@ -70,9 +61,8 @@ static void setup(void)
events[0].data.fd = fd[0];
events[1].data.fd = fd[1];
- TEST(epoll_ctl(epfd, EPOLL_CTL_ADD, fd[0], &events[0]));
- if (TST_RET == -1)
- tst_brk(TFAIL | TTERRNO, "epoll_ctl() fails to init");
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd[0], &events[0]))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
}
static void cleanup(void)
@@ -89,25 +79,12 @@ static void cleanup(void)
static void verify_epoll_ctl(unsigned int n)
{
- struct testcase *tc = &tcases[n];
-
- TEST(epoll_ctl(*tc->epfds, tc->opt, *tc->fds, tc->ts_event));
- if (TST_RET != -1) {
- tst_res(TFAIL, "epoll_ctl() succeeds unexpectedly");
- return;
- }
-
- if (tc->exp_err == TST_ERR) {
- tst_res(TPASS | TTERRNO, "epoll_ctl() fails as expected");
- } else {
- tst_res(TFAIL | TTERRNO,
- "epoll_ctl() fails unexpectedly, expected %i: %s",
- tc->exp_err, tst_strerrno(tc->exp_err));
- }
+ TST_EXP_FAIL(epoll_ctl(*tc[n].epfd, tc[n].opt, *tc[n].fd, tc[n].event),
+ tc[n].exp_err, "epoll_clt(...) if %s", tc[n].desc);
}
static struct tst_test test = {
- .tcnt = ARRAY_SIZE(tcases),
+ .tcnt = ARRAY_SIZE(tc),
.setup = setup,
.cleanup = cleanup,
.test = verify_epoll_ctl,
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01 Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02 Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-24 15:38 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01 Xie Ziyao
` (3 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
Check that epoll_ctl returns zero with different combinations of events on
success.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_ctl/.gitignore | 5 +-
.../kernel/syscalls/epoll_ctl/epoll_ctl03.c | 75 +++++++++++++++++++
3 files changed, 79 insertions(+), 2 deletions(-)
create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 7d308dcec..b28d19ac7 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -160,6 +160,7 @@ epoll_create1_01 epoll_create1_01
epoll01 epoll-ltp
epoll_ctl01 epoll_ctl01
epoll_ctl02 epoll_ctl02
+epoll_ctl03 epoll_ctl03
epoll_wait01 epoll_wait01
epoll_wait02 epoll_wait02
epoll_wait03 epoll_wait03
diff --git a/testcases/kernel/syscalls/epoll_ctl/.gitignore b/testcases/kernel/syscalls/epoll_ctl/.gitignore
index 634470a06..2b50d924c 100644
--- a/testcases/kernel/syscalls/epoll_ctl/.gitignore
+++ b/testcases/kernel/syscalls/epoll_ctl/.gitignore
@@ -1,2 +1,3 @@
-/epoll_ctl01
-/epoll_ctl02
+epoll_ctl01
+epoll_ctl02
+epoll_ctl03
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c
new file mode 100644
index 000000000..f80bef93e
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Check that epoll_ctl returns zero with different combinations of events on
+ * success.
+ */
+
+#include <poll.h>
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+
+#define WIDTH_EPOLL_EVENTS 256
+
+static int epfd, fds[2];
+static struct epoll_event events = {.events = EPOLLIN};
+
+static void run_all(void)
+{
+ unsigned int index, events_bitmap;
+
+ for (index = 0; index < WIDTH_EPOLL_EVENTS; index++) {
+ events_bitmap = ((EPOLLIN * ((index & 0x01) >> 0)) |
+ (EPOLLOUT * ((index & 0x02) >> 1)) |
+ (EPOLLPRI * ((index & 0x04) >> 2)) |
+ (EPOLLERR * ((index & 0x08) >> 3)) |
+ (EPOLLHUP * ((index & 0x10) >> 4)) |
+ (EPOLLET * ((index & 0x20) >> 5)) |
+ (EPOLLONESHOT * ((index & 0x40) >> 6)) |
+ (EPOLLRDHUP * ((index & 0x80) >> 7)));
+
+ events.events = events_bitmap;
+ TST_EXP_PASS(epoll_ctl(epfd, EPOLL_CTL_MOD, fds[0], &events),
+ "epoll_ctl(..., EPOLL_CTL_MOD, ...) with events.events=%x",
+ events.events);
+ }
+}
+
+static void setup(void)
+{
+ epfd = epoll_create(1);
+ if (epfd == -1)
+ tst_brk(TBROK | TERRNO, "fail to create epoll instance");
+
+ SAFE_PIPE(fds);
+ events.data.fd = fds[0];
+
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &events))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+}
+
+static void cleanup(void)
+{
+ if (epfd)
+ SAFE_CLOSE(epfd);
+
+ if (fds[0])
+ SAFE_CLOSE(fds[0]);
+
+ if (fds[1])
+ SAFE_CLOSE(fds[1]);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .cleanup = cleanup,
+ .test_all = run_all,
+ .min_kver = "2.6.17",
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
` (2 preceding siblings ...)
2021-08-17 6:49 ` [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-25 9:46 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02 Xie Ziyao
` (2 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
1. Add docparse formatting.
2. Make use of ARRAY_SIZE().
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
.../syscalls/epoll_create1/epoll_create1_01.c | 53 +++++++++----------
.../syscalls/epoll_create1/epoll_create1_02.c | 0
2 files changed, 25 insertions(+), 28 deletions(-)
create mode 100644 testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c
diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
index 41aa634e1..39e01eb8b 100644
--- a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
+++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
@@ -2,51 +2,48 @@
/*
* Copyright (c) Ulrich Drepper <drepper@redhat.com>
* Copyright (c) International Business Machines Corp., 2009
+ */
+
+/*\
+ * [Description]
*
- * Test system call introduced in 2.6.27.
- * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a0998b50c3f0b8fdd265c63e0032f86ebe377dbf
- *
- * This patch adds the new epoll_create1 syscall. It extends the old
- * epoll_create syscall by one parameter which is meant to hold a flag value.
- * In this patch the only flag support is EPOLL_CLOEXEC which causes the
- * close-on-exec flag for the returned file descriptor to be set. A new name
- * EPOLL_CLOEXEC is introduced which in this implementation must have the same
- * value as O_CLOEXEC.
+ * Verify that epoll_create1 sets the close-on-exec flag for the returned
+ * file descriptor with the only flag support, EPOLL_CLOEXEC.
*/
-#include <errno.h>
+
#include <sys/epoll.h>
+
#include "tst_test.h"
#include "lapi/epoll.h"
#include "lapi/syscalls.h"
-static void verify_epoll_create1(void)
+static struct test_case_t {
+ int flags;
+ int exp_flag;
+ const char *desc;
+} tc[] = {
+ {0, 0, "flags=0 didn't set close-on-exec flag"},
+ {EPOLL_CLOEXEC, 1, "flags=EPOLL_CLOEXEC set close-on-exec"}
+};
+
+static void run(unsigned int n)
{
int fd, coe;
- fd = tst_syscall(__NR_epoll_create1, 0);
+ fd = tst_syscall(__NR_epoll_create1, tc[n].flags);
if (fd == -1)
- tst_brk(TFAIL | TERRNO, "epoll_create1(0) failed");
+ tst_brk(TFAIL | TERRNO, "epoll_create1(...) failed");
coe = SAFE_FCNTL(fd, F_GETFD);
- if (coe & FD_CLOEXEC)
- tst_brk(TFAIL, "flags=0 set close-on-exec flag");
+ if ((coe & FD_CLOEXEC) != tc[n].exp_flag)
+ tst_brk(TFAIL, "epoll_create1(...) with %s", tc[n].desc);
+ tst_res(TPASS, "epoll_create1(...) with %s", tc[n].desc);
SAFE_CLOSE(fd);
-
- fd = tst_syscall(__NR_epoll_create1, EPOLL_CLOEXEC);
- if (fd == -1)
- tst_brk(TFAIL | TERRNO, "epoll_create1(EPOLL_CLOEXEC) failed");
-
- coe = SAFE_FCNTL(fd, F_GETFD);
- if ((coe & FD_CLOEXEC) == 0)
- tst_brk(TFAIL, "flags=EPOLL_CLOEXEC didn't set close-on-exec");
-
- SAFE_CLOSE(fd);
-
- tst_res(TPASS, "epoll_create1(EPOLL_CLOEXEC) PASSED");
}
static struct tst_test test = {
.min_kver = "2.6.27",
- .test_all = verify_epoll_create1,
+ .tcnt = ARRAY_SIZE(tc),
+ .test = run,
};
diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c
new file mode 100644
index 000000000..e69de29bb
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
` (3 preceding siblings ...)
2021-08-17 6:49 ` [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01 Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-25 11:35 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01 Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02 Xie Ziyao
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
Verify that epoll_create1 returns -1 and set errno to EINVAL with an invalid
value specified in flags.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_create1/.gitignore | 3 +-
.../syscalls/epoll_create1/epoll_create1_02.c | 38 +++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/runtest/syscalls b/runtest/syscalls
index b28d19ac7..f6fe140b2 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -157,6 +157,7 @@ dup3_01 dup3_01
dup3_02 dup3_02
epoll_create1_01 epoll_create1_01
+epoll_create1_02 epoll_create1_02
epoll01 epoll-ltp
epoll_ctl01 epoll_ctl01
epoll_ctl02 epoll_ctl02
diff --git a/testcases/kernel/syscalls/epoll_create1/.gitignore b/testcases/kernel/syscalls/epoll_create1/.gitignore
index 7de2e4231..3e0482de9 100644
--- a/testcases/kernel/syscalls/epoll_create1/.gitignore
+++ b/testcases/kernel/syscalls/epoll_create1/.gitignore
@@ -1 +1,2 @@
-/epoll_create1_01
+epoll_create1_01
+epoll_create1_02
diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c
index e69de29bb..2308a65d6 100644
--- a/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c
+++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that epoll_create1 returns -1 and set errno to EINVAL with an invalid
+ * value specified in flags.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "lapi/epoll.h"
+#include "lapi/syscalls.h"
+
+static struct test_case_t {
+ int flags;
+ int exp_err;
+ const char *desc;
+} tc[] = {
+ {-1, EINVAL, "-1"},
+ {EPOLL_CLOEXEC + 1, EINVAL, "EPOLL_CLOEXEC+1"}
+};
+
+static void run(unsigned int n)
+{
+ TST_EXP_FAIL(tst_syscall(__NR_epoll_create1, tc[n].flags),
+ tc[n].exp_err, "create(%s)", tc[n].desc);
+}
+
+static struct tst_test test = {
+ .tcnt = ARRAY_SIZE(tc),
+ .test = run,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
` (4 preceding siblings ...)
2021-08-17 6:49 ` [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02 Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-25 12:00 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02 Xie Ziyao
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
Verify that epoll_create return a nonnegative file descriptor on success.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_create/.gitignore | 1 +
.../kernel/syscalls/epoll_create/Makefile | 9 +++++
.../syscalls/epoll_create/epoll_create01.c | 40 +++++++++++++++++++
4 files changed, 51 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_create/.gitignore
create mode 100644 testcases/kernel/syscalls/epoll_create/Makefile
create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create01.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f6fe140b2..2540905a0 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -156,6 +156,7 @@ dup205 dup205
dup3_01 dup3_01
dup3_02 dup3_02
+epoll_create01 epoll_create01
epoll_create1_01 epoll_create1_01
epoll_create1_02 epoll_create1_02
epoll01 epoll-ltp
diff --git a/testcases/kernel/syscalls/epoll_create/.gitignore b/testcases/kernel/syscalls/epoll_create/.gitignore
new file mode 100644
index 000000000..0ed4d940a
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create/.gitignore
@@ -0,0 +1 @@
+epoll_create01
diff --git a/testcases/kernel/syscalls/epoll_create/Makefile b/testcases/kernel/syscalls/epoll_create/Makefile
new file mode 100644
index 000000000..0e0d8c56f
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+# Author: Xie Ziyao <xieziyao@huawei.com>
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/epoll_create/epoll_create01.c b/testcases/kernel/syscalls/epoll_create/epoll_create01.c
new file mode 100644
index 000000000..53cb1dfe1
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create/epoll_create01.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that epoll_create return a nonnegative file descriptor on success.
+ *
+ * The size argument informed the kernel of the number of file descriptors
+ * that the caller expected to add to the epoll instance, but it is no longer
+ * required.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "lapi/epoll.h"
+#include "lapi/syscalls.h"
+
+static int tc[] = {1, INT_MAX};
+
+static void run(unsigned int n)
+{
+ int fd;
+
+ fd = tst_syscall(__NR_epoll_create, tc[n]);
+ if (fd < 0)
+ tst_brk(TFAIL | TERRNO, "epoll_create(%d) failed", tc[n]);
+ tst_res(TPASS, "epoll_create(%d)", tc[n]);
+
+ SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+ .tcnt = ARRAY_SIZE(tc),
+ .test = run,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
` (5 preceding siblings ...)
2021-08-17 6:49 ` [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01 Xie Ziyao
@ 2021-08-17 6:49 ` Xie Ziyao
2021-08-25 12:01 ` Cyril Hrubis
6 siblings, 1 reply; 16+ messages in thread
From: Xie Ziyao @ 2021-08-17 6:49 UTC (permalink / raw)
To: ltp
Verify that epoll_create returns -1 and set errno to EINVAL if size is
not positive.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_create/.gitignore | 1 +
.../syscalls/epoll_create/epoll_create02.c | 37 +++++++++++++++++++
3 files changed, 39 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create02.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 2540905a0..d5a1e86e8 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -157,6 +157,7 @@ dup3_01 dup3_01
dup3_02 dup3_02
epoll_create01 epoll_create01
+epoll_create02 epoll_create02
epoll_create1_01 epoll_create1_01
epoll_create1_02 epoll_create1_02
epoll01 epoll-ltp
diff --git a/testcases/kernel/syscalls/epoll_create/.gitignore b/testcases/kernel/syscalls/epoll_create/.gitignore
index 0ed4d940a..5c16cfa8c 100644
--- a/testcases/kernel/syscalls/epoll_create/.gitignore
+++ b/testcases/kernel/syscalls/epoll_create/.gitignore
@@ -1 +1,2 @@
epoll_create01
+epoll_create02
diff --git a/testcases/kernel/syscalls/epoll_create/epoll_create02.c b/testcases/kernel/syscalls/epoll_create/epoll_create02.c
new file mode 100644
index 000000000..bbc493906
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create/epoll_create02.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that epoll_create returns -1 and set errno to EINVAL if size is not
+ * positive.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "lapi/epoll.h"
+#include "lapi/syscalls.h"
+
+static struct test_case_t {
+ int size;
+ int exp_err;
+} tc[] = {
+ {0, EINVAL},
+ {-1, EINVAL}
+};
+
+static void run(unsigned int n)
+{
+ TST_EXP_FAIL(tst_syscall(__NR_epoll_create, tc[n].size),
+ tc[n].exp_err, "create(%d)", tc[n].size);
+}
+
+static struct tst_test test = {
+ .tcnt = ARRAY_SIZE(tc),
+ .test = run,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01
2021-08-17 6:49 ` [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01 Xie Ziyao
@ 2021-08-24 15:23 ` Cyril Hrubis
0 siblings, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-24 15:23 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02
2021-08-17 6:49 ` [LTP] [PATCH 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02 Xie Ziyao
@ 2021-08-24 15:24 ` Cyril Hrubis
0 siblings, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-24 15:24 UTC (permalink / raw)
To: ltp
Hi!
Pushed with a minor change to the documentation comment, thanks.
> +/*\
> + * [Description]
> *
> + * Verify that,
> + * - epoll_ctl fails with EBADF if epfd is an invalid fd.
> + * - epoll_ctl fails with EBADF if fd is an invalid fd.
> + * - epoll_ctl fails with EINVAL if op is not supported.
> + * - epoll_ctl fails with EINVAL if fd is the same as epfd.
> + * - epoll_ctl fails with EINVAL if events is NULL.
> + * - epoll_ctl fails with ENOENT if fd is not registered with EPOLL_CTL_DEL.
> + * - epoll_ctl fails with ENOENT if fd is not registered with EPOLL_CTL_MOD.
> + * - epoll_ctl fails with EEXIST if fd is already registered with EPOLL_CTL_ADD.
There is no reason to repeat the 'epoll_ctl fails with' so I've moved it
to the "Verify that," part and also there has to be empty line after the
"Verify that..." so that the list renders as a list in asciidoc.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03
2021-08-17 6:49 ` [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
@ 2021-08-24 15:38 ` Cyril Hrubis
2021-08-26 2:02 ` Xie Ziyao
0 siblings, 1 reply; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-24 15:38 UTC (permalink / raw)
To: ltp
> +static void run_all(void)
> +{
> + unsigned int index, events_bitmap;
> +
> + for (index = 0; index < WIDTH_EPOLL_EVENTS; index++) {
> + events_bitmap = ((EPOLLIN * ((index & 0x01) >> 0)) |
> + (EPOLLOUT * ((index & 0x02) >> 1)) |
> + (EPOLLPRI * ((index & 0x04) >> 2)) |
> + (EPOLLERR * ((index & 0x08) >> 3)) |
> + (EPOLLHUP * ((index & 0x10) >> 4)) |
> + (EPOLLET * ((index & 0x20) >> 5)) |
> + (EPOLLONESHOT * ((index & 0x40) >> 6)) |
> + (EPOLLRDHUP * ((index & 0x80) >> 7)));
I guess that we can as well add a IS_BIT_SET() macro that would do:
#define IS_BIT_SET(val, bit) (((val) & (1<<(bit))) >> (bit))
And use that here instead.
Otherwise it looks good.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01
2021-08-17 6:49 ` [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01 Xie Ziyao
@ 2021-08-25 9:46 ` Cyril Hrubis
0 siblings, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-25 9:46 UTC (permalink / raw)
To: ltp
Hi!
Pushed with a few changes, thanks.
The main problem was that the commit added empty epoll_create1_02.c
which did break the compilation and had to be removed.
Apart from that I've changed the tst_brk(TFAIL, ...) to tst_res(TFAIL,
...) since there is no real need for tst_brk() and adjusted the messages
a bit.
diff:
diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
index 39e01eb8b..ed359d434 100644
--- a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
+++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
@@ -8,7 +8,7 @@
* [Description]
*
* Verify that epoll_create1 sets the close-on-exec flag for the returned
- * file descriptor with the only flag support, EPOLL_CLOEXEC.
+ * file descriptor with EPOLL_CLOEXEC.
*/
#include <sys/epoll.h>
@@ -22,8 +22,8 @@ static struct test_case_t {
int exp_flag;
const char *desc;
} tc[] = {
- {0, 0, "flags=0 didn't set close-on-exec flag"},
- {EPOLL_CLOEXEC, 1, "flags=EPOLL_CLOEXEC set close-on-exec"}
+ {0, 0, "without EPOLL_CLOEXEC"},
+ {EPOLL_CLOEXEC, 1, "with EPOLL_CLOEXEC"}
};
static void run(unsigned int n)
@@ -36,8 +36,9 @@ static void run(unsigned int n)
coe = SAFE_FCNTL(fd, F_GETFD);
if ((coe & FD_CLOEXEC) != tc[n].exp_flag)
- tst_brk(TFAIL, "epoll_create1(...) with %s", tc[n].desc);
- tst_res(TPASS, "epoll_create1(...) with %s", tc[n].desc);
+ tst_res(TFAIL, "epoll_create1(...) %s", tc[n].desc);
+ else
+ tst_res(TPASS, "epoll_create1(...) %s", tc[n].desc);
SAFE_CLOSE(fd);
}
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02
2021-08-17 6:49 ` [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02 Xie Ziyao
@ 2021-08-25 11:35 ` Cyril Hrubis
0 siblings, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-25 11:35 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01
2021-08-17 6:49 ` [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01 Xie Ziyao
@ 2021-08-25 12:00 ` Cyril Hrubis
0 siblings, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-25 12:00 UTC (permalink / raw)
To: ltp
Hi!
> + fd = tst_syscall(__NR_epoll_create, tc[n]);
> + if (fd < 0)
> + tst_brk(TFAIL | TERRNO, "epoll_create(%d) failed", tc[n]);
> + tst_res(TPASS, "epoll_create(%d)", tc[n]);
We even have TST_EXP_FD() exactly for this case.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02
2021-08-17 6:49 ` [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02 Xie Ziyao
@ 2021-08-25 12:01 ` Cyril Hrubis
0 siblings, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2021-08-25 12:01 UTC (permalink / raw)
To: ltp
Hi!
This one looks fine, but needs the previous patch applied first.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 16+ messages in thread
* [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03
2021-08-24 15:38 ` Cyril Hrubis
@ 2021-08-26 2:02 ` Xie Ziyao
0 siblings, 0 replies; 16+ messages in thread
From: Xie Ziyao @ 2021-08-26 2:02 UTC (permalink / raw)
To: ltp
Hi, Cyril,
>> +static void run_all(void)
>> +{
>> + unsigned int index, events_bitmap;
>> +
>> + for (index = 0; index < WIDTH_EPOLL_EVENTS; index++) {
>> + events_bitmap = ((EPOLLIN * ((index & 0x01) >> 0)) |
>> + (EPOLLOUT * ((index & 0x02) >> 1)) |
>> + (EPOLLPRI * ((index & 0x04) >> 2)) |
>> + (EPOLLERR * ((index & 0x08) >> 3)) |
>> + (EPOLLHUP * ((index & 0x10) >> 4)) |
>> + (EPOLLET * ((index & 0x20) >> 5)) |
>> + (EPOLLONESHOT * ((index & 0x40) >> 6)) |
>> + (EPOLLRDHUP * ((index & 0x80) >> 7)));
>
> I guess that we can as well add a IS_BIT_SET() macro that would do:
>
> #define IS_BIT_SET(val, bit) (((val) & (1<<(bit))) >> (bit))
Looks good, thanks. I've added this macro to include/tst_bitmap.h in the
v2 patchset, other changes have also been applied.
Besides, I've used a different outlook email to submit and hope it
doesn't cause misunderstandings.
>
> And use that here instead.
>
> Otherwise it looks good.
>
Please see: https://patchwork.ozlabs.org/project/ltp/list/?series=259628
Thanks for your review.
--
Best Regards,
Xie Ziyao
E-mail:ziyaoxie@outlook.com
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-08-26 2:02 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 6:49 [LTP] [PATCH 0/7] epoll: Add more basic test for epoll_{create, create1, ctl} Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01 Xie Ziyao
2021-08-24 15:23 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02 Xie Ziyao
2021-08-24 15:24 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
2021-08-24 15:38 ` Cyril Hrubis
2021-08-26 2:02 ` Xie Ziyao
2021-08-17 6:49 ` [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01 Xie Ziyao
2021-08-25 9:46 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02 Xie Ziyao
2021-08-25 11:35 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01 Xie Ziyao
2021-08-25 12:00 ` Cyril Hrubis
2021-08-17 6:49 ` [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02 Xie Ziyao
2021-08-25 12:01 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.