From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Daniel Palmer <daniel@thingy.jp>
Cc: w@1wt.eu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests/nolibc: Add a very basic test for fallocate()
Date: Wed, 15 Apr 2026 17:59:14 +0200 [thread overview]
Message-ID: <617cdc58-4589-42f4-a30c-49108941e5c8@t-8ch.de> (raw)
In-Reply-To: <20260415143225.561998-3-daniel@thingy.jp>
On 2026-04-15 23:32:25+0900, Daniel Palmer wrote:
> Create a tmp file, fallocate() to make it a bit bigger, check the
> size is what was expected.
>
> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
> tools/testing/selftests/nolibc/nolibc-test.c | 33 ++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index d3c4facb54c0..066f436561e7 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -896,6 +896,38 @@ int test_getpagesize(void)
> return !c;
> }
>
> +int test_fallocate(void)
> +{
> + struct stat st;
> + int fd, r;
> +
> + /* Create a new tmp file */
> + fd = open("/tmp", O_TMPFILE | O_RDWR, 0644);
> + if (fd == -1)
> + return -1;
> +
> + /* Expand it to 42 bytes */
> + r = fallocate(fd, 0, 0, 42);
> + if (r)
> + goto close_tmpfile;
> +
> + /* Get the new stat */
> + r = fstat(fd, &st);
> + if (r)
> + goto close_tmpfile;
> +
> + /* It should be 42 bytes long */
> + if (st.st_size != 42) {
> + r = -1;
> + goto close_tmpfile;
> + }
This should also check that full 64-bit values are passed through.
> +
> +close_tmpfile:
> + close(fd);
> +
> + return r;
> +}
(...)
prev parent reply other threads:[~2026-04-15 15:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 14:32 [PATCH 0/2] nolibc: Add fallocate() Daniel Palmer
2026-04-15 14:32 ` [PATCH 1/2] tools/nolibc: fcntl: " Daniel Palmer
2026-04-15 15:56 ` Thomas Weißschuh
2026-04-15 14:32 ` [PATCH 2/2] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
2026-04-15 15:59 ` Thomas Weißschuh [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=617cdc58-4589-42f4-a30c-49108941e5c8@t-8ch.de \
--to=linux@weissschuh.net \
--cc=daniel@thingy.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=w@1wt.eu \
/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
all inboxes | Powered by JetHome®