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

Richard Palethorpe rpalethorpe@suse.de
Mon Mar 6 15:10:15 CET 2023


Hello,

"xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com> writes:

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

Yes, this is how it is used in SAFE_CLONE to provide debug information
when tst_clone fails.

It's important to know which clone failed as obviously they do not
support all the same flags or features.

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

I think just use the return value as it was intended and print which
version of clone failed.

>
> 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;
>>   }
>> 
>> 


-- 
Thank you,
Richard.


More information about the ltp mailing list