Skip to contentSkip to conversation

syscalls/epoll_create: Replace syscall to libc

PATCH zhaogongyi 1 participant 1 message Nov 5, 2021

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

Hi Cyril,

It looks good for me and I have resubmit the patch, please see: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Thanks so much!

Best Regards,
Gongyi

Quoted 98 lines

Hi!

Quoted 3 lines

For epoll_create01.c/epoll_create02.c, we should replace syscall to libc or the testcase will fail because of Syscall epoll_create is not support in some arches.

I guess that epoll_create() is emulated via epoll_create1() in these cases right?

Does these testcases fail in these cases though? The __NR_epoll_create should be set to -1 when the syscall is not supported and the test should be skipped with TCONF.

The patch looks good, however it would be slightly better to add test variants so that we call both the raw syscall, if available, and the glibc wrapper, with something as:

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(do_epoll_create(tc[n]) ...);

	...
}

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,
	...
};
Quoted 12 lines
---
 testcases/kernel/syscalls/epoll_create/epoll_create01.c | 2 +-
testcases/kernel/syscalls/epoll_create/epoll_create02.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/epoll_create/epoll_create01.c +0 -0
index 3ef5b5cac..b6ebe9ad7 100644

testcases/kernel/syscalls/epoll_create/epoll_create01.c static int tc[] = {1, INT_MAX}; · line 27

Quoted 4 lines
testcases/kernel/syscalls/epoll_create/epoll_create01.c +0 -1
@@ -24,7 +24,7 @@ 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]);

Quoted 21 lines
testcases/kernel/syscalls/epoll_create/epoll_create01.c +1 -0
+	TST_EXP_FD(epoll_create(tc[n]), "epoll_create(%d)", tc[n]);
 
 	if (!TST_PASS)
 		return;
testcases/kernel/syscalls/epoll_create/epoll_create02.c +1 -2
index c59ea7944..e96228983 100644
@@ -27,7 +27,7 @@ static struct test_case_t {
 
 static void run(unsigned int n)
 {
-	TST_EXP_FAIL(tst_syscall(__NR_epoll_create, tc[n].size),
+	TST_EXP_FAIL(epoll_create(tc[n].size),
 		     tc[n].exp_err, "create(%d)", tc[n].size);  }
 
--

2.17.1

Quoted 2 lines

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

--
Cyril Hrubis
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp