syscalls/pidfd_open
A message that is not in the archive (sent off-list or not yet received): 007f89609cfe05cc4f7f0f310f05fc4bb0be829d.1580114160.git.viresh.kumar@linaro.org
PATCH v4 2/2 syscalls/pidfd_open
Add tests to check working of pidfd_open() syscall.
---V3->V4:
- Dropped duplicate headers
- Dropped local variable "fd" and used TST_RET directly.
- Handle failure tests with global variable
- Remove else part after creating child process
- Improved print messages
V2->V3:
- Add pidfd_open03 to syscalls and .gitignore files.
- Use TEST, tst_get_unused_pid, etc.
- Do the failure testing with help of array and .tcnt.
- Improved print messages.
- Removed useless comments.
- Few more minor changes.
V1->V2:
- New test to test failures
- Use SAFE_FORK, checkpoints, etc
- Print error numbers as well.
- Improved print messages.
configure.ac | 1 + include/lapi/pidfd_open.h | 24 ++++++++ runtest/syscalls | 4 ++ .../kernel/syscalls/pidfd_open/.gitignore | 3 + testcases/kernel/syscalls/pidfd_open/Makefile | 6 ++ .../kernel/syscalls/pidfd_open/pidfd_open01.c | 27 +++++++++ .../kernel/syscalls/pidfd_open/pidfd_open02.c | 58 +++++++++++++++++++ .../kernel/syscalls/pidfd_open/pidfd_open03.c | 57 ++++++++++++++++++ 8 files changed, 180 insertions(+) create mode 100644 include/lapi/pidfd_open.h create mode 100644 testcases/kernel/syscalls/pidfd_open/.gitignore create mode 100644 testcases/kernel/syscalls/pidfd_open/Makefile create mode 100644 testcases/kernel/syscalls/pidfd_open/pidfd_open01.c create mode 100644 testcases/kernel/syscalls/pidfd_open/pidfd_open02.c create mode 100644 testcases/kernel/syscalls/pidfd_open/pidfd_open03.c
configure.ac +1 -0
@@ -79,6 +79,7 @@ AC_CHECK_FUNCS([ \ mknodat \ name_to_handle_at \ openat \ + pidfd_open \ pidfd_send_signal \ pkey_mprotect \ preadv \
include/lapi/pidfd_open.h new file +24 -0
@@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Linaro Limited. All rights reserved. +* Author: Viresh Kumar <[email protected]> +*/ + +#ifndef PIDFD_OPEN_H +#define PIDFD_OPEN_H + +#include <sys/syscall.h> +#include <sys/types.h> + +#include "lapi/syscalls.h" + +#include "config.h" + +#ifndef HAVE_PIDFD_OPEN +int pidfd_open (pid_t pid,unsigned int flags) +{ +return tst_syscall (__NR_pidfd_open, pid, flags); +} +#endif + +#endif /* PIDFD_OPEN_H */
runtest/syscalls +4 -0
@@ -848,6 +848,10 @@ pause03 pause03 personality01 personality01 personality02 personality02 +pidfd_open01 pidfd_open01 +pidfd_open02 pidfd_open02 +pidfd_open03 pidfd_open03 + pidfd_send_signal01 pidfd_send_signal01 pidfd_send_signal02 pidfd_send_signal02 pidfd_send_signal03 pidfd_send_signal03
testcases/kernel/syscalls/pidfd_open/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +pidfd_open01 +pidfd_open02 +pidfd_open03
testcases/kernel/syscalls/pidfd_open/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/pidfd_open/pidfd_open01.c new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic pidfd_open() test, fetches the PID of the current process and tries to +* get its file descriptor. +*/ +#include "tst_test.h" +#include "lapi/pidfd_open.h" + +static void run (void ) +{ +TEST (pidfd_open (getpid (),0 )); + +if (TST_RET ==-1 ) +tst_brk (TFAIL |TTERRNO ,"pidfd_open(getpid(), 0) failed" ); + +SAFE_CLOSE (TST_RET ); + +tst_res (TPASS ,"pidfd_open(getpid(), 0) passed" ); +} + +static struct tst_test test = { + .min_kver ="5.3" , + .test_all = run, +};
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c new file +58 -0
58 lines not on this page · raw message
testcases/kernel/syscalls/pidfd_open/pidfd_open03.c new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v4 2/2 syscalls/pidfd_open
Quoted 10 lines · Viresh Kumar
Add tests to check working of
pidfd_open()syscall.Signed-off-by Viresh Kumar <[email protected]>---
V3->V4:
- Dropped duplicate headers
- Dropped local variable "fd" and usedTST_RETdirectly.
- Handle failure tests with global variable
- Remove else part after creating child process
- Improved print messages
Cyril,
I did send this email with
--in-reply-to="8dc3dff0390db58b2f472501c30595647a913e34.1579858930.git.viresh.kumar@linaro.org"
so it appear in earlier thread. But git didn't work the way I expected and so it shows this as a new thread now.
I created two patches (so this patch's header already had -in-reply-to set to the 1st patch), and sent only the second with with explicit --in-reply-to field, which in my expectations should have overridden the setting that were their in patch's header but it didn't :(
Sorry about that. I am not re-sending it for now to avoid unnecessary traffic.
Signature · 1 line
viresh
PATCH v4 2/2 syscalls/pidfd_open
In reply to Viresh KumarHi!
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c line 11
Quoted 4 lines
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c new file +4
-0+#include "tst_test.h" +#include "lapi/pidfd_open.h" + +#define INVALID_PID -1
I've removed this now unused macro and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]