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

Cyril Hrubis chrubis@suse.cz
Tue Feb 28 10:39:52 CET 2023


Hi!
> > Did you try this?
> > 
> > TST_EXP_FAIL(tst_clone(&cargs), EPERM);
> 
> I don't try this because I remembered TST_EXP_FAIL only thinks the 
> correct return value is -1.
> 
> tst_test.c:1560: TINFO: Timeout per run is 0h 00m 30s
> utsname04.c:27: TINFO: Dropping root privileges
> utsname04.c:33: TFAIL: tst_clone(&cargs) invalid retval -2: EPERM (1)

It's actually the tst_clone() that returns -2 if fallback to __NR_clone
failed.

@Ritchie Is there actually a good reason why tst_clone() returns -2 on a
         fialure? Can we fix the code by:

diff --git a/lib/tst_clone.c b/lib/tst_clone.c
index ecc84408c..bacd269d9 100644
--- a/lib/tst_clone.c
+++ b/lib/tst_clone.c
@@ -39,8 +39,5 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
        pid = syscall(__NR_clone, flags, NULL);
 #endif
 
-       if (pid == -1)
-               return -2;
-
        return pid;
 }


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list