From: Avinesh Kumar <akumar@suse.de>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3] flock: Add test for verifying EINTR errno
Date: Mon, 03 Feb 2025 15:55:29 +0100 [thread overview]
Message-ID: <4654118.LvFx2qVVIh@thinkpad> (raw)
In-Reply-To: <20250203142213.GA1268944@pevik>
On Monday, February 3, 2025 3:22:13 PM CET Petr Vorel wrote:
> Hi Avinesh, all,
>
> ...
> > +++ b/testcases/kernel/syscalls/flock/flock07.c
> ...
> > +static void handler(int sig)
> > +{
> > + tst_res(TINFO, "Received signal: %d", sig);
> How about print a signal constant/name?
>
> tst_res(TINFO, "Received signal: %s (%d)", tst_strsig(sig), sig);
> > +}
> ...
> > +static void verify_flock(void)
> > +{
> > + pid_t pid;
> > + int fd1 = SAFE_OPEN(TEMPFILE, O_RDWR);
> > + int fd2 = SAFE_OPEN(TEMPFILE, O_RDWR);
> How about to setup file descriptors in setup() and close them in cleanup()?
>
> I suggest to merge with the change below.
Hi Petr,
Thank you for the review, and I agree with your suggestions.
Regards,
Avinesh
>
> > +
> > + TST_EXP_PASS(flock(fd1, LOCK_EX));
> > +
> > + pid = SAFE_FORK();
> > + if (!pid) {
> > + child_do(fd2);
> > + exit(0);
> > + } else {
> > + sleep(1);
> > + SAFE_KILL(pid, SIGUSR1);
> > + SAFE_WAITPID(pid, NULL, 0);
> > + }
> > +
> > + SAFE_CLOSE(fd1);
> > + SAFE_CLOSE(fd2);
> > +}
>
> Kind regards,
> Petr
>
> +++ testcases/kernel/syscalls/flock/flock07.c
> @@ -17,14 +17,27 @@
>
> #define TEMPFILE "test_eintr"
>
> +static int fd1 = -1, fd2 = -1;
> +
> static void handler(int sig)
> {
> - tst_res(TINFO, "Received signal: %d", sig);
> + tst_res(TINFO, "Received signal: %s (%d)", tst_strsig(sig), sig);
> }
>
> static void setup(void)
> {
> SAFE_TOUCH(TEMPFILE, 0777, NULL);
> + fd1 = SAFE_OPEN(TEMPFILE, O_RDWR);
> + fd2 = SAFE_OPEN(TEMPFILE, O_RDWR);
> +}
> +
> +static void cleanup(void)
> +{
> + if (fd1 >= 0)
> + SAFE_CLOSE(fd1);
> +
> + if (fd2 >= 0)
> + SAFE_CLOSE(fd2);
> }
>
> static void child_do(int fd)
> @@ -42,8 +55,6 @@ static void child_do(int fd)
> static void verify_flock(void)
> {
> pid_t pid;
> - int fd1 = SAFE_OPEN(TEMPFILE, O_RDWR);
> - int fd2 = SAFE_OPEN(TEMPFILE, O_RDWR);
>
> TST_EXP_PASS(flock(fd1, LOCK_EX));
>
> @@ -56,13 +67,11 @@ static void verify_flock(void)
> SAFE_KILL(pid, SIGUSR1);
> SAFE_WAITPID(pid, NULL, 0);
> }
> -
> - SAFE_CLOSE(fd1);
> - SAFE_CLOSE(fd2);
> }
>
> static struct tst_test test = {
> .setup = setup,
> + .cleanup = cleanup,
> .test_all = verify_flock,
> .needs_tmpdir = 1,
> .needs_root = 1,
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-03 14:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 8:02 [LTP] [PATCH] flock: Add negative tests for flock Yang Xu via ltp
2024-05-30 14:13 ` Avinesh Kumar
2024-10-21 14:28 ` Petr Vorel
2024-05-30 14:40 ` [LTP] [PATCH v2] flock: Add test for verifying EINTR errno Avinesh Kumar
2024-05-30 14:48 ` [LTP] [PATCH v3] " Avinesh Kumar
2024-10-21 19:55 ` Petr Vorel
2025-01-14 15:54 ` Avinesh Kumar
2025-01-31 11:01 ` Petr Vorel
2025-02-03 9:41 ` Avinesh Kumar
2025-02-03 10:12 ` Petr Vorel
2025-02-03 14:22 ` Petr Vorel
2025-02-03 14:55 ` Avinesh Kumar [this message]
2025-02-03 15:33 ` Petr Vorel
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=4654118.LvFx2qVVIh@thinkpad \
--to=akumar@suse.de \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/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.