summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-18 20:25:12 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-21 18:55:16 +0200
commit6d686ea45f5cd01a0d11f92a903ac77779ad8562 (patch)
tree440e7541df792a2b81bc3ab49af2cbc4ff4b8c70
parent2c43d6e1068704cc4f4d6383217ed9a1a07bb67d (diff)
Fill test disk partitions with random noise to expose more bugs.
Without this, #2274 was not exposed by the test.
-rw-r--r--test/disk_writer_test.cc20
1 files changed, 4 insertions, 16 deletions
diff --git a/test/disk_writer_test.cc b/test/disk_writer_test.cc
index f22d27b9a..7b3778b67 100644
--- a/test/disk_writer_test.cc
+++ b/test/disk_writer_test.cc
@@ -40,18 +40,6 @@ using std::string;
using std::vector;
-static
-void
-create_empty (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);
-}
-
-
vector<string>
ext2_ls (vector<string> arguments)
{
@@ -91,8 +79,8 @@ BOOST_AUTO_TEST_CASE (disk_writer_test1)
/* lwext4 has a lower limit of correct ext2 partition sizes it can make; 32Mb
* does not work here: fsck gives errors about an incorrect free blocks count.
*/
- create_empty (disk, 256 * 1024 * 1024);
- create_empty (partition, 256 * 1024 * 1024);
+ make_random_file(disk, 256 * 1024 * 1024);
+ make_random_file(partition, 256 * 1024 * 1024);
path dcp = "build/test/disk_writer_test1";
create_directory (dcp);
@@ -156,8 +144,8 @@ BOOST_AUTO_TEST_CASE (disk_writer_test2)
cl.add(disk);
cl.add(partition);
- create_empty(disk, 4LL * 1024LL * 1024LL * 1024LL);
- create_empty(partition, 4LL * 1024LL * 1024LL * 1024LL);
+ make_random_file(disk, 4LL * 1024LL * 1024LL * 1024LL);
+ make_random_file(partition, 4LL * 1024LL * 1024LL * 1024LL);
auto const dcp = TestPaths::private_data() / "xm";
dcpomatic::write(dcp, disk.string(), partition.string(), 0);