[LTP] [PATCH] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone
xuyang2018.jy@fujitsu.com
xuyang2018.jy@fujitsu.com
Tue Feb 28 10:18:51 CET 2023
Hi Andrea
> Hi!
>
> On 2/28/23 09:44, Yang Xu wrote:
>
>> For old kernel that doesn't support clone3, tst_clone returns
> it would be nice to add unsupported kernel version inside patch comment
> (in this case, anything below 5.3).
Yes.
>> -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);
>
> 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)
Best Regards
Yang Xu
>
>> + 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()) {
>
> Regards,
> Andrea
>
>
More information about the ltp
mailing list