Re: [LTP] [PATCH v3 3/4] tree: Use TST_EXP_PASS_OR_FAIL() and TST_EXP_FD_OR_FAIL()

Petr Vorel <[email protected]>
Newsgroups it.linux.lists.ltp
Message-ID <20260814062434.GD261864@pevik>
> Hi Petr,

> > +	TST_EXP_FD_OR_FAIL(fd = open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);

> the correct usage should be:

> fd = TST_EXP_FD_OR_FAIL(open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);

Just a note: both compile and works the same (i.e. both are correct), but of
course the variant you suggested (fd = TST_EXP_FD_OR_FAIL...) is clearer.

This is because newer macros use ({  ...  TST_RET; }). But the original macro
TEST() use do { ... } while (0), that's why we slightly ugly code:

$ git grep 'TEST.*(fd ='
testcases/kernel/syscalls/fsconfig/fsconfig01.c:        TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/fsconfig/fsconfig02.c:        TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/fsconfig/fsconfig03.c:        TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/fsmount/fsmount02.c:  TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/fsopen/fsopen01.c:    TEST(fd = fsopen(tst_device->fs_type, tc->flags));
testcases/kernel/syscalls/move_mount/move_mount01.c:    TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/move_mount/move_mount02.c:    TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/mq_open/mq_open01.c:  TEST(fd = mq_open(qname, tc->oflag, S_IRWXU, tc->rq));
testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c:      TEST(fd = open_by_handle_at(*tc->dfd, fhp, tc->flags));
testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c:      TEST(fd = open_by_handle_at(*tc->dfd, *tc->fhp, tc->flags));
testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at02.c:      TEST(fd = open_by_handle_at(tc->dfd, *tc->fhp, tc->flags));
testcases/kernel/syscalls/openat2/openat201.c:  TEST(fd = openat2(*tc->dfd, tc->pathname, myhow, tc->size));
testcases/kernel/syscalls/socket/socket01.c:    TEST(fd = socket(tc->domain, tc->type, tc->proto));

Anyway, this could be fixed before merge if this is a single thing to fix, but I
worry about agents findings:
https://lore.kernel.org/ltp/[email protected]/

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.