[LTP] 回复: [PATCH 2/3] umount02: Simplify test using TST_ macros

Yang Xu (Fujitsu) xuyang2018.jy@fujitsu.com
Thu Oct 26 07:40:30 CEST 2023


>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>> ---
>>  testcases/kernel/syscalls/umount/umount02.c | 12 +++---------
>>  1 file changed, 3 insertions(+), 9 deletions(-)

>> diff --git a/testcases/kernel/syscalls/umount/umount02.c b/testcases/kernel/syscalls/umount/umount02.c
>> index 34a38c998..40fed1fbd 100644
>> --- a/testcases/kernel/syscalls/umount/umount02.c
>> +++ b/testcases/kernel/syscalls/umount/umount02.c
>> @@ -2,6 +2,7 @@
>>  /*
>>   * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
>>   * Copyright (c) 2014 Cyril Hrubis <chrubis@suse.cz>
>> + * Copyright (c) Linux Test Project, 2003-2023
>>   * Author: Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
>>   *
>>   * Check for basic errors returned by umount(2) system call.
>> @@ -41,21 +42,14 @@ static void verify_umount(unsigned int n)
>>  {
>>        struct tcase *tc = &tcases[n];

>> -     TEST(umount(tc->mntpoint));
>> -
>> -     if (TST_RET != -1) {
>> -             tst_res(TFAIL, "umount() succeeds unexpectedly");
>> -             return;
>> -     }
>> +     TST_EXP_FAIL(umount(tc->mntpoint), tc->exp_errno,
>> +                  "umount() fail with %s", tc->err_desc);

>I'd prefer just:
>TST_EXP_FAIL(umount(tc->mntpoint), tc->exp_errno);

OK. Thanks for your suggestion.

>>        if (tc->exp_errno != TST_ERR) {
>>                tst_res(TFAIL | TTERRNO, "umount() should fail with %s",
>>                        tst_strerrno(tc->exp_errno));
>>                return;
>>        }
>Also this is redundant and should be removed.
>With it removed you may add:
>Reviewed-by: Petr Vorel <pvorel@suse.cz>

>nit: #include <string.h> could be removed.
>Also doc could be converted to docparse.

OK.

>Kind regards,
>Petr

Best Regards
Yang Xu
________________________________
发件人: Petr Vorel <pvorel@suse.cz>
发送时间: 2023年10月26日 8:12
收件人: Xu, Yang/徐 杨 <xuyang2018.jy@fujitsu.com>
抄送: ltp@lists.linux.it <ltp@lists.linux.it>
主题: Re: [LTP] [PATCH 2/3] umount02: Simplify test using TST_ macros

> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
>  testcases/kernel/syscalls/umount/umount02.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)

> diff --git a/testcases/kernel/syscalls/umount/umount02.c b/testcases/kernel/syscalls/umount/umount02.c
> index 34a38c998..40fed1fbd 100644
> --- a/testcases/kernel/syscalls/umount/umount02.c
> +++ b/testcases/kernel/syscalls/umount/umount02.c
> @@ -2,6 +2,7 @@
>  /*
>   * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
>   * Copyright (c) 2014 Cyril Hrubis <chrubis@suse.cz>
> + * Copyright (c) Linux Test Project, 2003-2023
>   * Author: Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
>   *
>   * Check for basic errors returned by umount(2) system call.
> @@ -41,21 +42,14 @@ static void verify_umount(unsigned int n)
>  {
>        struct tcase *tc = &tcases[n];

> -     TEST(umount(tc->mntpoint));
> -
> -     if (TST_RET != -1) {
> -             tst_res(TFAIL, "umount() succeeds unexpectedly");
> -             return;
> -     }
> +     TST_EXP_FAIL(umount(tc->mntpoint), tc->exp_errno,
> +                  "umount() fail with %s", tc->err_desc);

I'd prefer just:
TST_EXP_FAIL(umount(tc->mntpoint), tc->exp_errno);

>        if (tc->exp_errno != TST_ERR) {
>                tst_res(TFAIL | TTERRNO, "umount() should fail with %s",
>                        tst_strerrno(tc->exp_errno));
>                return;
>        }
Also this is redundant and should be removed.
With it removed you may add:
Reviewed-by: Petr Vorel <pvorel@suse.cz>

nit: #include <string.h> could be removed.
Also doc could be converted to docparse.

Kind regards,
Petr


More information about the ltp mailing list