Skip to contentSkip to conversation

api: Add a IS_BIT_SET() macro in tst_bitmap.h

PATCH New Xie Ziyao 2 participants 7 messages Aug 25, 2021 – Aug 26, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Xie Ziyao

author
#1 lore raw

PATCH v2 1/4 api: Add a IS_BIT_SET() macro in tst_bitmap.h

From: "Xie Ziyao" <[email protected]>

Add a IS_BIT_SET() macro in tst_bitmap.h to check whether the n-th bit of val is set.

---
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
include/tst_bitmap.h new file +15 -0
new file mode 100644
index 000000000..528a2bdaa
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright (c) Linux Test Project, 2021
+ * Author: Xie Ziyao <[email protected]>
+ */
+
+#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

#2 lore raw

PATCH v2 1/4 api: Add a IS_BIT_SET() macro in tst_bitmap.h

Hi!

Quoted 2 lines

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.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#3 lore raw

PATCH v2 2/4 epoll_ctl: Add test for epoll_ctl03

In reply to a message not in the archive

From: "Xie Ziyao" <[email protected]>

Check that epoll_ctl returns zero with different combinations of events on success.

---
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
runtest/syscalls +1 -0
index 6762a234c..f6fe140b2 100644
@@ -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
testcases/kernel/syscalls/epoll_ctl/.gitignore +3 -2
index 634470a06..2b50d924c 100644
@@ -1,2 +1,3 @@
-/epoll_ctl01
-/epoll_ctl02
+epoll_ctl01
+epoll_ctl02
+epoll_ctl03
testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c new file +78 -0

78 lines not on this page · raw message

--
2.25.1

#4 lore raw

PATCH v2 2/4 epoll_ctl: Add test for epoll_ctl03

Hi!

testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c line 43

Quoted 2 lines
testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c new file +2 -0
+		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.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#5 lore raw

PATCH v2 3/4 epoll_create: Add test for epoll_create01

In reply to a message not in the archive

From: "Xie Ziyao" <[email protected]>

Verify that epoll_create return a nonnegative file descriptor on success.

---
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
runtest/syscalls +1 -0
index f6fe140b2..2540905a0 100644
@@ -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
testcases/kernel/syscalls/epoll_create/.gitignore new file +1 -0
new file mode 100644
index 000000000..0ed4d940a
@@ -0,0 +1 @@
+epoll_create01
testcases/kernel/syscalls/epoll_create/Makefile new file +9 -0
new file mode 100644
index 000000000..ad856cee4
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Linux Test Project, 2021
+# Author: Xie Ziyao <[email protected]>
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/epoll_create/epoll_create01.c new file +37 -0
new file mode 100644
index 000000000..54fd0810d
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Linux Test Project, 2021
+ * Author: Xie Ziyao <[email protected]>
+ */
+
+/*\
+ * [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

author
#6 lore raw

PATCH v2 4/4 epoll_create: Add test for epoll_create02

In reply to a message not in the archive

From: "Xie Ziyao" <[email protected]>

Verify that epoll_create returns -1 and set errno to EINVAL if size is not positive.

---
 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
runtest/syscalls +1 -0
index 2540905a0..d5a1e86e8 100644
@@ -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
testcases/kernel/syscalls/epoll_create/.gitignore +1 -0
index 0ed4d940a..5c16cfa8c 100644
@@ -1 +1,2 @@
 epoll_create01
+epoll_create02
testcases/kernel/syscalls/epoll_create/epoll_create02.c new file +37 -0
new file mode 100644
index 000000000..00df07922
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Linux Test Project, 2021
+ * Author: Xie Ziyao <[email protected]>
+ */
+
+/*\
+ * [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

#7 lore raw

PATCH v2 4/4 epoll_create: Add test for epoll_create02

Hi!

Quoted 2 lines

+ * 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.

Signature · 2 lines
Cyril Hrubis
[email protected]