All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] tests: move common definitions and functions into pidfd.h
@ 2019-07-26 16:22 Suren Baghdasaryan
  2019-07-26 16:22 ` [PATCH v3 2/2] tests: add pidfd poll tests Suren Baghdasaryan
  2019-08-06 17:50 ` [PATCH v3 1/2] tests: move common definitions and functions into pidfd.h Christian Brauner
  0 siblings, 2 replies; 9+ messages in thread
From: Suren Baghdasaryan @ 2019-07-26 16:22 UTC (permalink / raw)
  To: surenb
  Cc: christian, arnd, ebiederm, keescook, joel, dancol, tglx, jannh,
	dhowells, mtk.manpages, luto, akpm, oleg, cyphar, torvalds, viro,
	linux-api, linux-kselftest, kernel-team

Move definitions and functions used across different pidfd tests into
pidfd.h header.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Christian Brauner <christian@brauner.io>
---
Changes since v1 (https://lore.kernel.org/linux-kselftest/20190723173907.196488-1-surenb@google.com)
	- Move common test definitions and functions into pidfd.h as per Christian Brauner
	- Code cleanup and additional error handling as per Christian Brauner
Changes since v2 (https://lore.kernel.org/linux-kselftest/20190725002204.185225-2-surenb@google.com)
	- Added waitpid to prevent zombies as per Yann Droneaud

Patches are based on v5.3-rc1 in Linus' tree.
---
 tools/testing/selftests/pidfd/pidfd.h          | 18 ++++++++++++++++++
 .../testing/selftests/pidfd/pidfd_open_test.c  |  5 -----
 tools/testing/selftests/pidfd/pidfd_test.c     | 10 ----------
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
index 8452e910463f..db4377af6be7 100644
--- a/tools/testing/selftests/pidfd/pidfd.h
+++ b/tools/testing/selftests/pidfd/pidfd.h
@@ -16,6 +16,14 @@
 
 #include "../kselftest.h"
 
+#ifndef __NR_pidfd_open
+#define __NR_pidfd_open -1
+#endif
+
+#ifndef __NR_pidfd_send_signal
+#define __NR_pidfd_send_signal -1
+#endif
+
 /*
  * The kernel reserves 300 pids via RESERVED_PIDS in kernel/pid.c
  * That means, when it wraps around any pid < 300 will be skipped.
@@ -53,5 +61,15 @@ int wait_for_pid(pid_t pid)
 	return WEXITSTATUS(status);
 }
 
+static inline int sys_pidfd_open(pid_t pid, unsigned int flags)
+{
+	return syscall(__NR_pidfd_open, pid, flags);
+}
+
+static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
+					unsigned int flags)
+{
+	return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
+}
 
 #endif /* __PIDFD_H */
diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c b/tools/testing/selftests/pidfd/pidfd_open_test.c
index 0377133dd6dc..b9fe75fc3e51 100644
--- a/tools/testing/selftests/pidfd/pidfd_open_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_open_test.c
@@ -22,11 +22,6 @@
 #include "pidfd.h"
 #include "../kselftest.h"
 
-static inline int sys_pidfd_open(pid_t pid, unsigned int flags)
-{
-	return syscall(__NR_pidfd_open, pid, flags);
-}
-
 static int safe_int(const char *numstr, int *converted)
 {
 	char *err = NULL;
diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c
index 7eaa8a3de262..17b2fd621726 100644
--- a/tools/testing/selftests/pidfd/pidfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_test.c
@@ -21,10 +21,6 @@
 #include "pidfd.h"
 #include "../kselftest.h"
 
-#ifndef __NR_pidfd_send_signal
-#define __NR_pidfd_send_signal -1
-#endif
-
 #define str(s) _str(s)
 #define _str(s) #s
 #define CHILD_THREAD_MIN_WAIT 3 /* seconds */
@@ -47,12 +43,6 @@ static pid_t pidfd_clone(int flags, int *pidfd, int (*fn)(void *))
 #endif
 }
 
-static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
-					unsigned int flags)
-{
-	return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
-}
-
 static int signal_received;
 
 static void set_signal_received_on_sigusr1(int sig)
-- 
2.22.0.709.g102302147b-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-08-06 18:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-26 16:22 [PATCH v3 1/2] tests: move common definitions and functions into pidfd.h Suren Baghdasaryan
2019-07-26 16:22 ` [PATCH v3 2/2] tests: add pidfd poll tests Suren Baghdasaryan
2019-07-26 17:07   ` Joel Fernandes
2019-07-26 17:24     ` Suren Baghdasaryan
2019-07-27  8:41     ` Christian Brauner
2019-07-27 18:24   ` Yann Droneaud
2019-08-06 18:03     ` Suren Baghdasaryan
2019-08-06 17:51   ` Christian Brauner
2019-08-06 17:50 ` [PATCH v3 1/2] tests: move common definitions and functions into pidfd.h Christian Brauner

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.