From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC] [PATCH 06/15] syscalls/fallocate05: New test
Date: Thu, 7 Sep 2017 04:51:34 -0400 (EDT) [thread overview]
Message-ID: <1530936082.10130435.1504774294954.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170905160918.6477-6-chrubis@suse.cz>
----- Original Message -----
> Tests that fallocate() works fine when filesystem is full.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
...
> +#define _GNU_SOURCE
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <fcntl.h>
> +#include "tst_test.h"
I'm running into build failure:
fallocate05.c: In function ‘run’:
fallocate05.c:43: warning: implicit declaration of function ‘fallocate’
fallocate05.c:72: error: ‘FALLOC_FL_PUNCH_HOLE’ undeclared (first use in this function)
fallocate05.c:72: error: (Each undeclared identifier is reported only once
fallocate05.c:72: error: for each function it appears in.)
make: *** [fallocate05] Error 1
This likely needs:
#include "lapi/fallocate.h"
Regards,
Jan
> +
> +#define MNTPOINT "mntpoint"
> +#define FALLOCATE_SIZE 8192
> +
> +static int fd;
> +
> +static void run(void)
> +{
> + char buf[FALLOCATE_SIZE];
> + ssize_t ret;
> +
> + fd = SAFE_OPEN(MNTPOINT "/test_file", O_WRONLY | O_CREAT);
> +
> + if (fallocate(fd, 0, 0, FALLOCATE_SIZE)) {
> + if (errno == EOPNOTSUPP) {
> + tst_res(TCONF | TERRNO, "fallocate() not supported");
> + SAFE_CLOSE(fd);
> + return;
> + }
> +
> + tst_brk(TBROK | TERRNO,
> + "fallocate(fd, 0, 0, %i)", FALLOCATE_SIZE);
> + }
> +
> + tst_fill_fs(MNTPOINT);
> +
> + ret = write(fd, buf, sizeof(buf));
> +
> + if (ret < 0)
> + tst_res(TFAIL | TERRNO, "write() failed unexpectedly");
> + else
> + tst_res(TPASS, "write() wrote %zu bytes", ret);
> +
> + ret = fallocate(fd, 0, FALLOCATE_SIZE, FALLOCATE_SIZE);
> + if (ret != -1)
> + tst_brk(TFAIL, "fallocate() succeeded unexpectedly");
> +
> + if (errno != ENOSPC)
> + tst_brk(TFAIL | TERRNO, "fallocate() should fail with ENOSPC");
> +
> + tst_res(TPASS | TERRNO, "fallocate() on full FS");
> +
> + ret = fallocate(fd, FALLOC_FL_PUNCH_HOLE, 0, FALLOCATE_SIZE);
> + if (ret == -1) {
> + if (errno == EOPNOTSUPP)
> + tst_brk(TCONF, "fallocate(FALLOC_FL_PUNCH_HOLE)");
> +
> + tst_brk(TBROK | TERRNO, "fallocate(FALLOC_FL_PUNCH_HOLE)");
> + }
> + tst_res(TPASS, "fallocate(FALLOC_FL_PUNCH_HOLE)");
> +
> + ret = write(fd, buf, 10);
> + if (ret == -1)
> + tst_res(TFAIL | TERRNO, "write()");
> + else
> + tst_res(TPASS, "write()");
> +
> + SAFE_CLOSE(fd);
> +}
> +
> +static void cleanup(void)
> +{
> + if (fd > 0)
> + SAFE_CLOSE(fd);
> +}
> +
> +static struct tst_test test = {
> + .needs_root = 1,
> + .needs_tmpdir = 1,
> + .mount_device = 1,
> + .mntpoint = MNTPOINT,
> + .all_filesystems = 1,
> + .cleanup = cleanup,
> + .test_all = run,
> +};
> --
> 2.13.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
next prev parent reply other threads:[~2017-09-07 8:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 16:09 [LTP] [RFC] [PATCH 01/15] lib/tst_mkfs: Clear first 512k of the device Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 02/15] lib: Add interface to list supported filesystems Cyril Hrubis
2017-09-07 7:48 ` Jan Stancek
2017-09-07 8:25 ` Jan Stancek
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 03/15] SAFE_MOUNT: Handle FUSE mounts as well Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 04/15] lib/tst_test: Add .all_filesystems flag Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 05/15] lib/tst_fs: Add tst_fill_fs() Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 06/15] syscalls/fallocate05: New test Cyril Hrubis
2017-09-07 8:51 ` Jan Stancek [this message]
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 07/15] syscalls/msync04: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 08/15] syscalls/fallocate04: Convert to the new library Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 09/15] syscalls/fallocate04: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 10/15] syscalls/setxattr01: Convert to the new library Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 11/15] syscalls/setxattr01: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 12/15] syscallse/setxattr02: Convert to the new library Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 13/15] syscalls/fsync01: " Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 14/15] syscalls/fsync01: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 15/15] fs/fs_fill: Add a test to fill a FS in a few threads Cyril Hrubis
2017-09-07 9:13 ` Jan Stancek
2017-09-07 7:42 ` [LTP] [RFC] [PATCH 01/15] lib/tst_mkfs: Clear first 512k of the device Jan Stancek
2017-09-07 8:34 ` 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=1530936082.10130435.1504774294954.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.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