[RFC PATCH 9/9] Add pidns test for a couple of syscalls

Ákos Uzonyi uzonyi.akos at gmail.com
Sat Jun 27 17:20:56 UTC 2020


---
 tests/.gitignore            |  7 +++++++
 tests/Makefile.am           |  7 +++++++
 tests/gen_tests.in          |  9 ++++++++-
 tests/kill-Y.c              |  2 ++
 tests/kill.c                | 15 +++++++++++----
 tests/pidfd_send_signal-Y.c |  2 ++
 tests/pidfd_send_signal.c   | 20 ++++++++++++++------
 tests/rt_sigqueueinfo-Y.c   |  2 ++
 tests/rt_sigqueueinfo.c     | 16 ++++++++++++----
 tests/rt_tgsigqueueinfo-Y.c |  2 ++
 tests/rt_tgsigqueueinfo.c   | 30 ++++++++++++++++++++----------
 tests/sched_xetaffinity-Y.c |  2 ++
 tests/sched_xetaffinity.c   | 29 ++++++++++++++++++-----------
 tests/xet_robust_list-Y.c   |  2 ++
 tests/xet_robust_list.c     | 21 +++++++++++++++------
 tests/xetpriority-Y.c       |  2 ++
 tests/xetpriority.c         | 22 +++++++++++++++++++---
 17 files changed, 145 insertions(+), 45 deletions(-)
 create mode 100644 tests/kill-Y.c
 create mode 100644 tests/pidfd_send_signal-Y.c
 create mode 100644 tests/rt_sigqueueinfo-Y.c
 create mode 100644 tests/rt_tgsigqueueinfo-Y.c
 create mode 100644 tests/sched_xetaffinity-Y.c
 create mode 100644 tests/xet_robust_list-Y.c
 create mode 100644 tests/xetpriority-Y.c

diff --git a/tests/.gitignore b/tests/.gitignore
index f9a4eae0..f850dff6 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -304,6 +304,7 @@ keyctl-Xabbrev
 keyctl-Xraw
 keyctl-Xverbose
 kill
+kill-Y
 kill_child
 ksysent
 ksysent.h
@@ -501,6 +502,7 @@ pidfd_open-P
 pidfd_open-y
 pidfd_open-yy
 pidfd_send_signal
+pidfd_send_signal-Y
 pidns
 pipe
 pipe2
@@ -591,10 +593,12 @@ rt_sigaction
 rt_sigpending
 rt_sigprocmask
 rt_sigqueueinfo
+rt_sigqueueinfo-Y
 rt_sigreturn
 rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
+rt_tgsigqueueinfo-Y
 run_expect_termsig
 s390_guarded_storage
 s390_guarded_storage-v
@@ -605,6 +609,7 @@ s390_sthyi-v
 sched_get_priority_mxx
 sched_rr_get_interval
 sched_xetaffinity
+sched_xetaffinity-Y
 sched_xetattr
 sched_xetparam
 sched_xetscheduler
@@ -773,9 +778,11 @@ waitpid
 xattr
 xattr-strings
 xet_robust_list
+xet_robust_list-Y
 xet_thread_area_x86
 xetitimer
 xetpgid
 xetpriority
+xetpriority-Y
 xettimeofday
 zeroargc
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7bd00631..c6ea20bd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -151,6 +151,7 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
 	ioctl_v4l2-success-v-Xverbose \
 	is_linux_mips_n64 \
 	kill_child \
+	kill-Y \
 	ksysent \
 	list_sigaction_signum \
 	localtime \
@@ -172,6 +173,7 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
 	pc \
 	perf_event_open_nonverbose \
 	perf_event_open_unabbrev \
+	pidfd_send_signal-Y \
 	poll-P \
 	ppoll-P \
 	ppoll-v \
@@ -193,7 +195,10 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
 	quotactl-xfs-v \
 	redirect-fds \
 	restart_syscall \
+	rt_sigqueueinfo-Y \
+	rt_tgsigqueueinfo-Y \
 	run_expect_termsig \
+	sched_xetaffinity-Y \
 	scm_rights \
 	seccomp-filter-v \
 	seccomp-strict \
@@ -222,6 +227,8 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
 	vfork-f \
 	wait4-v \
 	waitid-v \
