From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/fallocate04: add 'FALLOC_FL_INSERT_RANGE' test-case
Date: Tue, 26 Jul 2016 14:45:22 +0200 [thread overview]
Message-ID: <20160726124522.GD11679@rei.lan> (raw)
In-Reply-To: <1466612145-13233-1-git-send-email-alexey.kodanev@oracle.com>
Hi!
> fill_tst_buf(tmp_buf);
>
> memcpy(exp_buf, tmp_buf, block_size);
> - memcpy(exp_buf + block_size, tmp_buf + size, block_size);
> + memcpy(exp_buf + block_size, tmp_buf + 2 * block_size,
> + buf_size - block_size * 2);
Looks OK to me.
> exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
> check_file_data(exp_buf, size);
> @@ -274,6 +275,50 @@ static void test04(void)
> tst_resm(TPASS, "test-case succeeded");
> }
>
> +static void test05(void)
> +{
> + tst_resm(TINFO, "inserting space with FALLOC_FL_INSERT_RANGE");
> +
> + size_t alloc_size0 = get_allocsize();
> +
> + tst_resm(TINFO, "read current allocated file size '%zu'", alloc_size0);
> +
> + if (fallocate(fd, FALLOC_FL_INSERT_RANGE, block_size,
> + block_size) == -1) {
> + if (errno == EOPNOTSUPP) {
> + tst_brkm(TCONF, cleanup,
> + "FALLOC_FL_INSERT_RANGE not supported");
> + }
> + tst_brkm(TFAIL | TERRNO, cleanup, "fallocate failed");
> + }
> +
> + /* allocate space and ensure that it filled with zeroes */
> + if (fallocate(fd, FALLOC_FL_ZERO_RANGE, block_size, block_size) == -1)
> + tst_brkm(TFAIL | TERRNO, cleanup, "fallocate failed");
> +
> + size_t alloc_size1 = get_allocsize();
> +
> + tst_resm(TINFO, "allocated file size before '%zu' and after '%zu'",
> + alloc_size0, alloc_size1);
> + if ((alloc_size0 + block_size) != alloc_size1)
> + tst_brkm(TFAIL, cleanup, "not expected allocated size");
> +
> + size_t size = buf_size;
> + char tmp_buf[buf_size];
> + char exp_buf[size];
> +
> + fill_tst_buf(tmp_buf);
> +
> + memcpy(exp_buf, tmp_buf, block_size);
> + memcpy(exp_buf + 2 * block_size, tmp_buf + 2 * block_size,
> + buf_size - block_size * 2);
> + memset(exp_buf + block_size - 1, 0, block_size + 2);
> +
> + check_file_data(exp_buf, size);
Why not just:
fill_tst_buf(exp_buf);
memset(exp_buf + block_size - 1, 0, block_size + 2);
Otherwise it looks fine.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2016-07-26 12:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-22 16:15 [LTP] [PATCH] syscalls/fallocate04: add 'FALLOC_FL_INSERT_RANGE' test-case Alexey Kodanev
2016-07-26 12:45 ` Cyril Hrubis [this message]
2016-07-27 10:45 ` Alexey Kodanev
2016-07-28 10:18 ` Alexey Kodanev
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=20160726124522.GD11679@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