[LTP] [PATCH] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone
Yang Xu
xuyang2018.jy@fujitsu.com
Tue Feb 28 09:44:24 CET 2023
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
More information about the ltp
mailing list