* [LTP] [PATCH 1/4 v2] api: Add a IS_BIT_SET() macro in tst_bitmap.h
[not found] <20210825153932.138396-1-ziyaoxie@outlook.com>
@ 2021-08-25 15:39 ` Xie Ziyao
2021-08-26 15:29 ` Cyril Hrubis
2021-08-25 15:39 ` [LTP] [PATCH 2/4 v2] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Xie Ziyao @ 2021-08-25 15:39 UTC (permalink / raw)
To: ltp
From: "Xie Ziyao" <ziyaoxie@outlook.com>
Add a IS_BIT_SET() macro in tst_bitmap.h to check whether the n-th bit
of val is set.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <ziyaoxie@outlook.com>
---
v1->v2:
1. Add a IS_BIT_SET() macro in tst_bitmap.h.
include/tst_bitmap.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 include/tst_bitmap.h
diff --git a/include/tst_bitmap.h b/include/tst_bitmap.h
new file mode 100644
index 000000000..528a2bdaa
--- /dev/null
+++ b/include/tst_bitmap.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright (c) Linux Test Project, 2021
+ * Author: Xie Ziyao <ziyaoxie@outlook.com>
+ */
+
+#ifndef TST_BITMAP_H__
+#define TST_BITMAP_H__
+
+/*
+ * Check whether the n-th bit of val is set
+ * @return 0: the n-th bit of val is 0, 1: the n-th bit of val is 1
+ */
+#define IS_BIT_SET(val, n) (((val) & (1<<(n))) >> (n))
+
+#endif /* TST_BITMAP_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/4 v2] epoll_ctl: Add test for epoll_ctl03
[not found] <20210825153932.138396-1-ziyaoxie@outlook.com>
2021-08-25 15:39 ` [LTP] [PATCH 1/4 v2] api: Add a IS_BIT_SET() macro in tst_bitmap.h Xie Ziyao
@ 2021-08-25 15:39 ` Xie Ziyao
2021-08-26 15:29 ` Cyril Hrubis
2021-08-25 15:39 ` [LTP] [PATCH 3/4 v2] epoll_create: Add test for epoll_create01 Xie Ziyao
2021-08-25 15:39 ` [LTP] [PATCH 4/4 v2] epoll_create: Add test for epoll_create02 Xie Ziyao
3 siblings, 1 reply; 7+ messages in thread
From: Xie Ziyao @ 2021-08-25 15:39 UTC (permalink / raw)
To: ltp
From: "Xie Ziyao" <ziyaoxie@outlook.com>
Check that epoll_ctl returns zero with different combinations of events on
success.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <ziyaoxie@outlook.com>
---
v1->v2:
1. Use IS_BIT_SET() macro to check whether the n-th bit of val is set.
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_ctl/.gitignore | 5 +-
.../kernel/syscalls/epoll_ctl/epoll_ctl03.c | 78 +++++++++++++++++++
3 files changed, 82 insertions(+), 2 deletions(-)
create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 6762a234c..f6fe140b2 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -161,6 +161,7 @@ epoll_create1_02 epoll_create1_02
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..df065c7c6
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Linux Test Project, 2021
+ * Author: Xie Ziyao <ziyaoxie@outlook.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"
+#include "tst_bitmap.h"
+
+#define NUM_EPOLL_EVENTS 8
+#define WIDTH_EPOLL_EVENTS 256
+
+static int epfd, fds[2];
+static struct epoll_event events = {.events = EPOLLIN};
+
+static unsigned int events_type[NUM_EPOLL_EVENTS] = {
+ EPOLLIN, EPOLLOUT, EPOLLPRI, EPOLLERR,
+ EPOLLHUP, EPOLLET, EPOLLONESHOT, EPOLLRDHUP
+};
+
+static void run_all(void)
+{
+ unsigned int i, j, events_bitmap;
+
+ for (i = 0; i < WIDTH_EPOLL_EVENTS; i++) {
+ events_bitmap = 0;
+
+ for (j = 0; j < NUM_EPOLL_EVENTS; j++)
+ events_bitmap |= (events_type[j] * IS_BIT_SET(i, j));
+
+ 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.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 3/4 v2] epoll_create: Add test for epoll_create01
[not found] <20210825153932.138396-1-ziyaoxie@outlook.com>
2021-08-25 15:39 ` [LTP] [PATCH 1/4 v2] api: Add a IS_BIT_SET() macro in tst_bitmap.h Xie Ziyao
2021-08-25 15:39 ` [LTP] [PATCH 2/4 v2] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
@ 2021-08-25 15:39 ` Xie Ziyao
2021-08-25 15:39 ` [LTP] [PATCH 4/4 v2] epoll_create: Add test for epoll_create02 Xie Ziyao
3 siblings, 0 replies; 7+ messages in thread
From: Xie Ziyao @ 2021-08-25 15:39 UTC (permalink / raw)
To: ltp
From: "Xie Ziyao" <ziyaoxie@outlook.com>
Verify that epoll_create return a nonnegative file descriptor on success.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Xie Ziyao <ziyaoxie@outlook.com>
---
v1->v2:
1. Use TST_EXP_FD() to check whether fd is valid.
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_create/.gitignore | 1 +
.../kernel/syscalls/epoll_create/Makefile | 9 +++++
.../syscalls/epoll_create/epoll_create01.c | 37 +++++++++++++++++++
4 files changed, 48 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..ad856cee4
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Linux Test Project, 2021
+# Author: Xie Ziyao <ziyaoxie@outlook.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..54fd0810d
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_create/epoll_create01.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Linux Test Project, 2021
+ * Author: Xie Ziyao <ziyaoxie@outlook.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)
+{
+ TST_EXP_FD(tst_syscall(__NR_epoll_create, tc[n]), "epoll_create(%d)", tc[n]);
+
+ if (!TST_PASS)
+ return;
+ SAFE_CLOSE(TST_PASS);
+}
+
+static struct tst_test test = {
+ .tcnt = ARRAY_SIZE(tc),
+ .test = run,
+};
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 4/4 v2] epoll_create: Add test for epoll_create02
[not found] <20210825153932.138396-1-ziyaoxie@outlook.com>
` (2 preceding siblings ...)
2021-08-25 15:39 ` [LTP] [PATCH 3/4 v2] epoll_create: Add test for epoll_create01 Xie Ziyao
@ 2021-08-25 15:39 ` Xie Ziyao
2021-08-26 15:35 ` Cyril Hrubis
3 siblings, 1 reply; 7+ messages in thread
From: Xie Ziyao @ 2021-08-25 15:39 UTC (permalink / raw)
To: ltp
From: "Xie Ziyao" <ziyaoxie@outlook.com>
Verify that epoll_create returns -1 and set errno to EINVAL if size is
not positive.
Signed-off-by: Xie Ziyao <ziyaoxie@outlook.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..00df07922
--- /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) Linux Test Project, 2021
+ * Author: Xie Ziyao <ziyaoxie@outlook.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.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 1/4 v2] api: Add a IS_BIT_SET() macro in tst_bitmap.h
2021-08-25 15:39 ` [LTP] [PATCH 1/4 v2] api: Add a IS_BIT_SET() macro in tst_bitmap.h Xie Ziyao
@ 2021-08-26 15:29 ` Cyril Hrubis
0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2021-08-26 15:29 UTC (permalink / raw)
To: ltp
Hi!
> Add a IS_BIT_SET() macro in tst_bitmap.h to check whether the n-th bit
> of val is set.
Since this has been put into the test library I've changed this to
TST_IS_BIT_SET() and pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/4 v2] epoll_ctl: Add test for epoll_ctl03
2021-08-25 15:39 ` [LTP] [PATCH 2/4 v2] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
@ 2021-08-26 15:29 ` Cyril Hrubis
0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2021-08-26 15:29 UTC (permalink / raw)
To: ltp
Hi!
> + TST_EXP_PASS(epoll_ctl(epfd, EPOLL_CTL_MOD, fds[0], &events),
> + "epoll_ctl(..., EPOLL_CTL_MOD, ...) with events.events=%x",
I've changed the %x to %08x to make the messages nicer and pushed,
thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 4/4 v2] epoll_create: Add test for epoll_create02
2021-08-25 15:39 ` [LTP] [PATCH 4/4 v2] epoll_create: Add test for epoll_create02 Xie Ziyao
@ 2021-08-26 15:35 ` Cyril Hrubis
0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2021-08-26 15:35 UTC (permalink / raw)
To: ltp
Hi!
> + * Verify that epoll_create returns -1 and set errno to EINVAL if size is not
> + * positive.
I've changed the 'positive' here to 'greater than zero' to make it
clearer.
And pushed the two test for epoll_create, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-08-26 15:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20210825153932.138396-1-ziyaoxie@outlook.com>
2021-08-25 15:39 ` [LTP] [PATCH 1/4 v2] api: Add a IS_BIT_SET() macro in tst_bitmap.h Xie Ziyao
2021-08-26 15:29 ` Cyril Hrubis
2021-08-25 15:39 ` [LTP] [PATCH 2/4 v2] epoll_ctl: Add test for epoll_ctl03 Xie Ziyao
2021-08-26 15:29 ` Cyril Hrubis
2021-08-25 15:39 ` [LTP] [PATCH 3/4 v2] epoll_create: Add test for epoll_create01 Xie Ziyao
2021-08-25 15:39 ` [LTP] [PATCH 4/4 v2] epoll_create: Add test for epoll_create02 Xie Ziyao
2021-08-26 15:35 ` 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.