From: Cyril Hrubis <chrubis@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/fcntl05: Convert into new api
Date: Wed, 27 Apr 2022 16:39:59 +0200 [thread overview]
Message-ID: <YmlVv3QSmAmIIwA/@yuki> (raw)
In-Reply-To: <1651034524-18799-1-git-send-email-xuyang2018.jy@fujitsu.com>
Hi!
> +static void verify_fcntl(void)
> {
> - int lc;
> + /* F_GETLK will change flock.l_type to F_UNLCK, so need to reset */
> + flocks.l_type = F_RDLCK;
>
> - tst_parse_opts(ac, av, NULL, NULL);
> -
> - setup();
> -
> - for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> - tst_count = 0;
> -
> - flocks.l_type = F_RDLCK;
> - TEST(fcntl(fd, F_GETLK, &flocks));
> -
> - if (TEST_RETURN == -1)
> - tst_resm(TFAIL | TTERRNO, "fcntl failed");
> - else {
> - tst_resm(TPASS, "fcntl returned %ld",
> - TEST_RETURN);
> - }
> -
> - }
> -
> - cleanup();
> - tst_exit();
> + TST_EXP_PASS(fcntl(fd, F_GETLK, &flocks), "fcntl(%d, F_GETLK, &flocks)", fd);
Can we also check that the l_type was actually set and that the rest of
the fields have not changed?
Should be as easy as:
TST_EXP_EQ_LI(flocks.l_type, F_UNLCK);
TST_EXP_EQ_LI(flocks.l_whence, SEEK_CUR);
TST_EXP_EQ_LI(flocks.l_start, 0);
...
> }
>
> -void setup(void)
> +static void setup(void)
> {
> + char fname[255];
> + int pid;
>
> - tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> - TEST_PAUSE;
> -
> - tst_tmpdir();
> + pid = getpid();
>
> - sprintf(fname, "tfile_%d", getpid());
> - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
> - tst_brkm(TBROK | TERRNO, cleanup, "open failed");
> + sprintf(fname, "testfile_%d", pid);
> + fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
The test creates unique temporary directory so tehre is no need to
include the pid in the filename anymore...
The rest looks good. With the two changes applied:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-04-27 14:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 4:42 [LTP] [PATCH] syscalls/fcntl05: Convert into new api Yang Xu
2022-04-27 14:39 ` Cyril Hrubis [this message]
2022-04-28 1:22 ` xuyang2018.jy
2022-04-28 2:51 ` [LTP] [PATCH v2] " Yang Xu
2022-06-01 14:45 ` Cyril Hrubis
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=YmlVv3QSmAmIIwA/@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox