From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4] Refactor aiocp using new LTP API
Date: Wed, 3 Aug 2022 12:19:42 +0200 [thread overview]
Message-ID: <YupLvuw1JpxL1pnY@pevik> (raw)
In-Reply-To: <20220803070839.24125-1-andrea.cervesato@suse.com>
Hi Andrea,
...
> + io_destroy(myctx);
> + SAFE_CLOSE(srcfd);
> + SAFE_CLOSE(dstfd);
> +
> + /* check if file has been copied correctly */
> + tst_res(TINFO, "Comparing %s with %s", srcname, dstname);
> +
> + SAFE_STAT(dstname, &st);
> + if (st.st_size != filesize) {
> + tst_res(TFAIL, "Expected destination file size %lld but it's %ld", filesize, st.st_size);
> + /* no need to compare files */
> + return;
> }
> + srcfd = SAFE_OPEN(srcname, srcflags | O_RDONLY, 0666);
> + dstfd = SAFE_OPEN(dstname, srcflags | O_RDONLY, 0666);
> +
> + reads = howmany(filesize, buffsize);
> +
> + for (i = 0; i < reads; i++) {
> + r = SAFE_READ(0, srcfd, srcbuff, buffsize);
> + SAFE_READ(0, dstfd, dstbuff, buffsize);
> + if (memcmp(srcbuff, dstbuff, r)) {
> + fail = 1;
> + break;
> }
> + SAFE_CLOSE(srcfd);
> + SAFE_CLOSE(dstfd);
Shouldn't this be moved to the cleanup function? Because if SAFE_STAT() fails, file
stays open (also, if you add the cleanup function, than tst_res(TFAIL) can be in
for loop, followed by return - a bit simpler code).
Otherwise LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> + if (fail)
> + tst_res(TFAIL, "Files are not identical");
> + else
> + tst_res(TPASS, "Files are identical");
> +}
> +static struct tst_test test = {
> + .test_all = run,
> + .setup = setup,
> + .needs_tmpdir = 1,
> + .options = (struct tst_option[]) {
> + {"b:", &str_aio_blksize, "Size of writing blocks (default 1K)"},
> + {"s:", &str_filesize, "Size of file (default 10M)"},
> + {"n:", &str_aionum, "Number of Async IO blocks (default 16)"},
> + {"f:", &str_oflag, "Open flag: SYNC | DIRECT (default O_CREAT only)"},
> + {},
> + },
> +};
> #else
> -int main(void)
> -{
> - fprintf(stderr, "test requires libaio and it's development packages\n");
> - return TCONF;
> -}
> +TST_TEST_TCONF("test requires libaio and its development packages");
> #endif
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2022-08-03 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 7:08 [LTP] [PATCH v4] Refactor aiocp using new LTP API Andrea Cervesato via ltp
2022-08-03 10:19 ` Petr Vorel [this message]
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=YupLvuw1JpxL1pnY@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox