public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone
@ 2023-02-28  8:44 Yang Xu
  2023-02-28  9:06 ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 9+ messages in thread
From: Yang Xu @ 2023-02-28  8:44 UTC (permalink / raw)
  To: ltp

For old kernel that doesn't support clone3, tst_clone returns
-2 instead of -1. So we can't use TST_EXP_EQ_LI api.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/containers/utsname/utsname04.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/containers/utsname/utsname04.c b/testcases/kernel/containers/utsname/utsname04.c
index e8d636d0d..1adc4542c 100644
--- a/testcases/kernel/containers/utsname/utsname04.c
+++ b/testcases/kernel/containers/utsname/utsname04.c
@@ -22,6 +22,7 @@ static void run(void)
 {
 	const struct tst_clone_args cargs = { CLONE_NEWUTS, SIGCHLD };
 	struct passwd *pw;
+	pid_t pid;
 
 	tst_res(TINFO, "Dropping root privileges");
 
@@ -29,7 +30,11 @@ static void run(void)
 	SAFE_SETRESUID(pw->pw_uid, pw->pw_uid, pw->pw_uid);
 
 	if (!str_op || !strcmp(str_op, "clone")) {
-		TST_EXP_EQ_LI(tst_clone(&cargs), -1);
+		pid = tst_clone(&cargs);
+		if (pid == -1 || pid == -2)
+			tst_res(TPASS, "clone() returns an expected value %d", pid);
+		else
+			tst_res(TFAIL, "clone() returns an unexpected value %d", pid);
 		TST_EXP_PASS(errno == EPERM);
 	} else {
 		if (!SAFE_FORK()) {
-- 
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2023-03-07 10:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28  8:44 [LTP] [PATCH] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone Yang Xu
2023-02-28  9:06 ` Andrea Cervesato via ltp
2023-02-28  9:18   ` xuyang2018.jy
2023-02-28  9:39     ` Cyril Hrubis
2023-03-03  6:11       ` xuyang2018.jy
2023-03-06 14:10         ` Richard Palethorpe
2023-03-07  6:09           ` [LTP] [PATCH v2] " Yang Xu
2023-03-07  8:35             ` Richard Palethorpe
2023-03-07 10:16               ` Richard Palethorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox