diff mbox series

[1/1] tree: Use TST_EXP_FAIL2() for wait{,id}

Message ID 20240201151357.110769-1-pvorel@suse.cz
State Changes Requested
Headers show
Series [1/1] tree: Use TST_EXP_FAIL2() for wait{,id} | expand

Commit Message

Petr Vorel Feb. 1, 2024, 3:13 p.m. UTC
Both wait() and waitid() returns PID, therefore (similarly as for file
descriptor) pass condition is >= 0, which is in TST_EXP_FAIL2().

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/pidfd_open/pidfd_open04.c | 2 +-
 testcases/kernel/syscalls/wait/wait01.c             | 2 +-
 testcases/kernel/syscalls/waitid/waitid02.c         | 2 +-
 testcases/kernel/syscalls/waitid/waitid03.c         | 2 +-
 testcases/kernel/syscalls/waitid/waitid05.c         | 2 +-
 testcases/kernel/syscalls/waitid/waitid06.c         | 2 +-
 testcases/kernel/syscalls/waitid/waitid09.c         | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

Comments

Cyril Hrubis May 9, 2024, 2:08 p.m. UTC | #1
Hi!
> Both wait() and waitid() returns PID, therefore (similarly as for file
> descriptor) pass condition is >= 0, which is in TST_EXP_FAIL2().

Actually waitid() returns whatever was waited for in the siginfo_t
structure and returns just 0 on success.
Petr Vorel May 9, 2024, 2:17 p.m. UTC | #2
Hi Cyril,

> Hi!
> > Both wait() and waitid() returns PID, therefore (similarly as for file
> > descriptor) pass condition is >= 0, which is in TST_EXP_FAIL2().

> Actually waitid() returns whatever was waited for in the siginfo_t
> structure and returns just 0 on success.

Ah, thanks!  I guess I misread "waitpid()" in man wait(3p) as "waitid()".

I'll send v2 with just pidfd_open04.c and wait01.c changes.

Kind regards,
Petr
Petr Vorel May 9, 2024, 2:20 p.m. UTC | #3
> Hi Cyril,

> > Hi!
> > > Both wait() and waitid() returns PID, therefore (similarly as for file
> > > descriptor) pass condition is >= 0, which is in TST_EXP_FAIL2().

> > Actually waitid() returns whatever was waited for in the siginfo_t
> > structure and returns just 0 on success.

> Ah, thanks!  I guess I misread "waitpid()" in man wait(3p) as "waitid()".

> I'll send v2 with just pidfd_open04.c and wait01.c changes.
Actually only wait01.c (pidfd_open04.c has also waitid) + searching for
waitpid() usage.

Kind regards,
Petr

> Kind regards,
> Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/pidfd_open/pidfd_open04.c b/testcases/kernel/syscalls/pidfd_open/pidfd_open04.c
index 0e8ab6956..9f83d2b72 100644
--- a/testcases/kernel/syscalls/pidfd_open/pidfd_open04.c
+++ b/testcases/kernel/syscalls/pidfd_open/pidfd_open04.c
@@ -45,7 +45,7 @@  static void run(void)
 
 	tst_res(TPASS, "pidfd_open(%d, O_NONBLOCK) sets O_NONBLOCK flag", pid);
 
-	TST_EXP_FAIL(waitid(P_PIDFD, pidfd, &info, WEXITED), EAGAIN,
+	TST_EXP_FAIL2(waitid(P_PIDFD, pidfd, &info, WEXITED), EAGAIN,
 			"waitid(P_PIDFD,...,WEXITED)");
 
 	TST_CHECKPOINT_WAKE(0);
diff --git a/testcases/kernel/syscalls/wait/wait01.c b/testcases/kernel/syscalls/wait/wait01.c
index aec91b911..8245898dd 100644
--- a/testcases/kernel/syscalls/wait/wait01.c
+++ b/testcases/kernel/syscalls/wait/wait01.c
@@ -16,7 +16,7 @@ 
 
 static void verify_wait(void)
 {
-	TST_EXP_FAIL(wait(NULL), ECHILD);
+	TST_EXP_FAIL2(wait(NULL), ECHILD);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/waitid/waitid02.c b/testcases/kernel/syscalls/waitid/waitid02.c
index f13a4ed00..c5b27939b 100644
--- a/testcases/kernel/syscalls/waitid/waitid02.c
+++ b/testcases/kernel/syscalls/waitid/waitid02.c
@@ -18,7 +18,7 @@  static siginfo_t *infop;
 
 static void run(void)
 {
-	TST_EXP_FAIL(waitid(P_ALL, 0, infop, WNOHANG), EINVAL);
+	TST_EXP_FAIL2(waitid(P_ALL, 0, infop, WNOHANG), EINVAL);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/waitid/waitid03.c b/testcases/kernel/syscalls/waitid/waitid03.c
index ef3fd7376..a44a030df 100644
--- a/testcases/kernel/syscalls/waitid/waitid03.c
+++ b/testcases/kernel/syscalls/waitid/waitid03.c
@@ -19,7 +19,7 @@  static siginfo_t *infop;
 
 static void run(void)
 {
-	TST_EXP_FAIL(waitid(P_ALL, 0, infop, WNOHANG | WEXITED), ECHILD);
+	TST_EXP_FAIL2(waitid(P_ALL, 0, infop, WNOHANG | WEXITED), ECHILD);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/waitid/waitid05.c b/testcases/kernel/syscalls/waitid/waitid05.c
index 1b9186dc1..004d48b97 100644
--- a/testcases/kernel/syscalls/waitid/waitid05.c
+++ b/testcases/kernel/syscalls/waitid/waitid05.c
@@ -31,7 +31,7 @@  static void run(void)
 
 	pid_group = getpgid(0);
 
-	TST_EXP_FAIL(waitid(P_PGID, pid_group+1, infop, WEXITED), ECHILD);
+	TST_EXP_FAIL2(waitid(P_PGID, pid_group+1, infop, WEXITED), ECHILD);
 
 	memset(infop, 0, sizeof(*infop));
 	TST_EXP_PASS(waitid(P_PGID, pid_group, infop, WEXITED));
diff --git a/testcases/kernel/syscalls/waitid/waitid06.c b/testcases/kernel/syscalls/waitid/waitid06.c
index 5f51c81c8..003d10d6e 100644
--- a/testcases/kernel/syscalls/waitid/waitid06.c
+++ b/testcases/kernel/syscalls/waitid/waitid06.c
@@ -28,7 +28,7 @@  static void run(void)
 	if (!pid_child)
 		exit(0);
 
-	TST_EXP_FAIL(waitid(P_PID, pid_child+1, infop, WEXITED), ECHILD);
+	TST_EXP_FAIL2(waitid(P_PID, pid_child+1, infop, WEXITED), ECHILD);
 
 	memset(infop, 0, sizeof(*infop));
 	TST_EXP_PASS(waitid(P_PID, pid_child, infop, WEXITED));
diff --git a/testcases/kernel/syscalls/waitid/waitid09.c b/testcases/kernel/syscalls/waitid/waitid09.c
index 115c2e672..935c1754c 100644
--- a/testcases/kernel/syscalls/waitid/waitid09.c
+++ b/testcases/kernel/syscalls/waitid/waitid09.c
@@ -24,7 +24,7 @@  static void run(void)
 	if (!SAFE_FORK())
 		exit(0);
 
-	TST_EXP_FAIL(waitid(P_PID, 1, infop, WEXITED), ECHILD);
+	TST_EXP_FAIL2(waitid(P_PID, 1, infop, WEXITED), ECHILD);
 }
 
 static struct tst_test test = {