* [LTP] [PATCH v5 0/2] Convert fallocate testing suite
@ 2026-08-27 8:22 Andrea Cervesato
2026-08-27 8:22 ` [LTP] [PATCH v5 1/2] fallocate01: Convert to new API Andrea Cervesato
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Andrea Cervesato @ 2026-08-27 8:22 UTC (permalink / raw)
To: Linux Test Project
Testing a new multi-agent converter that does a deep analysis on the
code, evaluate if it needs to be converted line by line or it only needs
a complete rewrite, then it spawn an agent for writing the test, one for
reviewing and it iterates until test is out of issues.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v5:
- fallocate01: handle ENOSYS in setup()
- Link to v4: https://lore.kernel.org/20260827-convert_fallocate_suite-v4-0-cb146b9e5623@suse.com
Changes in v4:
- fallocate01: make sure we handle ENOTSUPP
- Link to v3: https://lore.kernel.org/20260826-convert_fallocate_suite-v3-0-1286ede0493d@suse.com
Changes in v3:
- fallocate01: all filesystems, check for ENOSYS/ENOTSUPP, use TST_EXP_*
- fallocate02: check for ENOSYS/ENOTSUPP
- Link to v2: https://lore.kernel.org/20260807-convert_fallocate_suite-v2-0-3761f7b74b1f@suse.com
Changes in v2:
- fix fname size
- simplify commit messages
- Link to v1: https://lore.kernel.org/20260720-convert_fallocate_suite-v1-0-50ae85c56c03@suse.com
To: Linux Test Project <ltp@lists.linux.it>
---
Andrea Cervesato (2):
fallocate01: Convert to new API
fallocate02: Convert to new API
testcases/kernel/syscalls/fallocate/fallocate01.c | 344 +++++++---------------
testcases/kernel/syscalls/fallocate/fallocate02.c | 192 ++++--------
2 files changed, 162 insertions(+), 374 deletions(-)
---
base-commit: 9118a480cc68700f27944aab817e0202e9e6136c
change-id: 20260720-convert_fallocate_suite-820312fbf352
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v5 1/2] fallocate01: Convert to new API
2026-08-27 8:22 [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato
@ 2026-08-27 8:22 ` Andrea Cervesato
2026-08-27 11:48 ` Cyril Hrubis
2026-08-27 12:04 ` Andrea Cervesato via ltp
2026-08-27 8:22 ` [LTP] [PATCH v5 2/2] fallocate02: " Andrea Cervesato
2026-08-27 12:04 ` [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato via ltp
2 siblings, 2 replies; 8+ messages in thread
From: Andrea Cervesato @ 2026-08-27 8:22 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
Convert the fallocate01 test case from the legacy LTP API (test.h) to the
new tst_test API using a table-driven struct tcase[] and TST_EXP_* macros.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/syscalls/fallocate/fallocate01.c | 344 +++++++---------------
1 file changed, 101 insertions(+), 243 deletions(-)
diff --git a/testcases/kernel/syscalls/fallocate/fallocate01.c b/testcases/kernel/syscalls/fallocate/fallocate01.c
index d21936eba..97c3ee3e4 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate01.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate01.c
@@ -1,274 +1,132 @@
-/******************************************************************************
- * fallocate01.c
- * Mon Dec 24 2007
- * Copyright (c) International Business Machines Corp., 2007
- * Emali : sharyathi@in.ibm.com
- ******************************************************************************/
-
-/***************************************************************************
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-***************************************************************************/
-
-/*****************************************************************************
- *
- * OS Test - International Business Machines Corp. 2007.
- *
- * TEST IDENTIFIER : fallocate01
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Basic test for fallocate()
- *
- * TEST CASE TOTAL : 2
- *
- * CPU ARCHITECTURES : PPC,X86, X86_64
- *
- * AUTHOR : Sharyathi Nagesh
- *
- * CO-PILOT :
- *
- * DATE STARTED : 24/12/2007
- *
- * TEST CASES
- * (Working of fallocate under 2 modes)
- * 1) DEFAULT 2)FALLOC_FL_KEEP_SIZE
- *
- * INPUT SPECIFICATIONS
- * No input needs to be specified
- * fallocate() in puts are generated randomly
- *
- * OUTPUT SPECIFICATIONS
- * Output describing whether test cases passed or failed.
- *
- * ENVIRONMENTAL NEEDS
- * Test Needs to be executed on file system supporting ext4
- * LTP {TMP} Needs to be set to such a folder
- *
- * SPECIAL PROCEDURAL REQUIREMENTS
- * None
- *
- * DETAILED DESCRIPTION
- * This is a test case for fallocate() system call.
- * This test suite tests basic working of fallocate under different modes
- * It trys to fallocate memory blocks and write into that block
- *
- * Total 2 Test Cases :-
- * (1) Test Case for DEFAULT MODE
- * (2) Test Case for FALLOC_FL_KEEP_SIZE
- *
- * Setup:
- * Setup file on which fallocate is to be called
- * Set up 2 files for each mode
- *
- * Test:
- * Loop if the proper options are given.
- * Execute system call
- * Check return code, if system call did fail
- * lseek to some random location with in allocate block
- * write data into the locattion Report if any error encountered
- * PASS the test otherwise
- *
- * Cleanup:
- * Cleanup the temporary folder
- *
-*************************************************************************/
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) International Business Machines Corp., 2007
+ * Author: Sharyathi Nagesh <sharyathi@in.ibm.com>
+ * Copyright (c) Linux Test Project, 2008-2024
+ */
+
+/*\
+ * Basic test for :manpage:`fallocate(2)` covering the two preallocation
+ * modes and their effect on the file size.
+ *
+ * A file is pre-populated to 12 blocks and a single extra block is
+ * preallocated past the end of the file. The test verifies that the
+ * resulting file size matches the mode semantics and that the newly
+ * allocated region is writable.
+ *
+ * [Algorithm]
+ *
+ * - Populate the working file with 12 blocks of block_size bytes.
+ * - Preallocate one block at the end of the file.
+ * - In DEFAULT_MODE the file grows to 13 blocks.
+ * - In FALLOC_FL_KEEP_SIZE mode the file size stays at 12 blocks.
+ * - Seek into the newly allocated region and write a byte to it.
+ */
#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <endian.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <sys/utsname.h>
-
-#include "test.h"
-#include "tso_safe_macros.h"
+#include "tst_test.h"
#include "lapi/fallocate.h"
-#include "lapi/fcntl.h"
+#define MNTPOINT "mntpoint"
+#define FNAME MNTPOINT "/tfile"
#define BLOCKS_WRITTEN 12
-void get_blocksize(int);
-void populate_files(int fd);
-void runtest(int, int, loff_t);
-
-char *TCID = "fallocate01";
-char fname_mode1[255], fname_mode2[255]; /* Files used for testing */
-int fd_mode1, fd_mode2;
-int TST_TOTAL = 2;
-loff_t block_size;
-int buf_size;
-
-/******************************************************************************
- * Performs all one time clean up for this test on successful
- * completion, premature exit or failure. Closes all temporary
- * files, removes all temporary directories exits the test with
- * appropriate return code by calling tst_exit() function.
-******************************************************************************/
-void cleanup(void)
-{
+static int fd = -1;
+static int block_size;
- if (close(fd_mode1) == -1)
- tst_resm(TWARN | TERRNO, "close(%s) failed", fname_mode1);
- if (close(fd_mode2) == -1)
- tst_resm(TWARN | TERRNO, "close(%s) failed", fname_mode2);
- tst_rmdir();
-}
+static struct tcase {
+ int mode;
+ int expected_blocks;
+ const char *desc;
+} tcases[] = {
+ {0, BLOCKS_WRITTEN + 1, "DEFAULT_MODE"},
+ {FALLOC_FL_KEEP_SIZE, BLOCKS_WRITTEN, "FALLOC_FL_KEEP_SIZE"},
+};
-/*****************************************************************************
- * Performs all one time setup for this test. This function is
- * used to create temporary dirs and temporary files
- * that may be used in the course of this test
- ******************************************************************************/
-void setup(void)
+static void populate_file(void)
{
- /* Create temporary directories */
- TEST_PAUSE;
+ char buf[block_size];
- tst_tmpdir();
+ for (int blocks = 0; blocks < BLOCKS_WRITTEN; blocks++) {
+ for (int i = 0; i < block_size; i++)
+ buf[i] = 'A' + (i % 26);
- sprintf(fname_mode1, "tfile_mode1_%d", getpid());
- fd_mode1 = SAFE_OPEN(cleanup, fname_mode1, O_RDWR | O_CREAT, 0700);
- get_blocksize(fd_mode1);
- populate_files(fd_mode1);
-
- sprintf(fname_mode2, "tfile_mode2_%d", getpid());
- fd_mode2 = SAFE_OPEN(cleanup, fname_mode2, O_RDWR | O_CREAT, 0700);
- populate_files(fd_mode2);
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, buf, block_size);
+ }
}
-/*****************************************************************************
- * Gets the block size for the file system
- ******************************************************************************/
-void get_blocksize(int fd)
+static void setup(void)
{
struct stat file_stat;
- if (fstat(fd, &file_stat) < 0)
- tst_resm(TFAIL | TERRNO,
- "fstat failed while getting block_size");
-
- block_size = file_stat.st_blksize;
- buf_size = block_size;
-}
-
-/*****************************************************************************
- * Writes data into the file
- ******************************************************************************/
+ TEST(fallocate(-1, 0, 0, 0));
+ if (TST_ERR == ENOSYS)
+ tst_brk(TCONF, "fallocate() not supported");
-void populate_files(int fd)
-{
- char buf[buf_size + 1];
- int index;
- int blocks;
- int data;
+ fd = SAFE_OPEN(FNAME, O_RDWR | O_CREAT, 0700);
- for (blocks = 0; blocks < BLOCKS_WRITTEN; blocks++) {
- for (index = 0; index < buf_size; index++)
- buf[index] = 'A' + (index % 26);
- buf[buf_size] = '\0';
- if ((data = write(fd, buf, buf_size)) == -1)
- tst_brkm(TBROK | TERRNO, cleanup, "write failed");
- }
+ SAFE_FSTAT(fd, &file_stat);
+ block_size = (int)file_stat.st_blksize;
}
-int main(int ac, char **av)
+static void run(unsigned int n)
{
- loff_t expected_size;
- int lc;
+ struct tcase *tc = &tcases[n];
+ struct stat file_stat;
+ loff_t offset, len, pos, write_offset, expected_size;
+
+ /* Reset the backing file to a pristine 12-block state per run. */
+ SAFE_FTRUNCATE(fd, 0);
+ SAFE_LSEEK(fd, 0, SEEK_SET);
+ populate_file();
+
+ offset = SAFE_LSEEK(fd, 0, SEEK_END);
+ len = block_size;
+ expected_size = (loff_t)tc->expected_blocks * block_size;
+
+ TEST(fallocate(fd, tc->mode, offset, len));
+ if (TST_RET != 0) {
+ if (TST_ERR == EOPNOTSUPP) {
+ tst_res(TCONF | TTERRNO,
+ "fallocate(%s, %lld, %lld) not supported",
+ tc->desc, (long long)offset, (long long)len);
+ return;
+ }
- tst_parse_opts(ac, av, NULL, NULL);
+ tst_res(TFAIL | TTERRNO,
+ "fallocate(%s, %lld, %lld) failed",
+ tc->desc, (long long)offset, (long long)len);
+ return;
+ }
- setup();
+ tst_res(TPASS, "fallocate(%s, %lld, %lld) passed",
+ tc->desc, (long long)offset, (long long)len);
- for (lc = 0; TEST_LOOPING(lc); lc++) {
- tst_count = 0;
+ SAFE_FSTAT(fd, &file_stat);
+ TST_EXP_EQ_LI(file_stat.st_size, expected_size);
- expected_size = BLOCKS_WRITTEN * block_size + block_size;
- runtest(0, fd_mode1, expected_size);
+ write_offset = len / 2;
+ pos = SAFE_LSEEK(fd, write_offset, SEEK_CUR);
+ TST_EXP_EQ_LI(pos, offset + write_offset);
- expected_size = BLOCKS_WRITTEN * block_size;
- runtest(FALLOC_FL_KEEP_SIZE, fd_mode2, expected_size);
- }
-
- cleanup();
- tst_exit();
+ TST_EXP_POSITIVE(write(fd, "A", 1),
+ "write into the newly allocated region");
}
-/*****************************************************************************
- * Calls the system call, with appropriate parameters and writes data
- ******************************************************************************/
-void runtest(int mode, int fd, loff_t expected_size)
+static void cleanup(void)
{
- loff_t offset;
- loff_t len = block_size;
- loff_t write_offset, lseek_offset;
- offset = lseek(fd, 0, SEEK_END);
- struct stat file_stat;
- errno = 0;
-
- TEST(fallocate(fd, mode, offset, len));
- /* check return code */
- if (TEST_RETURN != 0) {
- if (TEST_ERRNO == EOPNOTSUPP || TEST_ERRNO == ENOSYS) {
- tst_brkm(TCONF, cleanup,
- "fallocate system call is not implemented");
- }
- tst_resm(TFAIL | TTERRNO,
- "fallocate(%d, %d, %" PRId64 ", %" PRId64 ") failed",
- fd, mode, offset, len);
- return;
- } else {
- tst_resm(TPASS,
- "fallocate(%d, %d, %" PRId64 ", %" PRId64
- ") returned %ld", fd, mode, offset, len,
- TEST_RETURN);
- }
-
- if (fstat(fd, &file_stat) < 0)
- tst_resm(TFAIL | TERRNO, "fstat failed after fallocate()");
-
- if (file_stat.st_size != expected_size)
- tst_resm(TFAIL | TERRNO,
- "fstat test fails on fallocate (%d, %d, %" PRId64 ", %"
- PRId64 ") Failed on mode", fd, mode, offset, len);
-
- write_offset = random() % len;
- lseek_offset = lseek(fd, write_offset, SEEK_CUR);
- if (lseek_offset != offset + write_offset) {
- tst_resm(TFAIL | TERRNO,
- "lseek fails in fallocate(%d, %d, %" PRId64 ", %"
- PRId64 ") failed on mode", fd, mode, offset, len);
- return;
- }
- //Write a character to file at random location
- TEST(write(fd, "A", 1));
- /* check return code */
- if (TEST_RETURN == -1) {
- tst_resm(TFAIL | TTERRNO,
- "write fails in fallocate(%d, %d, %" PRId64 ", %"
- PRId64 ") failed", fd, mode, offset, len);
- } else {
- tst_resm(TPASS,
- "write operation on fallocated(%d, %d, %"
- PRId64 ", %" PRId64 ") returned %ld", fd, mode,
- offset, len, TEST_RETURN);
- }
+ if (fd != -1)
+ SAFE_CLOSE(fd);
}
+
+static struct tst_test test = {
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
+ .setup = setup,
+ .cleanup = cleanup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(tcases),
+};
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH v5 2/2] fallocate02: Convert to new API
2026-08-27 8:22 [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato
2026-08-27 8:22 ` [LTP] [PATCH v5 1/2] fallocate01: Convert to new API Andrea Cervesato
@ 2026-08-27 8:22 ` Andrea Cervesato
2026-08-27 11:56 ` Cyril Hrubis
2026-08-27 12:04 ` Andrea Cervesato via ltp
2026-08-27 12:04 ` [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato via ltp
2 siblings, 2 replies; 8+ messages in thread
From: Andrea Cervesato @ 2026-08-27 8:22 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
Convert the fallocate02 test case from the legacy LTP API (test.h) to the
new tst_test API using a table-driven struct tcase[] and TST_EXP_FAIL for
each error-path oracle.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/syscalls/fallocate/fallocate02.c | 192 +++++++---------------
1 file changed, 61 insertions(+), 131 deletions(-)
diff --git a/testcases/kernel/syscalls/fallocate/fallocate02.c b/testcases/kernel/syscalls/fallocate/fallocate02.c
index 4469f02f2..0a25a5611 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate02.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate02.c
@@ -1,164 +1,94 @@
-/******************************************************************************
- * Copyright (c) International Business Machines Corp., 2007
- * Author: Sharyathi Nagesh <sharyathi@in.ibm.com>
- ******************************************************************************/
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) International Business Machines Corp., 2007
+ * Author: Sharyathi Nagesh <sharyathi@in.ibm.com>
+ * Copyright (c) Linux Test Project, 2026
+ */
-/***************************************************************************
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+/*\
+ * Verify that :manpage:`fallocate(2)` fails with the expected error codes:
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-***************************************************************************/
-
-/*
- * DESCRIPTION
- * check fallocate() with various error conditions that should produce
- * EBADF, EINVAL and EFBIG.
+ * - EBADF when the file descriptor is opened read-only.
+ * - EINVAL when the offset or length is negative, or the length is zero.
+ * - EFBIG when the requested range exceeds the maximum file size (only
+ * tested on 64-bit offset ABIs).
*/
#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <endian.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <sys/utsname.h>
-#include <limits.h>
-
-#include "test.h"
-#include "tso_safe_macros.h"
+#include "tst_test.h"
#include "lapi/fallocate.h"
#include "lapi/abisize.h"
-#define BLOCKS_WRITTEN 12
-#ifdef TEST_DEFAULT
-# define DEFAULT_TEST_MODE 0
-#else
-# define DEFAULT_TEST_MODE 1
-#endif
-#define OFFSET 12
-#define FNAMER "test_file1"
-#define FNAMEW "test_file2"
-#define BLOCK_SIZE 1024
-#define MAX_FILESIZE (LLONG_MAX / 1024)
-
-static void setup(void);
-static void fallocate_verify(int);
-static void cleanup(void);
+#define BLOCKS_WRITTEN 12
+#define OFFSET 12
+#define FNAMER "test_file1"
+#define FNAMEW "test_file2"
+#define BLOCK_SIZE 1024
+#define MAX_FILESIZE (LLONG_MAX / BLOCK_SIZE)
-static int fdw;
-static int fdr;
+static int fdr = -1;
+static int fdw = -1;
-static struct test_data_t {
+static struct tcase {
int *fd;
- char *fname;
- int mode;
loff_t offset;
loff_t len;
- int error;
-} test_data[] = {
- {&fdr, FNAMER, DEFAULT_TEST_MODE, 0, 1, EBADF},
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, -1, 1, EINVAL},
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, 1, -1, EINVAL},
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, BLOCKS_WRITTEN, 0, EINVAL},
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, BLOCKS_WRITTEN, -1, EINVAL},
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, -(BLOCKS_WRITTEN+OFFSET), 1, EINVAL},
+ int exp_errno;
+} tcases[] = {
+ {&fdr, 0, 1, EBADF},
+ {&fdw, -1, 1, EINVAL},
+ {&fdw, 1, -1, EINVAL},
+ {&fdw, BLOCKS_WRITTEN, 0, EINVAL},
+ {&fdw, BLOCKS_WRITTEN, -1, EINVAL},
+ {&fdw, -(BLOCKS_WRITTEN + OFFSET), 1, EINVAL},
#if defined(TST_ABI64) || _FILE_OFFSET_BITS == 64
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, MAX_FILESIZE, 1, EFBIG},
- {&fdw, FNAMEW, DEFAULT_TEST_MODE, 1, MAX_FILESIZE, EFBIG},
+ {&fdw, MAX_FILESIZE, 1, EFBIG},
+ {&fdw, 1, MAX_FILESIZE, EFBIG},
#endif
};
-TCID_DEFINE(fallocate02);
-int TST_TOTAL = ARRAY_SIZE(test_data);
-
-int main(int ac, char **av)
-{
- int lc;
- int i;
-
- tst_parse_opts(ac, av, NULL, NULL);
-
- setup();
-
- for (lc = 0; TEST_LOOPING(lc); lc++) {
-
- tst_count = 0;
-
- for (i = 0; i < TST_TOTAL; i++)
- fallocate_verify(i);
- }
-
- cleanup();
-
- tst_exit();
-}
-
static void setup(void)
{
+ char buf[BLOCK_SIZE];
int i;
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
-
- tst_tmpdir();
+ TEST(fallocate(-1, 0, 0, 0));
+ if (TST_ERR == EOPNOTSUPP || TST_ERR == ENOSYS)
+ tst_brk(TCONF, "fallocate() not supported");
- fdr = SAFE_OPEN(cleanup, FNAMER, O_RDONLY | O_CREAT, S_IRUSR);
+ fdr = SAFE_OPEN(FNAMER, O_RDONLY | O_CREAT, 0400);
+ fdw = SAFE_OPEN(FNAMEW, O_RDWR | O_CREAT, 0700);
- fdw = SAFE_OPEN(cleanup, FNAMEW, O_RDWR | O_CREAT, S_IRWXU);
-
- char buf[BLOCK_SIZE];
memset(buf, 'A', BLOCK_SIZE);
for (i = 0; i < BLOCKS_WRITTEN; i++)
- SAFE_WRITE(cleanup, SAFE_WRITE_ALL, fdw, buf, BLOCK_SIZE);
+ SAFE_WRITE(SAFE_WRITE_ALL, fdw, buf, BLOCK_SIZE);
}
-static void fallocate_verify(int i)
+static void cleanup(void)
{
- TEST(fallocate(*test_data[i].fd, test_data[i].mode,
- test_data[i].offset * BLOCK_SIZE,
- test_data[i].len * BLOCK_SIZE));
- if (TEST_ERRNO != test_data[i].error) {
- if (TEST_ERRNO == EOPNOTSUPP ||
- TEST_ERRNO == ENOSYS) {
- tst_brkm(TCONF, cleanup,
- "fallocate system call is not implemented");
- }
- tst_resm(TFAIL | TTERRNO,
- "fallocate(%s:%d, %d, %" PRId64 ", %" PRId64 ") "
- "failed, expected errno:%d", test_data[i].fname,
- *test_data[i].fd, test_data[i].mode,
- test_data[i].offset * BLOCK_SIZE,
- test_data[i].len * BLOCK_SIZE, test_data[i].error);
- } else {
- tst_resm(TPASS | TTERRNO,
- "fallocate(%s:%d, %d, %" PRId64 ", %" PRId64 ") "
- "returned %d", test_data[i].fname, *test_data[i].fd,
- test_data[i].mode, test_data[i].offset * BLOCK_SIZE,
- test_data[i].len * BLOCK_SIZE, TEST_ERRNO);
- }
+ if (fdw != -1)
+ SAFE_CLOSE(fdw);
+ if (fdr != -1)
+ SAFE_CLOSE(fdr);
}
-static void cleanup(void)
+static void verify_fallocate(unsigned int n)
{
- if (fdw > 0)
- SAFE_CLOSE(NULL, fdw);
- if (fdr > 0)
- SAFE_CLOSE(NULL, fdr);
-
- tst_rmdir();
+ struct tcase *tc = &tcases[n];
+
+ TST_EXP_FAIL(fallocate(*tc->fd, FALLOC_FL_KEEP_SIZE,
+ tc->offset * BLOCK_SIZE,
+ tc->len * BLOCK_SIZE), tc->exp_errno,
+ "fallocate(%d, %lld, %lld)", *tc->fd,
+ (long long)(tc->offset * BLOCK_SIZE),
+ (long long)(tc->len * BLOCK_SIZE));
}
+
+static struct tst_test test = {
+ .setup = setup,
+ .cleanup = cleanup,
+ .test = verify_fallocate,
+ .tcnt = ARRAY_SIZE(tcases),
+ .needs_tmpdir = 1,
+};
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v5 1/2] fallocate01: Convert to new API
2026-08-27 8:22 ` [LTP] [PATCH v5 1/2] fallocate01: Convert to new API Andrea Cervesato
@ 2026-08-27 11:48 ` Cyril Hrubis
2026-08-27 12:04 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2026-08-27 11:48 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v5 2/2] fallocate02: Convert to new API
2026-08-27 8:22 ` [LTP] [PATCH v5 2/2] fallocate02: " Andrea Cervesato
@ 2026-08-27 11:56 ` Cyril Hrubis
2026-08-27 12:04 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2026-08-27 11:56 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v5 0/2] Convert fallocate testing suite
2026-08-27 8:22 [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato
2026-08-27 8:22 ` [LTP] [PATCH v5 1/2] fallocate01: Convert to new API Andrea Cervesato
2026-08-27 8:22 ` [LTP] [PATCH v5 2/2] fallocate02: " Andrea Cervesato
@ 2026-08-27 12:04 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 8+ messages in thread
From: Andrea Cervesato via ltp @ 2026-08-27 12:04 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Merged, Thanks!
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v5 2/2] fallocate02: Convert to new API
2026-08-27 8:22 ` [LTP] [PATCH v5 2/2] fallocate02: " Andrea Cervesato
2026-08-27 11:56 ` Cyril Hrubis
@ 2026-08-27 12:04 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 8+ messages in thread
From: Andrea Cervesato via ltp @ 2026-08-27 12:04 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Merged, Thanks!
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v5 1/2] fallocate01: Convert to new API
2026-08-27 8:22 ` [LTP] [PATCH v5 1/2] fallocate01: Convert to new API Andrea Cervesato
2026-08-27 11:48 ` Cyril Hrubis
@ 2026-08-27 12:04 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 8+ messages in thread
From: Andrea Cervesato via ltp @ 2026-08-27 12:04 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Merged, Thanks!
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-08-27 12:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27 8:22 [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato
2026-08-27 8:22 ` [LTP] [PATCH v5 1/2] fallocate01: Convert to new API Andrea Cervesato
2026-08-27 11:48 ` Cyril Hrubis
2026-08-27 12:04 ` Andrea Cervesato via ltp
2026-08-27 8:22 ` [LTP] [PATCH v5 2/2] fallocate02: " Andrea Cervesato
2026-08-27 11:56 ` Cyril Hrubis
2026-08-27 12:04 ` Andrea Cervesato via ltp
2026-08-27 12:04 ` [LTP] [PATCH v5 0/2] Convert fallocate testing suite Andrea Cervesato via ltp
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.