+	xetpriority-Y \
+	xet_robust_list-Y \
 	zeroargc \
 	# end of check_PROGRAMS
 
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index e4d8663e..ee1cb957 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -279,6 +279,7 @@ keyctl-Xabbrev	-a31 -s10 -e trace=keyctl -Xabbrev
 keyctl-Xraw	-a13 -s10 -e trace=keyctl -Xraw
 keyctl-Xverbose	-a41 -s10 -e trace=keyctl -Xverbose
 kill	-a12 -esignal=none
+kill-Y	test_pidns -a12 -e trace=kill -esignal=none
 ksysent	../$NAME
 lchown	-a30
 lchown32	-a32
@@ -453,6 +454,7 @@ pidfd_open-P	-a17 -P /dev/full -e trace=pidfd_open
 pidfd_open-y	-a17 -y -e trace=pidfd_open
 pidfd_open-yy	-a17 -yy -e trace=pidfd_open
 pidfd_send_signal
+pidfd_send_signal-Y test_pidns -e trace=pidfd_send_signal
 pipe2	-a15
 pkey_alloc	-a17
 pkey_free	-a13
@@ -512,11 +514,13 @@ riscv_flush_icache	-a34
 rmdir	-a22
 rt_sigpending	-a20
 rt_sigprocmask
-rt_sigqueueinfo	-esignal=none
+rt_sigqueueinfo -esignal=none
+rt_sigqueueinfo-Y	test_pidns -esignal=none -e trace=rt_sigqueueinfo
 rt_sigreturn	-esignal='!USR1'
 rt_sigsuspend	-a20 -esignal=none
 rt_sigtimedwait	-a38
 rt_tgsigqueueinfo	-esignal=none
+rt_tgsigqueueinfo-Y	test_pidns -esignal=none -e trace=rt_tgsigqueueinfo
 s390_guarded_storage	-a32
 s390_guarded_storage-v	-e trace=s390_guarded_storage -a32 -v
 s390_pci_mmio_read_write	-e trace=s390_pci_mmio_read,s390_pci_mmio_write -a30
@@ -527,6 +531,7 @@ sched	test_trace_expr times -e/sched
 sched_get_priority_mxx	-a33 -e trace=sched_get_priority_min,sched_get_priority_max
 sched_rr_get_interval	-a31
 sched_xetaffinity	-a28 -e trace=sched_getaffinity,sched_setaffinity
+sched_xetaffinity-Y	test_pidns -a28 -e trace=sched_getaffinity,sched_setaffinity
 sched_xetattr	-a29 -e trace=sched_getattr,sched_setattr
 sched_xetparam	-a23 -e trace=sched_getparam,sched_setparam
 sched_xetscheduler	-a22 -e trace=sched_getscheduler,sched_setscheduler
@@ -714,7 +719,9 @@ waitpid	-a28
 xattr	-a22 -e trace=getxattr,fgetxattr,lgetxattr,setxattr,fsetxattr,lsetxattr,listxattr,flistxattr,llistxattr,removexattr,fremovexattr,lremovexattr
 xattr-strings	-a22 -s 4 -e trace=fsetxattr
 xet_robust_list	-a24 -e trace=get_robust_list,set_robust_list
+xet_robust_list-Y	test_pidns -a24 -e trace=get_robust_list,set_robust_list
 xetitimer	-a29 -e trace=setitimer,getitimer
 xetpgid	-a11 -e trace=getpgid,setpgid
 xetpriority	-a29 -e trace=getpriority,setpriority
+xetpriority-Y	test_pidns -a29 -e trace=getpriority,setpriority
 xettimeofday	-a20 -e trace=gettimeofday,settimeofday
diff --git a/tests/kill-Y.c b/tests/kill-Y.c
new file mode 100644
index 00000000..97f75a13
--- /dev/null
+++ b/tests/kill-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "kill.c"
diff --git a/tests/kill.c b/tests/kill.c
index f7d9341e..11554f81 100644
--- a/tests/kill.c
+++ b/tests/kill.c
@@ -9,8 +9,13 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
 #include "scno.h"
+#include "pidns.h"
 
 #ifdef __NR_kill
 
@@ -26,6 +31,8 @@ handler(int sig)
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	const struct sigaction act = { .sa_handler = handler };
 	if (sigaction(SIGALRM, &act, NULL))
 		perror_msg_and_fail("sigaction");
@@ -38,18 +45,18 @@ main(void)
 
 	const int pid = getpid();
 	long rc = syscall(__NR_kill, pid, (long) 0xdefaced00000000ULL | SIGALRM);
