* [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2
@ 2021-06-28 8:04 Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 1/3] lapi/syscalls: Add syscall number " Xie Ziyao
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-06-28 8:04 UTC (permalink / raw)
To: ltp
Xie Ziyao (3):
lapi/syscalls: Add syscall number for epoll_pwait2
epoll_pwait2: Add test for epoll_pwait201
epoll_pwait2: Add test for epoll_pwait202
include/lapi/syscalls/aarch64.in | 1 +
include/lapi/syscalls/arc.in | 1 +
include/lapi/syscalls/arm.in | 1 +
include/lapi/syscalls/hppa.in | 3 +-
include/lapi/syscalls/i386.in | 1 +
include/lapi/syscalls/ia64.in | 1 +
include/lapi/syscalls/powerpc.in | 1 +
include/lapi/syscalls/powerpc64.in | 1 +
include/lapi/syscalls/s390.in | 1 +
include/lapi/syscalls/s390x.in | 1 +
include/lapi/syscalls/sh.in | 1 +
include/lapi/syscalls/sparc.in | 1 +
include/lapi/syscalls/sparc64.in | 1 +
include/lapi/syscalls/x86_64.in | 1 +
runtest/syscalls | 2 +
.../kernel/syscalls/epoll_pwait2/.gitignore | 2 +
.../kernel/syscalls/epoll_pwait2/Makefile | 9 +++
.../syscalls/epoll_pwait2/epoll_pwait201.c | 62 +++++++++++++++
.../syscalls/epoll_pwait2/epoll_pwait202.c | 76 +++++++++++++++++++
19 files changed, 166 insertions(+), 1 deletion(-)
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/.gitignore
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/Makefile
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/epoll_pwait201.c
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/epoll_pwait202.c
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH 1/3] lapi/syscalls: Add syscall number for epoll_pwait2
2021-06-28 8:04 [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
@ 2021-06-28 8:04 ` Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201 Xie Ziyao
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-06-28 8:04 UTC (permalink / raw)
To: ltp
Add syscall number for epoll_pwait2.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
include/lapi/syscalls/aarch64.in | 1 +
include/lapi/syscalls/arc.in | 1 +
include/lapi/syscalls/arm.in | 1 +
include/lapi/syscalls/hppa.in | 3 ++-
include/lapi/syscalls/i386.in | 1 +
include/lapi/syscalls/ia64.in | 1 +
include/lapi/syscalls/powerpc.in | 1 +
include/lapi/syscalls/powerpc64.in | 1 +
include/lapi/syscalls/s390.in | 1 +
include/lapi/syscalls/s390x.in | 1 +
include/lapi/syscalls/sh.in | 1 +
include/lapi/syscalls/sparc.in | 1 +
include/lapi/syscalls/sparc64.in | 1 +
include/lapi/syscalls/x86_64.in | 1 +
14 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
index 2def6ba3d..5a2816099 100644
--- a/include/lapi/syscalls/aarch64.in
+++ b/include/lapi/syscalls/aarch64.in
@@ -313,4 +313,5 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
_sysctl 1078
diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in
index 9bcd84706..9c1654b0b 100644
--- a/include/lapi/syscalls/arc.in
+++ b/include/lapi/syscalls/arc.in
@@ -313,3 +313,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in
index 98c840cb8..ded2f5e03 100644
--- a/include/lapi/syscalls/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -391,3 +391,4 @@ clone3 (__NR_SYSCALL_BASE+435)
close_range (__NR_SYSCALL_BASE+436)
openat2 (__NR_SYSCALL_BASE+437)
pidfd_getfd (__NR_SYSCALL_BASE+438)
+epoll_pwait2 (__NR_SYSCALL_BASE+441)
diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in
index e1628c4b1..d8f142b6a 100644
--- a/include/lapi/syscalls/hppa.in
+++ b/include/lapi/syscalls/hppa.in
@@ -39,4 +39,5 @@ fsconfig 431
fsmount 432
fspick 433
pidfd_open 434
-close_range 436
\ No newline at end of file
+close_range 436
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in
index aaa02c7bf..f69268e10 100644
--- a/include/lapi/syscalls/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -427,3 +427,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in
index 5467f80f2..3ba2406c4 100644
--- a/include/lapi/syscalls/ia64.in
+++ b/include/lapi/syscalls/ia64.in
@@ -340,3 +340,4 @@ pidfd_open 1458
close_range 1460
openat2 1461
pidfd_getfd 1462
+epoll_pwait2 1465
diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in
index 2d287a606..a4ed2169c 100644
--- a/include/lapi/syscalls/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -420,3 +420,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in
index 2d287a606..a4ed2169c 100644
--- a/include/lapi/syscalls/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -420,3 +420,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in
index c978b6660..d99e5fd9e 100644
--- a/include/lapi/syscalls/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -407,3 +407,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in
index d123db6cb..f26cdaaae 100644
--- a/include/lapi/syscalls/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -355,3 +355,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in
index 22da7d6ff..20ee61ccc 100644
--- a/include/lapi/syscalls/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -401,3 +401,4 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in
index 7324b4ac6..86decdd82 100644
--- a/include/lapi/syscalls/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -406,3 +406,4 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in
index 862d806fa..02dfe473a 100644
--- a/include/lapi/syscalls/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -371,3 +371,4 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in
index 1345002f5..cf6d78bf6 100644
--- a/include/lapi/syscalls/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -348,6 +348,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
rt_sigaction 512
rt_sigreturn 513
ioctl 514
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201
2021-06-28 8:04 [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 1/3] lapi/syscalls: Add syscall number " Xie Ziyao
@ 2021-06-28 8:04 ` Xie Ziyao
2021-07-12 12:23 ` Cyril Hrubis
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 3/3] epoll_pwait2: Add test for epoll_pwait202 Xie Ziyao
2021-06-28 8:12 ` [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
3 siblings, 2 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-06-28 8:04 UTC (permalink / raw)
To: ltp
Basic test for epoll_pwait2().
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_pwait2/.gitignore | 1 +
.../kernel/syscalls/epoll_pwait2/Makefile | 9 +++
.../syscalls/epoll_pwait2/epoll_pwait201.c | 62 +++++++++++++++++++
4 files changed, 73 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/.gitignore
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/Makefile
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/epoll_pwait201.c
diff --git a/runtest/syscalls b/runtest/syscalls
index d3eb96249..8a6b8ba20 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -166,6 +166,7 @@ epoll_wait01 epoll_wait01
epoll_wait02 epoll_wait02
epoll_wait03 epoll_wait03
epoll_pwait01 epoll_pwait01
+epoll_pwait201 epoll_pwait201
eventfd01 eventfd01
diff --git a/testcases/kernel/syscalls/epoll_pwait2/.gitignore b/testcases/kernel/syscalls/epoll_pwait2/.gitignore
new file mode 100644
index 000000000..2298cf9d9
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait2/.gitignore
@@ -0,0 +1 @@
+epoll_pwait201
diff --git a/testcases/kernel/syscalls/epoll_pwait2/Makefile b/testcases/kernel/syscalls/epoll_pwait2/Makefile
new file mode 100644
index 000000000..051db0b20
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait2/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 HUAWEI LIMITED
+# 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_pwait2/epoll_pwait201.c b/testcases/kernel/syscalls/epoll_pwait2/epoll_pwait201.c
new file mode 100644
index 000000000..a3fadc065
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait2/epoll_pwait201.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 HUAWEI LIMITED
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Basic test for epoll_pwait2().
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+
+static int efd, sfd[2];
+static struct epoll_event e;
+
+static void run(void)
+{
+ TEST(tst_syscall(__NR_epoll_pwait2, efd, &e, 1, NULL, NULL, 0));
+
+ if (TST_RET == 1) {
+ tst_res(TPASS, "epoll_pwait2() succeeded");
+ return;
+ }
+ tst_res(TFAIL, "epoll_pwait2() returned %li, expected 1", TST_RET);
+}
+
+static void setup(void)
+{
+ SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd);
+
+ efd = epoll_create(1);
+ if (efd == -1)
+ tst_brk(TBROK | TERRNO, "epoll_create()");
+
+ e.events = EPOLLIN;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+ SAFE_WRITE(1, sfd[1], "w", 1);
+}
+
+static void cleanup(void)
+{
+ if (efd > 0)
+ SAFE_CLOSE(efd);
+
+ if (sfd[0] > 0)
+ SAFE_CLOSE(sfd[0]);
+
+ if (sfd[1] > 0)
+ SAFE_CLOSE(sfd[1]);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 3/3] epoll_pwait2: Add test for epoll_pwait202
2021-06-28 8:04 [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 1/3] lapi/syscalls: Add syscall number " Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201 Xie Ziyao
@ 2021-06-28 8:04 ` Xie Ziyao
2021-07-12 12:25 ` Cyril Hrubis
2021-06-28 8:12 ` [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
3 siblings, 1 reply; 15+ messages in thread
From: Xie Ziyao @ 2021-06-28 8:04 UTC (permalink / raw)
To: ltp
Check that epoll_pwait2 timeouts correctly.
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_pwait2/.gitignore | 1 +
.../syscalls/epoll_pwait2/epoll_pwait202.c | 76 +++++++++++++++++++
3 files changed, 78 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait2/epoll_pwait202.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 8a6b8ba20..f63e57fee 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -167,6 +167,7 @@ epoll_wait02 epoll_wait02
epoll_wait03 epoll_wait03
epoll_pwait01 epoll_pwait01
epoll_pwait201 epoll_pwait201
+epoll_pwait202 epoll_pwait202
eventfd01 eventfd01
diff --git a/testcases/kernel/syscalls/epoll_pwait2/.gitignore b/testcases/kernel/syscalls/epoll_pwait2/.gitignore
index 2298cf9d9..8b2c314ea 100644
--- a/testcases/kernel/syscalls/epoll_pwait2/.gitignore
+++ b/testcases/kernel/syscalls/epoll_pwait2/.gitignore
@@ -1 +1,2 @@
epoll_pwait201
+epoll_pwait202
diff --git a/testcases/kernel/syscalls/epoll_pwait2/epoll_pwait202.c b/testcases/kernel/syscalls/epoll_pwait2/epoll_pwait202.c
new file mode 100644
index 000000000..2b0d5dd5b
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait2/epoll_pwait202.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 HUAWEI LIMITED
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Check that epoll_pwait2 timeouts correctly.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_timer_test.h"
+#include "lapi/epoll.h"
+
+static int efd, sfd[2];
+static struct epoll_event e;
+static struct __kernel_timespec ts;
+
+int sample_fn(int clk_id, long long usec)
+{
+ if (usec >= 1000000) {
+ ts.tv_sec = usec / 1000000;
+ ts.tv_nsec = 0;
+ } else {
+ ts.tv_sec = 0;
+ ts.tv_nsec = usec * 1000;
+ }
+
+ tst_timer_start(clk_id);
+ TEST(tst_syscall(__NR_epoll_pwait2, efd, &e, 1, &ts, NULL, 0));
+ tst_timer_stop();
+ tst_timer_sample();
+
+ if (TST_RET != 0) {
+ tst_res(TFAIL | TTERRNO,
+ "epoll_pwait2() returned %li, expected 0", TST_RET);
+ return 1;
+ }
+
+ return 0;
+}
+
+static void setup(void)
+{
+ SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd);
+
+ efd = epoll_create(1);
+ if (efd == -1)
+ tst_brk(TBROK | TERRNO, "epoll_create()");
+
+ e.events = EPOLLIN;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+}
+
+static void cleanup(void)
+{
+ if (efd > 0)
+ SAFE_CLOSE(efd);
+
+ if (sfd[0] > 0)
+ SAFE_CLOSE(sfd[0]);
+
+ if (sfd[1] > 0)
+ SAFE_CLOSE(sfd[1]);
+}
+
+static struct tst_test test = {
+ .scall = "epoll_pwait2()",
+ .sample = sample_fn,
+ .setup = setup,
+ .cleanup = cleanup,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2
2021-06-28 8:04 [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
` (2 preceding siblings ...)
2021-06-28 8:04 ` [LTP] [PATCH 3/3] epoll_pwait2: Add test for epoll_pwait202 Xie Ziyao
@ 2021-06-28 8:12 ` Xie Ziyao
3 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-06-28 8:12 UTC (permalink / raw)
To: ltp
Hi,
> Xie Ziyao (3):
> lapi/syscalls: Add syscall number for epoll_pwait2
> epoll_pwait2: Add test for epoll_pwait201
> epoll_pwait2: Add test for epoll_pwait202
Sorry for testing only under several archs (like arm, x86) on QEMU due
to environmental limitations.
If possible, I would recommend testing it on other platforms as well.
Kind Regards,
Ziyao
>
> include/lapi/syscalls/aarch64.in | 1 +
> include/lapi/syscalls/arc.in | 1 +
> include/lapi/syscalls/arm.in | 1 +
> include/lapi/syscalls/hppa.in | 3 +-
> include/lapi/syscalls/i386.in | 1 +
> include/lapi/syscalls/ia64.in | 1 +
> include/lapi/syscalls/powerpc.in | 1 +
> include/lapi/syscalls/powerpc64.in | 1 +
> include/lapi/syscalls/s390.in | 1 +
> include/lapi/syscalls/s390x.in | 1 +
> include/lapi/syscalls/sh.in | 1 +
> include/lapi/syscalls/sparc.in | 1 +
> include/lapi/syscalls/sparc64.in | 1 +
> include/lapi/syscalls/x86_64.in | 1 +
> runtest/syscalls | 2 +
> .../kernel/syscalls/epoll_pwait2/.gitignore | 2 +
> .../kernel/syscalls/epoll_pwait2/Makefile | 9 +++
> .../syscalls/epoll_pwait2/epoll_pwait201.c | 62 +++++++++++++++
> .../syscalls/epoll_pwait2/epoll_pwait202.c | 76 +++++++++++++++++++
> 19 files changed, 166 insertions(+), 1 deletion(-)
> create mode 100644 testcases/kernel/syscalls/epoll_pwait2/.gitignore
> create mode 100644 testcases/kernel/syscalls/epoll_pwait2/Makefile
> create mode 100644 testcases/kernel/syscalls/epoll_pwait2/epoll_pwait201.c
> create mode 100644 testcases/kernel/syscalls/epoll_pwait2/epoll_pwait202.c
>
> --
> 2.17.1
>
> .
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201
2021-06-28 8:04 ` [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201 Xie Ziyao
@ 2021-07-12 12:23 ` Cyril Hrubis
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
1 sibling, 0 replies; 15+ messages in thread
From: Cyril Hrubis @ 2021-07-12 12:23 UTC (permalink / raw)
To: ltp
Hi!
> +static void run(void)
> +{
> + TEST(tst_syscall(__NR_epoll_pwait2, efd, &e, 1, NULL, NULL, 0));
It would be better to put the prototype for epoll_pwait2 into
include/lapi/epoll.h.
Also given that the difference between epoll_pwait() and epoll_pwait2()
is only in the timeout parameter type it would make much more sense to
write these tests with two test variants so that we would cover both
epoll_pwait() and epoll_wait2().
I would have put these tests into epoll_wait/ directory and added
epoll_var.h that would make a common wrapper for both of these
functions. We do this for example for select in select/select_var.h but
in this case this would be much easier, I guess that the wrapper would
get timespec structure and convert that to miliseconds for
epoll_pwait().
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH 3/3] epoll_pwait2: Add test for epoll_pwait202
2021-06-28 8:04 ` [LTP] [PATCH 3/3] epoll_pwait2: Add test for epoll_pwait202 Xie Ziyao
@ 2021-07-12 12:25 ` Cyril Hrubis
0 siblings, 0 replies; 15+ messages in thread
From: Cyril Hrubis @ 2021-07-12 12:25 UTC (permalink / raw)
To: ltp
Hi!
I guess that this can go in as most of the complexity is in the test
library and we create similar wrapper for the epoll_pwait() test.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2
2021-06-28 8:04 ` [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201 Xie Ziyao
2021-07-12 12:23 ` Cyril Hrubis
@ 2021-07-16 10:22 ` Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 1/5 v2] lapi/syscalls: Add syscall number " Xie Ziyao
` (5 more replies)
1 sibling, 6 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-16 10:22 UTC (permalink / raw)
To: ltp
v1->v2:
1. Add the prototype for epoll_pwait and epoll_pwait2 into include/lapi/epoll.h.
2. Add test variants to switch between epoll_pwait and epoll_pwait2 for epoll_pwait.
Xie Ziyao (5):
lapi/syscalls: Add syscall number for epoll_pwait2
lapi: Add the prototype for epoll_pwait and epoll_pwait2
epoll_pwait: Add test variants for epoll_pwait
epoll_pwait: Add test for epoll_pwait02
epoll_pwait: Add test for epoll_pwait03
configure.ac | 1 +
include/lapi/epoll.h | 37 +++++++++-
include/lapi/syscalls/aarch64.in | 1 +
include/lapi/syscalls/arc.in | 1 +
include/lapi/syscalls/arm.in | 1 +
include/lapi/syscalls/hppa.in | 3 +-
include/lapi/syscalls/i386.in | 1 +
include/lapi/syscalls/ia64.in | 1 +
include/lapi/syscalls/powerpc.in | 1 +
include/lapi/syscalls/powerpc64.in | 1 +
include/lapi/syscalls/s390.in | 1 +
include/lapi/syscalls/s390x.in | 1 +
include/lapi/syscalls/sh.in | 1 +
include/lapi/syscalls/sparc.in | 1 +
include/lapi/syscalls/sparc64.in | 1 +
include/lapi/syscalls/x86_64.in | 1 +
runtest/syscalls | 2 +
.../kernel/syscalls/epoll_pwait/.gitignore | 4 +-
.../syscalls/epoll_pwait/epoll_pwait02.c | 65 ++++++++++++++++
.../syscalls/epoll_pwait/epoll_pwait03.c | 74 +++++++++++++++++++
.../syscalls/epoll_pwait/epoll_pwait_var.h | 43 +++++++++++
21 files changed, 237 insertions(+), 5 deletions(-)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH 1/5 v2] lapi/syscalls: Add syscall number for epoll_pwait2
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
@ 2021-07-16 10:22 ` Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 2/5 v2] lapi: Add the prototype for epoll_pwait and epoll_pwait2 Xie Ziyao
` (4 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-16 10:22 UTC (permalink / raw)
To: ltp
Add syscall number for epoll_pwait2.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
include/lapi/syscalls/aarch64.in | 1 +
include/lapi/syscalls/arc.in | 1 +
include/lapi/syscalls/arm.in | 1 +
include/lapi/syscalls/hppa.in | 3 ++-
include/lapi/syscalls/i386.in | 1 +
include/lapi/syscalls/ia64.in | 1 +
include/lapi/syscalls/powerpc.in | 1 +
include/lapi/syscalls/powerpc64.in | 1 +
include/lapi/syscalls/s390.in | 1 +
include/lapi/syscalls/s390x.in | 1 +
include/lapi/syscalls/sh.in | 1 +
include/lapi/syscalls/sparc.in | 1 +
include/lapi/syscalls/sparc64.in | 1 +
include/lapi/syscalls/x86_64.in | 1 +
14 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
index 2def6ba3d..5a2816099 100644
--- a/include/lapi/syscalls/aarch64.in
+++ b/include/lapi/syscalls/aarch64.in
@@ -313,4 +313,5 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
_sysctl 1078
diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in
index 9bcd84706..9c1654b0b 100644
--- a/include/lapi/syscalls/arc.in
+++ b/include/lapi/syscalls/arc.in
@@ -313,3 +313,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in
index 98c840cb8..ded2f5e03 100644
--- a/include/lapi/syscalls/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -391,3 +391,4 @@ clone3 (__NR_SYSCALL_BASE+435)
close_range (__NR_SYSCALL_BASE+436)
openat2 (__NR_SYSCALL_BASE+437)
pidfd_getfd (__NR_SYSCALL_BASE+438)
+epoll_pwait2 (__NR_SYSCALL_BASE+441)
diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in
index e1628c4b1..d8f142b6a 100644
--- a/include/lapi/syscalls/hppa.in
+++ b/include/lapi/syscalls/hppa.in
@@ -39,4 +39,5 @@ fsconfig 431
fsmount 432
fspick 433
pidfd_open 434
-close_range 436
\ No newline at end of file
+close_range 436
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in
index aaa02c7bf..f69268e10 100644
--- a/include/lapi/syscalls/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -427,3 +427,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in
index 5467f80f2..3ba2406c4 100644
--- a/include/lapi/syscalls/ia64.in
+++ b/include/lapi/syscalls/ia64.in
@@ -340,3 +340,4 @@ pidfd_open 1458
close_range 1460
openat2 1461
pidfd_getfd 1462
+epoll_pwait2 1465
diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in
index 2d287a606..a4ed2169c 100644
--- a/include/lapi/syscalls/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -420,3 +420,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in
index 2d287a606..a4ed2169c 100644
--- a/include/lapi/syscalls/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -420,3 +420,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in
index c978b6660..d99e5fd9e 100644
--- a/include/lapi/syscalls/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -407,3 +407,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in
index d123db6cb..f26cdaaae 100644
--- a/include/lapi/syscalls/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -355,3 +355,4 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in
index 22da7d6ff..20ee61ccc 100644
--- a/include/lapi/syscalls/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -401,3 +401,4 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in
index 7324b4ac6..86decdd82 100644
--- a/include/lapi/syscalls/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -406,3 +406,4 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in
index 862d806fa..02dfe473a 100644
--- a/include/lapi/syscalls/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -371,3 +371,4 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in
index 1345002f5..cf6d78bf6 100644
--- a/include/lapi/syscalls/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -348,6 +348,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+epoll_pwait2 441
rt_sigaction 512
rt_sigreturn 513
ioctl 514
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 2/5 v2] lapi: Add the prototype for epoll_pwait and epoll_pwait2
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 1/5 v2] lapi/syscalls: Add syscall number " Xie Ziyao
@ 2021-07-16 10:22 ` Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 3/5 v2] epoll_pwait: Add test variants for epoll_pwait Xie Ziyao
` (3 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-16 10:22 UTC (permalink / raw)
To: ltp
Add the prototype for epoll_pwait and epoll_pwait2 into include/lapi/epoll.h.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
v1->v2:
1. Add the prototype for epoll_pwait and epoll_pwait2 into include/lapi/epoll.h.
configure.ac | 1 +
include/lapi/epoll.h | 37 ++++++++++++++++++++++++++++++++++---
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 25c421de0..5bf3c52ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,6 +86,7 @@ AC_CHECK_FUNCS_ONCE([ \
close_range \
copy_file_range \
epoll_pwait \
+ epoll_pwait2 \
execveat \
fallocate \
fchownat \
diff --git a/include/lapi/epoll.h b/include/lapi/epoll.h
index 899eeb9d4..57f4b9d0f 100644
--- a/include/lapi/epoll.h
+++ b/include/lapi/epoll.h
@@ -1,13 +1,44 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
* Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com>
*/
#ifndef LAPI_EPOLL_H__
#define LAPI_EPOLL_H__
+#include "lapi/syscalls.h"
+#include "tst_timer_test.h"
+
#ifndef EPOLL_CLOEXEC
-# define EPOLL_CLOEXEC 02000000
+#define EPOLL_CLOEXEC 02000000
+#endif
+
+#ifndef HAVE_EPOLL_PWAIT
+int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
+ int timeout, const sigset_t *sigmask)
+{
+ return tst_syscall(__NR_epoll_pwait, epfd, events, maxevents,
+ timeout, sigmask, _NSIG / 8);
+}
+#endif
+
+#ifndef HAVE_EPOLL_PWAIT2
+int epoll_pwait2(int epfd, struct epoll_event *events, int maxevents,
+ const struct timespec *timeout, const sigset_t *sigmask)
+{
+ if (timeout == NULL)
+ return tst_syscall(__NR_epoll_pwait2, epfd, events, maxevents,
+ NULL, sigmask, _NSIG / 8);
+
+ struct __kernel_timespec ts;
+
+ ts.tv_sec = timeout->tv_sec;
+ ts.tv_nsec = timeout->tv_nsec;
+
+ return tst_syscall(__NR_epoll_pwait2, epfd, events, maxevents,
+ &ts, sigmask, _NSIG / 8);
+}
#endif
#endif /* LAPI_EPOLL_H__ */
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 3/5 v2] epoll_pwait: Add test variants for epoll_pwait
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 1/5 v2] lapi/syscalls: Add syscall number " Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 2/5 v2] lapi: Add the prototype for epoll_pwait and epoll_pwait2 Xie Ziyao
@ 2021-07-16 10:22 ` Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 4/5 v2] epoll_pwait: Add test for epoll_pwait02 Xie Ziyao
` (2 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-16 10:22 UTC (permalink / raw)
To: ltp
Add test variants to switch between different syscall variants/wrappers at runtime.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
v1->v2:
1. Add test variants to switch between epoll_pwait and epoll_pwait2.
.../syscalls/epoll_pwait/epoll_pwait_var.h | 43 +++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h
new file mode 100644
index 000000000..2bdea17e9
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+#ifndef LTP_EPOLL_PWAIT_VAR_H
+#define LTP_EPOLL_PWAIT_VAR_H
+
+#include "lapi/epoll.h"
+
+#define TEST_VARIANTS 2
+#define MSEC_PER_SEC (1000L)
+#define NSEC_PER_MSEC (1000000L)
+
+static int do_epoll_pwait(int epfd, struct epoll_event *events, int
+ maxevents, int timeout, const sigset_t *sigmask)
+{
+ if (tst_variant == 0)
+ return epoll_pwait(epfd, events, maxevents, timeout, sigmask);
+
+ struct timespec ts;
+
+ if (timeout < 0) {
+ return epoll_pwait2(epfd, events, maxevents, NULL, sigmask);
+ } else {
+ ts.tv_sec = timeout / MSEC_PER_SEC;
+ ts.tv_nsec = NSEC_PER_MSEC * (timeout % MSEC_PER_SEC);
+ }
+
+ return epoll_pwait2(epfd, events, maxevents, &ts, sigmask);
+
+}
+
+static void epoll_pwait_info(void)
+{
+ if (tst_variant == 0)
+ tst_res(TINFO, "Test epoll_pwait()");
+ else
+ tst_res(TINFO, "Test epoll_pwait2()");
+}
+
+#endif //LTP_EPOLL_PWAIT_VAR_H
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 4/5 v2] epoll_pwait: Add test for epoll_pwait02
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
` (2 preceding siblings ...)
2021-07-16 10:22 ` [LTP] [PATCH 3/5 v2] epoll_pwait: Add test variants for epoll_pwait Xie Ziyao
@ 2021-07-16 10:22 ` Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 5/5 v2] epoll_pwait: Add test for epoll_pwait03 Xie Ziyao
2021-07-19 13:45 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Cyril Hrubis
5 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-16 10:22 UTC (permalink / raw)
To: ltp
Basic test for epoll_pwait/epoll_pwait2.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
1. Add test variants to switch between epoll_pwait and epoll_pwait2.
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_pwait/.gitignore | 3 +-
.../syscalls/epoll_pwait/epoll_pwait02.c | 65 +++++++++++++++++++
3 files changed, 68 insertions(+), 1 deletion(-)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 26786c96a..bed224809 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -166,6 +166,7 @@ epoll_wait01 epoll_wait01
epoll_wait02 epoll_wait02
epoll_wait03 epoll_wait03
epoll_pwait01 epoll_pwait01
+epoll_pwait02 epoll_pwait02
eventfd01 eventfd01
diff --git a/testcases/kernel/syscalls/epoll_pwait/.gitignore b/testcases/kernel/syscalls/epoll_pwait/.gitignore
index d53943a75..ab049f173 100644
--- a/testcases/kernel/syscalls/epoll_pwait/.gitignore
+++ b/testcases/kernel/syscalls/epoll_pwait/.gitignore
@@ -1 +1,2 @@
-/epoll_pwait01
+epoll_pwait01
+epoll_pwait02
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c
new file mode 100644
index 000000000..b2733fa41
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c
@@ -0,0 +1,65 @@
+// 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]
+ *
+ * Basic test for epoll_pwait and epoll_pwait2.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "epoll_pwait_var.h"
+
+static int efd, sfd[2];
+static struct epoll_event e;
+
+static void run(void)
+{
+ TEST(do_epoll_pwait(efd, &e, 1, -1, NULL));
+
+ if (TST_RET == 1) {
+ tst_res(TPASS, "do_epoll_pwait() succeeded");
+ return;
+ }
+ tst_res(TFAIL, "do_epoll_pwait() returned %li, expected 1", TST_RET);
+}
+
+static void setup(void)
+{
+ epoll_pwait_info();
+
+ SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd);
+
+ efd = epoll_create(1);
+ if (efd == -1)
+ tst_brk(TBROK | TERRNO, "epoll_create()");
+
+ e.events = EPOLLIN;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+ SAFE_WRITE(1, sfd[1], "w", 1);
+}
+
+static void cleanup(void)
+{
+ if (efd > 0)
+ SAFE_CLOSE(efd);
+
+ if (sfd[0] > 0)
+ SAFE_CLOSE(sfd[0]);
+
+ if (sfd[1] > 0)
+ SAFE_CLOSE(sfd[1]);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .test_variants = TEST_VARIANTS,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 5/5 v2] epoll_pwait: Add test for epoll_pwait03
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
` (3 preceding siblings ...)
2021-07-16 10:22 ` [LTP] [PATCH 4/5 v2] epoll_pwait: Add test for epoll_pwait02 Xie Ziyao
@ 2021-07-16 10:22 ` Xie Ziyao
2021-07-19 13:45 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Cyril Hrubis
5 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-16 10:22 UTC (permalink / raw)
To: ltp
Check that epoll_pwait/epoll_pwait2 timeout correctly.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
v1->v2:
1. Add test variants to switch between epoll_pwait and epoll_pwait2.
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_pwait/.gitignore | 1 +
.../syscalls/epoll_pwait/epoll_pwait03.c | 74 +++++++++++++++++++
3 files changed, 76 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index bed224809..1deb6118f 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -167,6 +167,7 @@ epoll_wait02 epoll_wait02
epoll_wait03 epoll_wait03
epoll_pwait01 epoll_pwait01
epoll_pwait02 epoll_pwait02
+epoll_pwait03 epoll_pwait03
eventfd01 eventfd01
diff --git a/testcases/kernel/syscalls/epoll_pwait/.gitignore b/testcases/kernel/syscalls/epoll_pwait/.gitignore
index ab049f173..1d16367e6 100644
--- a/testcases/kernel/syscalls/epoll_pwait/.gitignore
+++ b/testcases/kernel/syscalls/epoll_pwait/.gitignore
@@ -1,2 +1,3 @@
epoll_pwait01
epoll_pwait02
+epoll_pwait03
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
new file mode 100644
index 000000000..ec3b9579d
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
@@ -0,0 +1,74 @@
+// 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_pwait and epoll_pwait2 timeout correctly.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_timer_test.h"
+#include "epoll_pwait_var.h"
+
+#define USEC_PER_MSEC (1000L)
+
+static int efd, sfd[2];
+static struct epoll_event e;
+
+int sample_fn(int clk_id, long long usec)
+{
+ unsigned int ms = usec / USEC_PER_MSEC;
+
+ tst_timer_start(clk_id);
+ TEST(do_epoll_pwait(efd, &e, 1, ms, NULL));
+ tst_timer_stop();
+ tst_timer_sample();
+
+ if (TST_RET != 0) {
+ tst_res(TFAIL | TTERRNO,
+ "do_epoll_pwait() returned %li, expected 0", TST_RET);
+ return 1;
+ }
+
+ return 0;
+}
+
+static void setup(void)
+{
+ epoll_pwait_info();
+
+ SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd);
+
+ efd = epoll_create(1);
+ if (efd == -1)
+ tst_brk(TBROK | TERRNO, "epoll_create()");
+
+ e.events = EPOLLIN;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+}
+
+static void cleanup(void)
+{
+ if (efd > 0)
+ SAFE_CLOSE(efd);
+
+ if (sfd[0] > 0)
+ SAFE_CLOSE(sfd[0]);
+
+ if (sfd[1] > 0)
+ SAFE_CLOSE(sfd[1]);
+}
+
+static struct tst_test test = {
+ .scall = "do_epoll_pwait()",
+ .sample = sample_fn,
+ .setup = setup,
+ .cleanup = cleanup,
+ .test_variants = TEST_VARIANTS,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
` (4 preceding siblings ...)
2021-07-16 10:22 ` [LTP] [PATCH 5/5 v2] epoll_pwait: Add test for epoll_pwait03 Xie Ziyao
@ 2021-07-19 13:45 ` Cyril Hrubis
2021-07-20 6:57 ` Xie Ziyao
5 siblings, 1 reply; 15+ messages in thread
From: Cyril Hrubis @ 2021-07-19 13:45 UTC (permalink / raw)
To: ltp
Hi!
Pushed with minor changes, thanks.
* Changed the include in lapi/epoll.h to tst_timer.h
* Added better description to epoll_wait02
Also it would be nice to convert the epoll_pwait01.c to the variants as
well...
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2
2021-07-19 13:45 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Cyril Hrubis
@ 2021-07-20 6:57 ` Xie Ziyao
0 siblings, 0 replies; 15+ messages in thread
From: Xie Ziyao @ 2021-07-20 6:57 UTC (permalink / raw)
To: ltp
Hi, Cyril,
> Pushed with minor changes, thanks.
>
> * Changed the include in lapi/epoll.h to tst_timer.h
>
> * Added better description to epoll_wait02
>
Looks good. Thanks for your modifications.
>
> Also it would be nice to convert the epoll_pwait01.c to the variants as
> well...
>
OK, I'll fix it.
Thanks for your review.
Kind Regards,
Ziyao
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-07-20 6:57 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 8:04 [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 1/3] lapi/syscalls: Add syscall number " Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 2/3] epoll_pwait2: Add test for epoll_pwait201 Xie Ziyao
2021-07-12 12:23 ` Cyril Hrubis
2021-07-16 10:22 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 1/5 v2] lapi/syscalls: Add syscall number " Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 2/5 v2] lapi: Add the prototype for epoll_pwait and epoll_pwait2 Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 3/5 v2] epoll_pwait: Add test variants for epoll_pwait Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 4/5 v2] epoll_pwait: Add test for epoll_pwait02 Xie Ziyao
2021-07-16 10:22 ` [LTP] [PATCH 5/5 v2] epoll_pwait: Add test for epoll_pwait03 Xie Ziyao
2021-07-19 13:45 ` [LTP] [PATCH 0/5 v2] epoll_pwait2: Add test for epoll_pwait2 Cyril Hrubis
2021-07-20 6:57 ` Xie Ziyao
2021-06-28 8:04 ` [LTP] [PATCH 3/3] epoll_pwait2: Add test for epoll_pwait202 Xie Ziyao
2021-07-12 12:25 ` Cyril Hrubis
2021-06-28 8:12 ` [LTP] [PATCH 0/3] epoll_pwait2: Add test for epoll_pwait2 Xie Ziyao
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.