[LTP] [PATCH v3] syscalls/sync_file_range: add partial file sync test-cases
Cyril Hrubis
chrubis@suse.cz
Wed Mar 27 15:48:26 CET 2019
Hi!
Sorry for the long delay.
This is altmost perfect, the only problem is that the third test fails
on vfat. As far as I can tell the reason is that vfat does not support
sparse files, hence seeking to the middle of file and writing there also
schedulles I/O to write zeros from the start of the file to the offset
we started writing to.
Following ugly patch solves the problem:
diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
index 334ea5e88..774524c2f 100644
--- a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
+++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
@@ -45,6 +45,12 @@ static void verify_sync_file_range(struct testcase *tc)
fd = SAFE_OPEN(tc->fname, O_RDWR|O_CREAT, MODE);
+ if (!strcmp(tst_device->fs_type, "vfat")) {
+ tst_res(TINFO, "Pre-filling file");
+ tst_fill_fd(fd, 0, tc->write_off, 1);
+ fsync(fd);
+ }
+
lseek(fd, tc->write_off, SEEK_SET);
So either we limit the tests so that the sync region does not overlap with the
possible hole at the start of the file and loose some test coverage.
Or we can add a function to the test library that would return true/false if
sparse files are supported for a given FS.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list