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

xuyang2018.jy@fujitsu.com xuyang2018.jy@fujitsu.com
Fri Mar 3 07:11:11 CET 2023


Hi Cyril

> 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:

I guess it is used to distinguish clone3(-1) and clone failure(-2).
@Ritchie  Is this right? Or you have other meaning.

Maybe we can use clone instead of tst_clone in this case?

Best Regards
Yang Xu
  >
> 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;
>   }
> 
> 


More information about the ltp mailing list