-	printf("kill(%d, SIGALRM) = %ld\n", pid, rc);
+	pidns_printf("kill(%d%s, SIGALRM) = %ld\n", pid, pidns_pid2str(PT_TGID), rc);
 
 	const long big_pid = (long) 0xfacefeedbadc0dedULL;
 	const long big_sig = (long) 0xdeadbeefcafef00dULL;
 	rc = syscall(__NR_kill, big_pid, big_sig);
-	printf("kill(%d, %d) = %ld %s (%m)\n",
+	pidns_printf("kill(%d, %d) = %ld %s (%m)\n",
 	       (int) big_pid, (int) big_sig, rc, errno2name());
 
 	rc = syscall(__NR_kill, (long) 0xdefaced00000000ULL | pid, 0);
-	printf("kill(%d, 0) = %ld\n", pid, rc);
+	pidns_printf("kill(%d%s, 0) = %ld\n", pid, pidns_pid2str(PT_TGID), rc);
 
-	puts("+++ exited with 0 +++");
+	pidns_printf("+++ exited with 0 +++\n");
 	return 0;
 }
 
diff --git a/tests/pidfd_send_signal-Y.c b/tests/pidfd_send_signal-Y.c
new file mode 100644
index 00000000..f5ac3bd9
--- /dev/null
+++ b/tests/pidfd_send_signal-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "pidfd_send_signal.c"
diff --git a/tests/pidfd_send_signal.c b/tests/pidfd_send_signal.c
index ca01c04a..b1c87889 100644
--- a/tests/pidfd_send_signal.c
+++ b/tests/pidfd_send_signal.c
@@ -7,9 +7,14 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
 #include <unistd.h>
 #include "scno.h"
+#include "pidns.h"
 
 #ifdef __NR_pidfd_send_signal
 
@@ -36,6 +41,8 @@ sys_pidfd_send_signal(int pidfd, int sig, const void *info, int flags)
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	static const char null_path[] = "/dev/null";
 
 	int fd = open(null_path, O_RDONLY);
@@ -46,20 +53,21 @@ main(void)
 	const void *esi = (const void *) si + 1;
 
 	sys_pidfd_send_signal(fd, SIGUSR1, esi, 0);
-	printf("pidfd_send_signal(%d, SIGUSR1, %p, 0) = %s\n",
+	pidns_printf("pidfd_send_signal(%d, SIGUSR1, %p, 0) = %s\n",
 	       fd, esi, errstr);
 
 	si->si_signo = SIGUSR1;
 	si->si_code = SI_QUEUE;
+	si->si_pid = getpid();
 
 	sys_pidfd_send_signal(fd, SIGUSR2, si, -1);
-	printf("pidfd_send_signal(%d, SIGUSR2, {si_signo=SIGUSR1"
-	       ", si_code=SI_QUEUE, si_errno=%u, si_pid=%d, si_uid=%u"
+	pidns_printf("pidfd_send_signal(%d, SIGUSR2, {si_signo=SIGUSR1"
+	       ", si_code=SI_QUEUE, si_errno=%u, si_pid=%d%s, si_uid=%u"
 	       ", si_value={int=%d, ptr=%p}}, %#x) = %s\n",
-	       fd, si->si_errno, si->si_pid, si->si_uid, si->si_int, si->si_ptr,
-	       -1, errstr);
+	       fd, si->si_errno, si->si_pid, pidns_pid2str(PT_TGID), si->si_uid,
+	       si->si_int, si->si_ptr, -1, errstr);
 
-	puts("+++ exited with 0 +++");
+	pidns_printf("+++ exited with 0 +++\n");
 	return 0;
 }
 
diff --git a/tests/rt_sigqueueinfo-Y.c b/tests/rt_sigqueueinfo-Y.c
new file mode 100644
index 00000000..124e5d38
--- /dev/null
+++ b/tests/rt_sigqueueinfo-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "rt_sigqueueinfo.c"
diff --git a/tests/rt_sigqueueinfo.c b/tests/rt_sigqueueinfo.c
index 0455dd40..bff80396 100644
--- a/tests/rt_sigqueueinfo.c
+++ b/tests/rt_sigqueueinfo.c
@@ -6,7 +6,12 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
+#include "pidns.h"
 #include <assert.h>
 #include <stdio.h>
 #include <signal.h>
@@ -15,6 +20,8 @@
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	struct sigaction sa = {
 		.sa_handler = SIG_IGN
 	};
@@ -26,11 +33,12 @@ main(void)
 	assert(sigaction(SIGUSR1, &sa, NULL) == 0);
 	if (sigqueue(pid, SIGUSR1, value))
 		perror_msg_and_skip("sigqueue");
