All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 3/4] tree: Use TST_EXP_PASS_OR_FAIL() and TST_EXP_FD_OR_FAIL()
Date: Wed, 19 Aug 2026 15:53:59 +0200	[thread overview]
Message-ID: <20260819135359.GA2139309@pevik> (raw)
In-Reply-To: <20260814063537.GE261864@pevik>

Hi Andrea, all,

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

@Andrea I suppose the reason why you or somebody else set whole patch as changes
requested was the line above. Once you have time, would you please have look at
the changes I proposed in my previous mail?

Kind regards,
Petr

> > 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/20260811160555.9333-1-linuxtestproject.agent@gmail.com/

> Therefore I suggest to merge with changes below (removed O_TRUNC and move fd =
> to the beginning).

> > Kind regards,
> > Petr

> +++ testcases/kernel/syscalls/landlock/landlock_tester.h
> @@ -254,13 +254,13 @@ static void _test_truncate(const int exp_err)
>  	tst_res(TINFO, "Test truncating file");

>  	TST_EXP_PASS_OR_FAIL(truncate(FILE_TRUNCATE, 10), exp_err);
> -	TST_EXP_FD_OR_FAIL(fd = open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);
> +	fd = TST_EXP_FD_OR_FAIL(open(FILE_TRUNCATE, O_WRONLY, PERM_MODE), exp_err);
>  	if (fd != -1) {
>  		TST_EXP_PASS_OR_FAIL(ftruncate(fd, 10), exp_err);
>  		SAFE_CLOSE(fd);
>  	}

> -	TST_EXP_FD_OR_FAIL(fd = open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);
> +	fd = TST_EXP_FD_OR_FAIL(open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);
>  	if (fd != -1)
>  		SAFE_CLOSE(TST_RET);
>  }

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-08-19 13:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 15:51 [LTP] [PATCH v3 0/4] test_macros: Add TST_EXP_PASS_OR_FAIL() Petr Vorel
2026-08-11 15:51 ` [LTP] [PATCH v3 1/4] test macros: Fix TST_EXP_FD_OR_FAIL() Petr Vorel
2026-08-11 16:05   ` [LTP] " linuxtestproject.agent
2026-08-12 14:44   ` [LTP] [PATCH v3 1/4] " Cyril Hrubis
2026-08-13  6:40     ` Andrea Cervesato via ltp
2026-08-11 15:52 ` [LTP] [PATCH v3 2/4] test_macros: Add TST_EXP_PASS_OR_FAIL() Petr Vorel
2026-08-12 15:26   ` Cyril Hrubis
2026-08-13  6:41   ` Andrea Cervesato via ltp
2026-08-11 15:52 ` [LTP] [PATCH v3 3/4] tree: Use TST_EXP_PASS_OR_FAIL() and TST_EXP_FD_OR_FAIL() Petr Vorel
2026-08-13  6:40   ` Andrea Cervesato via ltp
2026-08-14  6:24     ` Petr Vorel
2026-08-14  6:35       ` Petr Vorel
2026-08-19 13:53         ` Petr Vorel [this message]
2026-08-20  7:52         ` Andrea Cervesato via ltp
2026-08-11 15:52 ` [LTP] [PATCH v3 4/4] test_macros*.c: Simplify with macros macros Petr Vorel
2026-08-20  7:51   ` Andrea Cervesato via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260819135359.GA2139309@pevik \
    --to=pvorel@suse.cz \
    --cc=andrea.cervesato@suse.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.