[LTP] [PATCH v2] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone

Yang Xu xuyang2018.jy@fujitsu.com
Tue Mar 7 07:09:55 CET 2023


For old kernel(below 5.3) 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 | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/containers/utsname/utsname04.c b/testcases/kernel/containers/utsname/utsname04.c
index e8d636d0d..61cc066d8 100644
--- a/testcases/kernel/containers/utsname/utsname04.c
+++ b/testcases/kernel/containers/utsname/utsname04.c
@@ -29,7 +29,13 @@ 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);
+		TEST(tst_clone(&cargs));
+		if (TST_RET == -1)
+			tst_res(TPASS, "clone3() fails as expected");
+		else if (TST_RET == -2)
+			tst_res(TPASS, "clone() fails as expected");
+		else
+			tst_res(TFAIL, "tst_clone returns %ld", TST_RET);
 		TST_EXP_PASS(errno == EPERM);
 	} else {
 		if (!SAFE_FORK()) {
-- 
2.39.1



More information about the ltp mailing list