From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/2] pwritev/pwritev01.c: add new testcase
Date: Tue, 15 Dec 2015 17:36:26 +0100 [thread overview]
Message-ID: <20151215163626.GE26217@rei.lan> (raw)
In-Reply-To: <1449142273-10679-2-git-send-email-yangx.jy@cn.fujitsu.com>
Hi!
> +static struct test_case_t {
> + int count;
> + off_t offset;
> + ssize_t size;
> +} tc[] = {
> + {1, 0, CHUNK},
> + {2, 0, CHUNK},
I've added a test with non-zero offset here.
> +void verify_pwritev(struct test_case_t *tc)
> +{
> + int i;
> +
> + SAFE_PWRITE(cleanup, 1, fd, initbuf, tc->size, 0);
> +
> + SAFE_LSEEK(cleanup, fd, 0, SEEK_SET);
> +
> + TEST(pwritev(fd, wr_iovec, tc->count, tc->offset));
> + if (TEST_RETURN < 0) {
> + tst_resm(TFAIL | TTERRNO, "Pwritev(2) failed");
> + return;
> + }
> +
> + if (TEST_RETURN != tc->size) {
> + tst_resm(TFAIL, "Pwritev(2) write %li bytes, expected %li",
> + TEST_RETURN, tc->size);
> + return;
> + }
> +
> + if (SAFE_LSEEK(cleanup, fd, 0, SEEK_CUR) != 0) {
> + tst_resm(TFAIL, "Pwritev(2) has changed file offset");
> + return;
> + }
> +
> + SAFE_PREAD(cleanup, 1, fd, preadbuf, tc->size, 0);
Fixed it here to read from tc->offset
> + for (i = 0; i < tc->size; i++) {
> + if (preadbuf[i] != 0x61)
> + break;
> + }
> +
> + if (i != tc->size) {
> + tst_resm(TFAIL, "Buffer wrong at %i have %c expected a",
> + i, preadbuf[i]);
Changed the %c to $02x (for the same reason as in the preadv()).
> + return;
> + }
> +
> + tst_resm(TPASS, "Pwritev(2) write %li bytes successfully "
> + "with content 'a' expectedly ", tc->size);
> +}
> +
> +void setup(void)
> +{
> + if ((tst_kvercmp(2, 6, 30)) < 0) {
> + tst_brkm(TCONF, NULL, "This test can only run on kernels "
> + "that are 2.6.30 and higher");
> + }
> +
> + tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +
> + TEST_PAUSE;
> +
> + tst_tmpdir();
> +
> + memset(&initbuf, 0x00, CHUNK);
And removed the memset() here since global variables are initialized to
zero automatically.
And pushed the test, thanks.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2015-12-15 16:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 22:57 [LTP] [PATCH 1/2] preadv/preadv01.c: add new testcase Xiao Yang
2015-11-03 14:30 ` Cyril Hrubis
2015-11-04 6:33 ` yangx.jy
2015-11-04 11:51 ` Cyril Hrubis
2015-11-03 22:57 ` [LTP] [PATCH 2/2] pwritev/pwritev01.c: " Xiao Yang
2015-11-03 14:46 ` Cyril Hrubis
2015-12-03 11:31 ` [LTP] [PATCH v2 1/2] preadv/preadv01.c: " Xiao Yang
2015-12-03 11:31 ` [LTP] [PATCH v2 2/2] pwritev/pwritev01.c: " Xiao Yang
2015-12-15 16:36 ` Cyril Hrubis [this message]
2015-12-15 14:40 ` [LTP] [PATCH v2 1/2] preadv/preadv01.c: " 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=20151215163626.GE26217@rei.lan \
--to=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