-	printf("rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, "
-		"si_code=SI_QUEUE, si_pid=%u, si_uid=%u, "
+	pidns_printf("rt_sigqueueinfo(%d%s, SIGUSR1, {si_signo=SIGUSR1, "
+		"si_code=SI_QUEUE, si_pid=%d%s, si_uid=%u, "
 		"si_value={int=%d, ptr=%p}}) = 0\n",
-		pid, pid, getuid(), value.sival_int, value.sival_ptr);
-	printf("+++ exited with 0 +++\n");
+		pid, pidns_pid2str(PT_TGID), pid, pidns_pid2str(PT_TGID),
+		getuid(), value.sival_int, value.sival_ptr);
+	pidns_printf("+++ exited with 0 +++\n");
 
 	return 0;
 }
diff --git a/tests/rt_tgsigqueueinfo-Y.c b/tests/rt_tgsigqueueinfo-Y.c
new file mode 100644
index 00000000..4a91fbbb
--- /dev/null
+++ b/tests/rt_tgsigqueueinfo-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "rt_tgsigqueueinfo.c"
diff --git a/tests/rt_tgsigqueueinfo.c b/tests/rt_tgsigqueueinfo.c
index 658f1d31..a42b8820 100644
--- a/tests/rt_tgsigqueueinfo.c
+++ b/tests/rt_tgsigqueueinfo.c
@@ -8,10 +8,15 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
 #include "scno.h"
+#include "pidns.h"
 
-#ifdef __NR_rt_tgsigqueueinfo
+#if defined __NR_rt_tgsigqueueinfo && defined __NR_gettid
 
 # include <errno.h>
 # include <signal.h>
@@ -20,11 +25,11 @@
 # include <unistd.h>
 
 static long
-k_tgsigqueueinfo(const pid_t pid, const int sig, const void *const info)
+k_tgsigqueueinfo(const pid_t tgid, const int tid, const int sig, const void *const info)
 {
 	return syscall(__NR_rt_tgsigqueueinfo,
-		       F8ILL_KULONG_MASK | pid,
-		       F8ILL_KULONG_MASK | pid,
+		       F8ILL_KULONG_MASK | tgid,
+		       F8ILL_KULONG_MASK | tid,
 		       F8ILL_KULONG_MASK | sig,
 		       info);
 }
@@ -32,6 +37,8 @@ k_tgsigqueueinfo(const pid_t pid, const int sig, const void *const info)
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	const struct sigaction sa = {
 		.sa_handler = SIG_IGN
 	};
@@ -48,18 +55,21 @@ main(void)
 	info->si_value.sival_ptr =
 		(void *) (unsigned long) 0xdeadbeeffacefeedULL;
 
-	if (k_tgsigqueueinfo(info->si_pid, SIGUSR1, info))
+	if (k_tgsigqueueinfo(getpid(), syscall(__NR_gettid), SIGUSR1, info))
 		(errno == ENOSYS ? perror_msg_and_skip : perror_msg_and_fail)(
 			"rt_tgsigqueueinfo");
 
-	printf("rt_tgsigqueueinfo(%u, %u, %s, {si_signo=%s"
-		", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%u"
+	pidns_printf("rt_tgsigqueueinfo(%d%s, %d%s, %s, {si_signo=%s"
+		", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%d%s"
 		", si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\n",
-		info->si_pid, info->si_pid, "SIGUSR1", "SIGUSR1",
-		info->si_pid, info->si_uid, info->si_value.sival_int,
+		info->si_pid, pidns_pid2str(PT_TGID),
+		info->si_pid, pidns_pid2str(PT_TID),
+		"SIGUSR1", "SIGUSR1",
+		info->si_pid, pidns_pid2str(PT_TGID),
+		info->si_uid, info->si_value.sival_int,
 		info->si_value.sival_ptr);
 
-	puts("+++ exited with 0 +++");
+	pidns_printf("+++ exited with 0 +++\n");
 	return 0;
 }
 
diff --git a/tests/sched_xetaffinity-Y.c b/tests/sched_xetaffinity-Y.c
new file mode 100644
index 00000000..fe6bc38a
--- /dev/null
+++ b/tests/sched_xetaffinity-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "sched_xetaffinity.c"
diff --git a/tests/sched_xetaffinity.c b/tests/sched_xetaffinity.c
index cebff3ab..213209e4 100644
--- a/tests/sched_xetaffinity.c
+++ b/tests/sched_xetaffinity.c
@@ -8,8 +8,13 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
 #include "scno.h"
