summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-20 11:38:58 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-21 18:55:16 +0200
commit30a0a1ea15303e4c2e18395fab5f419450f19e97 (patch)
tree59b37ebf1440ac00e7fe7835cd2725b9b338e092
parent8b38c3523b061883c3d320bd2e38afffe7424f4d (diff)
Use empty files where possible to speed things up a lot.
-rw-r--r--test/disk_writer_test.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/disk_writer_test.cc b/test/disk_writer_test.cc
index a27da0c5f..dae991e58 100644
--- a/test/disk_writer_test.cc
+++ b/test/disk_writer_test.cc
@@ -58,6 +58,18 @@ ext2_ls (vector<string> arguments)
}
+static
+void
+make_empty_file(boost::filesystem::path file, off_t size)
+{
+ auto fd = open (file.string().c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ BOOST_REQUIRE (fd != -1);
+ auto const r = posix_fallocate (fd, 0, size);
+ BOOST_REQUIRE_EQUAL (r, 0);
+ close (fd);
+}
+
+
/** Use the writer code to make a disk and partition and copy a file (in a directory)
* to it, then check that:
* - the partition has inode size 128
@@ -147,8 +159,9 @@ BOOST_AUTO_TEST_CASE (disk_writer_test2)
cl.add(disk);
cl.add(partition);
- make_random_file(disk, 31043616768LL);
- make_random_file(partition, 31043571712LL);
+ /* Using empty files here still triggers the bug and is much quicker than using random data */
+ make_empty_file(disk, 31043616768LL);
+ make_empty_file(partition, 31043571712LL);
auto const dcp = TestPaths::private_data() / "xm";
dcpomatic::write(dcp, disk.string(), partition.string(), nullptr);