From: Carl Hetherington Date: Mon, 20 Jun 2022 09:38:58 +0000 (+0200) Subject: Use empty files where possible to speed things up a lot. X-Git-Tag: v2.16.15~2 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=30a0a1ea15303e4c2e18395fab5f419450f19e97 Use empty files where possible to speed things up a lot. --- 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 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);