+#include "pidns.h"
 #include <sched.h>
 
 #if defined __NR_sched_getaffinity && defined __NR_sched_setaffinity \
@@ -41,6 +46,8 @@ setaffinity(unsigned long pid, unsigned long size, void *set)
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	unsigned int cpuset_size = 1;
 	const pid_t pid = getpid();
 
@@ -50,18 +57,18 @@ main(void)
 			break;
 		if (EINVAL != errno)
 			perror_msg_and_skip("sched_getaffinity");
-		printf("sched_getaffinity(%d, %u, NULL) = %s\n",
-		       pid, cpuset_size, errstr);
+		pidns_printf("sched_getaffinity(%d%s, %u, NULL) = %s\n",
+		       pid, pidns_pid2str(PT_TGID), cpuset_size, errstr);
 		cpuset_size <<= 1;
 	}
 	assert(cpuset_size);
-	printf("sched_getaffinity(%d, %u, NULL) = %s\n",
-	       pid, cpuset_size, errstr);
+	pidns_printf("sched_getaffinity(%d%s, %u, NULL) = %s\n",
+	       pid, pidns_pid2str(PT_TGID), cpuset_size, errstr);
 
 	cpu_set_t *cpuset = tail_alloc(cpuset_size);
 	getaffinity(pid, cpuset_size, cpuset + 1);
-	printf("sched_getaffinity(%d, %u, %p) = %s\n",
-	       pid, cpuset_size, cpuset + 1, errstr);
+	pidns_printf("sched_getaffinity(%d%s, %u, %p) = %s\n",
+	       pid, pidns_pid2str(PT_TGID), cpuset_size, cpuset + 1, errstr);
 
 	int ret_size = getaffinity(pid, cpuset_size, cpuset);
 	if (ret_size < 0)
@@ -69,7 +76,7 @@ main(void)
 				    pid, (unsigned) cpuset_size, cpuset, errstr);
 	assert(ret_size <= (int) cpuset_size);
 
