* [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() [not found] <20260714100738.7745-1-gang.yan@linux.dev> @ 2026-07-14 10:07 ` Gang Yan 2026-07-14 10:18 ` gang.yan 0 siblings, 1 reply; 3+ messages in thread From: Gang Yan @ 2026-07-14 10:07 UTC (permalink / raw) To: ltp; +Cc: Gang Yan From: Gang Yan <yangang@kylinos.cn> If some feature is not supported by some arch, like _NR__memfd_secret, it will become -1. And the syscall can continue with '-1' and the output would be: ''' accept03.c:47: TFAIL: accept() on memfd secret expected ENOTSOCK: EBADF (9) tst_fd.c:307: TBROK: close(38) failed: EBADF(9) ''' This patch use tst_syscall to give a more specific fail reason: ''' tst_fd.c:262: TCONF: Skipping memfd secret: ENOSYS(38) ''' Signed-off-by: Gang Yan <yangang@kylinos.cn> --- lib/tst_fd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/tst_fd.c b/lib/tst_fd.c index 6538a098c..1d90505b2 100644 --- a/lib/tst_fd.c +++ b/lib/tst_fd.c @@ -139,14 +139,14 @@ static void open_timerfd(struct tst_fd *fd) static void open_pidfd(struct tst_fd *fd) { - fd->fd = syscall(__NR_pidfd_open, getpid(), 0); + fd->fd = tst_syscall_base(__NR_pidfd_open, getpid(), 0); if (fd->fd < 0) tst_res(TCONF | TERRNO, "pidfd_open()"); } static void open_fanotify(struct tst_fd *fd) { - fd->fd = syscall(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY); + fd->fd = tst_syscall_base(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -164,7 +164,7 @@ static void open_inotify(struct tst_fd *fd) static void open_userfaultfd(struct tst_fd *fd) { - fd->fd = syscall(__NR_userfaultfd, 0); + fd->fd = tst_syscall_base(__NR_userfaultfd, 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, @@ -183,7 +183,7 @@ static void open_perf_event(struct tst_fd *fd) .exclude_hv = 1, }; - fd->fd = syscall(__NR_perf_event_open, &pe_attr, 0, -1, -1, 0); + fd->fd = tst_syscall_base(__NR_perf_event_open, &pe_attr, 0, -1, -1, 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -194,7 +194,7 @@ static void open_io_uring(struct tst_fd *fd) { struct io_uring_params uring_params = {}; - fd->fd = syscall(__NR_io_uring_setup, 1, &uring_params); + fd->fd = tst_syscall_base(__NR_io_uring_setup, 1, &uring_params); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -210,7 +210,7 @@ static void open_bpf_map(struct tst_fd *fd) .max_entries = 1, }; - fd->fd = syscall(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr)); + fd->fd = tst_syscall_base(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr)); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -219,7 +219,7 @@ static void open_bpf_map(struct tst_fd *fd) static void open_fsopen(struct tst_fd *fd) { - fd->fd = syscall(__NR_fsopen, "ext2", 0); + fd->fd = tst_syscall_base(__NR_fsopen, "ext2", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -228,7 +228,7 @@ static void open_fsopen(struct tst_fd *fd) static void open_fspick(struct tst_fd *fd) { - fd->fd = syscall(__NR_fspick, AT_FDCWD, "/", 0); + fd->fd = tst_syscall_base(__NR_fspick, AT_FDCWD, "/", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -237,7 +237,7 @@ static void open_fspick(struct tst_fd *fd) static void open_open_tree(struct tst_fd *fd) { - fd->fd = syscall(__NR_open_tree, AT_FDCWD, "/", 0); + fd->fd = tst_syscall_base(__NR_open_tree, AT_FDCWD, "/", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -246,7 +246,7 @@ static void open_open_tree(struct tst_fd *fd) static void open_memfd(struct tst_fd *fd) { - fd->fd = syscall(__NR_memfd_create, "ltp_memfd", 0); + fd->fd = tst_syscall_base(__NR_memfd_create, "ltp_memfd", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -255,7 +255,7 @@ static void open_memfd(struct tst_fd *fd) static void open_memfd_secret(struct tst_fd *fd) { - fd->fd = syscall(__NR_memfd_secret, 0); + fd->fd = tst_syscall_base(__NR_memfd_secret, 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() 2026-07-14 10:07 ` [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() Gang Yan @ 2026-07-14 10:18 ` gang.yan 0 siblings, 0 replies; 3+ messages in thread From: gang.yan @ 2026-07-14 10:18 UTC (permalink / raw) To: ltp July 14, 2026 at 6:07 PM, "Gang Yan" <gang.yan@linux.dev mailto:gang.yan@linux.dev?to=%22Gang%20Yan%22%20%3Cgang.yan%40linux.dev%3E > wrote: Hi, Sorry for this broken message, please ignore it. I've resent the patch series. Thanks, Gang > > From: Gang Yan <yangang@kylinos.cn> > > If some feature is not supported by some arch, like _NR__memfd_secret, > it will become -1. And the syscall can continue with '-1' and the output > would be: > > ''' > accept03.c:47: TFAIL: accept() on memfd secret expected ENOTSOCK: EBADF (9) > tst_fd.c:307: TBROK: close(38) failed: EBADF(9) > ''' > > This patch use tst_syscall to give a more specific fail reason: > > ''' > tst_fd.c:262: TCONF: Skipping memfd secret: ENOSYS(38) > ''' > > Signed-off-by: Gang Yan <yangang@kylinos.cn> > --- > lib/tst_fd.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > > diff --git a/lib/tst_fd.c b/lib/tst_fd.c > index 6538a098c..1d90505b2 100644 > --- a/lib/tst_fd.c > +++ b/lib/tst_fd.c > @@ -139,14 +139,14 @@ static void open_timerfd(struct tst_fd *fd) > > static void open_pidfd(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_pidfd_open, getpid(), 0); > + fd->fd = tst_syscall_base(__NR_pidfd_open, getpid(), 0); > if (fd->fd < 0) > tst_res(TCONF | TERRNO, "pidfd_open()"); > } > > static void open_fanotify(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY); > + fd->fd = tst_syscall_base(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -164,7 +164,7 @@ static void open_inotify(struct tst_fd *fd) > > static void open_userfaultfd(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_userfaultfd, 0); > + fd->fd = tst_syscall_base(__NR_userfaultfd, 0); > > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > @@ -183,7 +183,7 @@ static void open_perf_event(struct tst_fd *fd) > .exclude_hv = 1, > }; > > - fd->fd = syscall(__NR_perf_event_open, &pe_attr, 0, -1, -1, 0); > + fd->fd = tst_syscall_base(__NR_perf_event_open, &pe_attr, 0, -1, -1, 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -194,7 +194,7 @@ static void open_io_uring(struct tst_fd *fd) > { > struct io_uring_params uring_params = {}; > > - fd->fd = syscall(__NR_io_uring_setup, 1, &uring_params); > + fd->fd = tst_syscall_base(__NR_io_uring_setup, 1, &uring_params); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -210,7 +210,7 @@ static void open_bpf_map(struct tst_fd *fd) > .max_entries = 1, > }; > > - fd->fd = syscall(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr)); > + fd->fd = tst_syscall_base(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr)); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -219,7 +219,7 @@ static void open_bpf_map(struct tst_fd *fd) > > static void open_fsopen(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_fsopen, "ext2", 0); > + fd->fd = tst_syscall_base(__NR_fsopen, "ext2", 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -228,7 +228,7 @@ static void open_fsopen(struct tst_fd *fd) > > static void open_fspick(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_fspick, AT_FDCWD, "/", 0); > + fd->fd = tst_syscall_base(__NR_fspick, AT_FDCWD, "/", 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -237,7 +237,7 @@ static void open_fspick(struct tst_fd *fd) > > static void open_open_tree(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_open_tree, AT_FDCWD, "/", 0); > + fd->fd = tst_syscall_base(__NR_open_tree, AT_FDCWD, "/", 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -246,7 +246,7 @@ static void open_open_tree(struct tst_fd *fd) > > static void open_memfd(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_memfd_create, "ltp_memfd", 0); > + fd->fd = tst_syscall_base(__NR_memfd_create, "ltp_memfd", 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > @@ -255,7 +255,7 @@ static void open_memfd(struct tst_fd *fd) > > static void open_memfd_secret(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_memfd_secret, 0); > + fd->fd = tst_syscall_base(__NR_memfd_secret, 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); > -- > 2.43.0 > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp > -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH 0/3] tst_fd.c: fix test_failures on loongarch's old
@ 2026-07-14 10:14 Gang Yan
2026-07-14 10:14 ` [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() Gang Yan
0 siblings, 1 reply; 3+ messages in thread
From: Gang Yan @ 2026-07-14 10:14 UTC (permalink / raw)
To: ltp; +Cc: Gang Yan
From: Gang Yan <yangang@kylinos.cn>
Patch1 fixes LTP tst_fd/accept03 test failures on LoongArch64
introduced after commit 209f0c6360da ("Update arch(s) syscalls files")
removed memfd_secret syscall number from loongarch64 syscall table.
Patch 2-3 refactors LTP syscall helper to properly handle missing
syscalls without unexpected TBROK/TFAIL errors.
Gang Yan (3):
loongarch.in: add memfd_secret syscall
generate_syscall.sh: add a helper named tst_syscall_base
tst_fd.c: replace syscall() with tst_syscall_base()
include/lapi/syscalls/generate_syscalls.sh | 27 +++++++++++++---------
include/lapi/syscalls/loongarch64.in | 1 +
lib/tst_fd.c | 22 +++++++++---------
3 files changed, 28 insertions(+), 22 deletions(-)
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread* [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() 2026-07-14 10:14 [LTP] [PATCH 0/3] tst_fd.c: fix test_failures on loongarch's old Gang Yan @ 2026-07-14 10:14 ` Gang Yan 0 siblings, 0 replies; 3+ messages in thread From: Gang Yan @ 2026-07-14 10:14 UTC (permalink / raw) To: ltp; +Cc: Gang Yan From: Gang Yan <yangang@kylinos.cn> If some feature is not supported by some arch, like _NR__memfd_secret, it will become -1. And the syscall can continue with '-1' and the output would be: ''' accept03.c:47: TFAIL: accept() on memfd secret expected ENOTSOCK: EBADF (9) tst_fd.c:307: TBROK: close(38) failed: EBADF(9) ''' This patch use tst_syscall to give a more specific fail reason: ''' tst_fd.c:262: TCONF: Skipping memfd secret: ENOSYS(38) ''' Signed-off-by: Gang Yan <yangang@kylinos.cn> --- lib/tst_fd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/tst_fd.c b/lib/tst_fd.c index 6538a098c..1d90505b2 100644 --- a/lib/tst_fd.c +++ b/lib/tst_fd.c @@ -139,14 +139,14 @@ static void open_timerfd(struct tst_fd *fd) static void open_pidfd(struct tst_fd *fd) { - fd->fd = syscall(__NR_pidfd_open, getpid(), 0); + fd->fd = tst_syscall_base(__NR_pidfd_open, getpid(), 0); if (fd->fd < 0) tst_res(TCONF | TERRNO, "pidfd_open()"); } static void open_fanotify(struct tst_fd *fd) { - fd->fd = syscall(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY); + fd->fd = tst_syscall_base(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -164,7 +164,7 @@ static void open_inotify(struct tst_fd *fd) static void open_userfaultfd(struct tst_fd *fd) { - fd->fd = syscall(__NR_userfaultfd, 0); + fd->fd = tst_syscall_base(__NR_userfaultfd, 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, @@ -183,7 +183,7 @@ static void open_perf_event(struct tst_fd *fd) .exclude_hv = 1, }; - fd->fd = syscall(__NR_perf_event_open, &pe_attr, 0, -1, -1, 0); + fd->fd = tst_syscall_base(__NR_perf_event_open, &pe_attr, 0, -1, -1, 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -194,7 +194,7 @@ static void open_io_uring(struct tst_fd *fd) { struct io_uring_params uring_params = {}; - fd->fd = syscall(__NR_io_uring_setup, 1, &uring_params); + fd->fd = tst_syscall_base(__NR_io_uring_setup, 1, &uring_params); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -210,7 +210,7 @@ static void open_bpf_map(struct tst_fd *fd) .max_entries = 1, }; - fd->fd = syscall(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr)); + fd->fd = tst_syscall_base(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr)); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -219,7 +219,7 @@ static void open_bpf_map(struct tst_fd *fd) static void open_fsopen(struct tst_fd *fd) { - fd->fd = syscall(__NR_fsopen, "ext2", 0); + fd->fd = tst_syscall_base(__NR_fsopen, "ext2", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -228,7 +228,7 @@ static void open_fsopen(struct tst_fd *fd) static void open_fspick(struct tst_fd *fd) { - fd->fd = syscall(__NR_fspick, AT_FDCWD, "/", 0); + fd->fd = tst_syscall_base(__NR_fspick, AT_FDCWD, "/", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -237,7 +237,7 @@ static void open_fspick(struct tst_fd *fd) static void open_open_tree(struct tst_fd *fd) { - fd->fd = syscall(__NR_open_tree, AT_FDCWD, "/", 0); + fd->fd = tst_syscall_base(__NR_open_tree, AT_FDCWD, "/", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -246,7 +246,7 @@ static void open_open_tree(struct tst_fd *fd) static void open_memfd(struct tst_fd *fd) { - fd->fd = syscall(__NR_memfd_create, "ltp_memfd", 0); + fd->fd = tst_syscall_base(__NR_memfd_create, "ltp_memfd", 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); @@ -255,7 +255,7 @@ static void open_memfd(struct tst_fd *fd) static void open_memfd_secret(struct tst_fd *fd) { - fd->fd = syscall(__NR_memfd_secret, 0); + fd->fd = tst_syscall_base(__NR_memfd_secret, 0); if (fd->fd < 0) { tst_res(TCONF | TERRNO, "Skipping %s", tst_fd_desc(fd)); -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-14 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260714100738.7745-1-gang.yan@linux.dev>
2026-07-14 10:07 ` [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() Gang Yan
2026-07-14 10:18 ` gang.yan
2026-07-14 10:14 [LTP] [PATCH 0/3] tst_fd.c: fix test_failures on loongarch's old Gang Yan
2026-07-14 10:14 ` [LTP] [PATCH 3/3] tst_fd.c: replace syscall() with tst_syscall_base() Gang Yan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox