[LTP] [PATCH 4/5] Add pidfd_getfd01 test
xuyang2018.jy@fujitsu.com
xuyang2018.jy@fujitsu.com
Tue Feb 22 03:29:58 CET 2022
Hi Petr
> Hi Xu,
>
> ...
>>>> TEST(kcmp(getpid(), pid, KCMP_FILE, remotefd, targetfd));
>>>> if (TST_RET==-1) {
>>>> tst_res(TFAIL | TTERRNO, "kcmp failed unexpectedly");
>>>> goto free;
>>>> } else {
>>>> if (TST_RET< 0 || TST_RET> 3)
>>> +1 (very nit: instead of if/else I'd use 2x if and (TST_RET< -1 || TST_RET> 3)
>>> - readability).
>> Good catch. I add the last "if" otherwise 1,2,3 are ignored.
>
>> TEST(kcmp(getpid(), pid, KCMP_FILE, remotefd, targetfd));
>> if (TST_RET == -1) {
>> tst_res(TFAIL | TTERRNO, "kcmp failed unexpectedly");
>> goto free;
>> }
>> if (TST_RET< 0 || TST_RET> 3) {
>> tst_res(TFAIL, "kcmp invalid returns value(%d)",
>> (int)TST_RET);
>> goto free;
>> }
>> if (TST_RET != 0) {
>> tst_res(TFAIL, "kcmp returns unexpected value(%d)
>> instead of 0",
>> (int)TST_RET);
>> goto free;
>> }
>
>> tst_res(TPASS, "pidfd_getfd(%d, %d, 0) passed", pidfd, targetfd);
>
> FYI Unless we want to have explanations why it failed, we could use TST_EXP_VAL() or
> TST_EXP_VAL_SILENT().
Ok, I will use TST_EXP_VAL_SILENT.
Best Regards
Yang Xu
>
> Kind regards,
> Petr
More information about the ltp
mailing list