All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Gongyi <zhaogongyi@huawei.com>
To: <ltp@lists.linux.it>
Subject: [LTP] [PATCH v2] syscalls/epoll_create: add libc test for epoll_create
Date: Fri, 5 Nov 2021 10:07:29 +0800	[thread overview]
Message-ID: <20211105020729.162391-1-zhaogongyi@huawei.com> (raw)

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2021-11-05  2:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  2:07 Zhao Gongyi [this message]
2021-11-05  7:56 ` [LTP] [PATCH v2] syscalls/epoll_create: add libc test for epoll_create Petr Vorel
2021-11-05 11:54 ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211105020729.162391-1-zhaogongyi@huawei.com \
    --to=zhaogongyi@huawei.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.