-	printf("sched_getaffinity(%d, %u, [", pid, cpuset_size);
+	pidns_printf("sched_getaffinity(%d%s, %u, [", pid, pidns_pid2str(PT_TGID), cpuset_size);
 	const char *sep;
 	unsigned int i, cpu;
 	for (i = 0, cpu = 0, sep = ""; i < (unsigned) ret_size * 8; ++i) {
@@ -85,8 +92,8 @@ main(void)
 	CPU_SET_S(cpu, cpuset_size, cpuset);
 	if (setaffinity(pid, cpuset_size, cpuset))
 		perror_msg_and_skip("sched_setaffinity");
-	printf("sched_setaffinity(%d, %u, [%u]) = 0\n",
-	       pid, cpuset_size, cpu);
+	pidns_printf("sched_setaffinity(%d%s, %u, [%u]) = 0\n",
+	       pid, pidns_pid2str(PT_TGID), cpuset_size, cpu);
 
 	const unsigned int big_size = cpuset_size < 128 ? 128 : cpuset_size * 2;
 	cpuset = tail_alloc(big_size);
@@ -95,7 +102,7 @@ main(void)
 		perror_msg_and_fail("sched_getaffinity(%d, %u, %p) = %s\n",
 				    pid, big_size, cpuset, errstr);
 	assert(ret_size <= (int) big_size);
-	printf("sched_getaffinity(%d, %u, [", pid, big_size);
+	pidns_printf("sched_getaffinity(%d%s, %u, [", pid, pidns_pid2str(PT_TGID), big_size);
 	for (i = 0, sep = ""; i < (unsigned) ret_size * 8; ++i) {
 		if (CPU_ISSET_S(i, (unsigned) ret_size, cpuset)) {
 			printf("%s%u", sep, i);
@@ -104,7 +111,7 @@ main(void)
 	}
 	printf("]) = %s\n", errstr);
 
-	puts("+++ exited with 0 +++");
+	pidns_printf("+++ exited with 0 +++\n");
 	return 0;
 }
 
diff --git a/tests/xet_robust_list-Y.c b/tests/xet_robust_list-Y.c
new file mode 100644
index 00000000..a463c976
--- /dev/null
+++ b/tests/xet_robust_list-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "xet_robust_list.c"
diff --git a/tests/xet_robust_list.c b/tests/xet_robust_list.c
index 43239c8b..5e2271b3 100644
--- a/tests/xet_robust_list.c
+++ b/tests/xet_robust_list.c
@@ -6,8 +6,13 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
 #include "scno.h"
+#include "pidns.h"
 
 #if defined __NR_get_robust_list && defined __NR_set_robust_list
 
@@ -30,6 +35,8 @@ sprintaddr(void *addr)
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	const pid_t pid = getpid();
 	const long long_pid = (unsigned long) (0xdeadbeef00000000LL | pid);
 	TAIL_ALLOC_OBJECT_CONST_PTR(void *, p_head);
@@ -37,21 +44,23 @@ main(void)
 
 	if (syscall(__NR_get_robust_list, long_pid, p_head, p_len))
 		perror_msg_and_skip("get_robust_list");
-	printf("get_robust_list(%d, [%s], [%lu]) = 0\n",
-	       (int) pid, sprintaddr(*p_head), (unsigned long) *p_len);
+	pidns_printf("get_robust_list(%d%s, [%s], [%lu]) = 0\n",
+	       pid, pidns_pid2str(PT_TGID), sprintaddr(*p_head),
+	       (unsigned long) *p_len);
 
 	void *head = tail_alloc(*p_len);
 	if (syscall(__NR_set_robust_list, head, *p_len))
 		perror_msg_and_skip("set_robust_list");
-	printf("set_robust_list(%p, %lu) = 0\n",
+	pidns_printf("set_robust_list(%p, %lu) = 0\n",
 	       head, (unsigned long) *p_len);
 
 	if (syscall(__NR_get_robust_list, long_pid, p_head, p_len))
 		perror_msg_and_skip("get_robust_list");
-	printf("get_robust_list(%d, [%s], [%lu]) = 0\n",
-	       (int) pid, sprintaddr(*p_head), (unsigned long) *p_len);
+	pidns_printf("get_robust_list(%d%s, [%s], [%lu]) = 0\n",
+	       pid, pidns_pid2str(PT_TGID), sprintaddr(*p_head),
+	       (unsigned long) *p_len);
 
-	puts("+++ exited with 0 +++");
+	pidns_printf("+++ exited with 0 +++\n");
 	return 0;
 }
 
diff --git a/tests/xetpriority-Y.c b/tests/xetpriority-Y.c
new file mode 100644
index 00000000..55f97de1
--- /dev/null
+++ b/tests/xetpriority-Y.c
@@ -0,0 +1,2 @@
+#define PIDNS_TEST_INIT pidns_test_init_Y();
+#include "xetpriority.c"
diff --git a/tests/xetpriority.c b/tests/xetpriority.c
index 2d61bd10..0e442d04 100644
--- a/tests/xetpriority.c
+++ b/tests/xetpriority.c
@@ -5,8 +5,13 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#ifndef PIDNS_TEST_INIT
+# define PIDNS_TEST_INIT pidns_test_init();
+#endif
+
 #include "tests.h"
 #include "scno.h"
+#include "pidns.h"
 
 #if defined __NR_getpriority && defined __NR_setpriority
 
@@ -17,16 +22,27 @@
 int
 main(void)
 {
+	PIDNS_TEST_INIT;
+
 	const int pid = getpid();
+	const int pgid = getpgid(0);
+
 	long rc = syscall(__NR_getpriority, PRIO_PROCESS,
 			  F8ILL_KULONG_MASK | pid);
-	printf("getpriority(PRIO_PROCESS, %d) = %ld\n", pid, rc);
+	pidns_printf("getpriority(PRIO_PROCESS, %d%s) = %ld\n",
+		pid, pidns_pid2str(PT_TGID), rc);
 
 	rc = syscall(__NR_setpriority, PRIO_PROCESS,
 		     F8ILL_KULONG_MASK | pid, F8ILL_KULONG_MASK);
-	printf("setpriority(PRIO_PROCESS, %d, 0) = %s\n", pid, sprintrc(rc));
+	pidns_printf("setpriority(PRIO_PROCESS, %d%s, 0) = %s\n",
+		pid, pidns_pid2str(PT_TGID), sprintrc(rc));
+
+	rc = syscall(__NR_getpriority, PRIO_PGRP,
+			  F8ILL_KULONG_MASK | pgid);
+	pidns_printf("getpriority(PRIO_PGRP, %d%s) = %ld\n",
+		pgid, pidns_pid2str(PT_PGID), rc);
 
-	puts("+++ exited with 0 +++");
+	pidns_printf("+++ exited with 0 +++\n");
 	return 0;
 }
 
-- 
2.27.0



More information about the Strace-devel mailing list