From: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] syscalls/fcntl05: Convert into new api
Date: Thu, 28 Apr 2022 01:22:01 +0000 [thread overview]
Message-ID: <6269FA77.1080601@fujitsu.com> (raw)
In-Reply-To: <YmlVv3QSmAmIIwA/@yuki>
Hi Cyril
> 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);
> ...
>
Of course, will do it in v2.
>
>> }
>>
>> -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...
Yes.
>
> The rest looks good. With the two changes applied:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-04-28 1:22 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
2022-04-28 1:22 ` xuyang2018.jy [this message]
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=6269FA77.1080601@fujitsu.com \
--to=xuyang2018.jy@fujitsu.com \
--cc=chrubis@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox