[LTP] [PATCH v2] syscalls/epoll_create: add libc test for epoll_create

Zhao Gongyi zhaogongyi@huawei.com
Fri Nov 5 03:07:29 CET 2021


For epoll_create01.c/epoll_create02.c, we add libc epoll_create()
test because Syscall __NR_epoll_create is not support in some arches.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2: remain syscall test

 .../syscalls/epoll_create/epoll_create01.c    | 30 ++++++++++++++++--
 .../syscalls/epoll_create/epoll_create02.c    | 31 +++++++++++++++++--
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/epoll_create/epoll_create01.c b/testcases/kernel/syscalls/epoll_create/epoll_create01.c
index 3ef5b5cac..5b9b48e73 100644
--- a/testcases/kernel/syscalls/epoll_create/epoll_create01.c
+++ b/testcases/kernel/syscalls/epoll_create/epoll_create01.c
@@ -15,23 +15,49 @@
  */

 #include <sys/epoll.h>
-
 #include "tst_test.h"
 #include "lapi/epoll.h"
 #include "lapi/syscalls.h"

 static int tc[] = {1, INT_MAX};

+static int do_epoll_create(int size)
+{
+	switch (tst_variant) {
+	case 0:
+		return tst_syscall(__NR_epoll_create, size);
+	break;
+	case 1:
+		return epoll_create(size);
+	break;
+	}
+}
+
+
 static void run(unsigned int n)
 {
-	TST_EXP_FD(tst_syscall(__NR_epoll_create, tc[n]), "epoll_create(%d)", tc[n]);
+	TST_EXP_FD(do_epoll_create(tc[n]), "epoll_create(%d)", tc[n]);

 	if (!TST_PASS)
 		return;
 	SAFE_CLOSE(TST_RET);
 }

+static void setup(void)
+{
+	switch (tst_variant) {
+	case 0:
+		tst_res(TINFO, "Testing variant: syscall __NR_epoll_create");
+	break;
+	case 1:
+		tst_res(TINFO, "Testing variant: libc epoll_create()");
+	break;
+	}
+}
+
 static struct tst_test test = {
+	.test_variants = 2,
 	.tcnt = ARRAY_SIZE(tc),
+	.setup = setup,
 	.test = run,
 };
diff --git a/testcases/kernel/syscalls/epoll_create/epoll_create02.c b/testcases/kernel/syscalls/epoll_create/epoll_create02.c
index c59ea7944..f19d58882 100644
--- a/testcases/kernel/syscalls/epoll_create/epoll_create02.c
+++ b/testcases/kernel/syscalls/epoll_create/epoll_create02.c
@@ -25,13 +25,40 @@ static struct test_case_t {
 	{-1, EINVAL}
 };

+static int do_epoll_create(int size)
+{
+	switch (tst_variant) {
+	case 0:
+		return tst_syscall(__NR_epoll_create, size);
+	break;
+	case 1:
+		return epoll_create(size);
+	break;
+	}
+}
+
 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);
+	TST_EXP_FAIL(do_epoll_create(tc[n].size),
+		     tc[n].exp_err, "epoll_create(%d)", tc[n].size);
 }

+static void setup(void)
+{
+	switch (tst_variant) {
+	case 0:
+		tst_res(TINFO, "Testing variant: syscall __NR_epoll_create");
+	break;
+	case 1:
+		tst_res(TINFO, "Testing variant: libc epoll_create()");
+	break;
+	}
+}
+
+
 static struct tst_test test = {
+	.test_variants = 2,
 	.tcnt = ARRAY_SIZE(tc),
+	.setup = setup,
 	.test = run,
 };
--
2.17.1



More information about the ltp mailing list