X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fdisk_writer_test.cc;h=60d7fe22aeff1f576a7e0caf45323bb0bb923e7c;hb=6e93ff6ac5b514d1b8dd9ccb2d6372576a52761a;hp=37c8f42d56cec9d3474f4965d9372c65ec8b0c19;hpb=81f2aee77e00dd46754f50d91c1e4a9e94441615;p=dcpomatic.git diff --git a/test/disk_writer_test.cc b/test/disk_writer_test.cc index 37c8f42d5..60d7fe22a 100644 --- a/test/disk_writer_test.cc +++ b/test/disk_writer_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -53,14 +53,13 @@ create_empty (boost::filesystem::path file, int size) vector -ext2_ls (string path) +ext2_ls (vector arguments) { using namespace boost::process; boost::asio::io_service ios; future data; - /* e2ls is from 'e2tools */ - child ch (search_path("e2ls"), path, std_in.close(), std_out > data, ios); + child ch (search_path("e2ls"), arguments, std_in.close(), std_out > data, ios); ios.run(); auto output = data.get(); @@ -71,9 +70,11 @@ ext2_ls (string path) } -/** Use the writer code to make a disk and partition and copy a file to it, then check - * that the partition has inode size 128 and that the file can be copied back off using - * e2tools. +/** 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 + * - the file and directory have reasonable timestamps + * - the file can be copied back off the disk */ BOOST_AUTO_TEST_CASE (disk_writer_test1) { @@ -98,7 +99,6 @@ BOOST_AUTO_TEST_CASE (disk_writer_test1) /* Some arbitrary file size here */ make_random_file (dcp / "foo", 1024 * 1024 * 32 - 6128); - PrivilegeEscalator::test = true; dcpomatic::write (dcp, disk.string(), partition.string(), 0); BOOST_CHECK_EQUAL (system("/sbin/e2fsck -fn build/test/disk_writer_test1.partition"), 0); @@ -117,8 +117,22 @@ BOOST_AUTO_TEST_CASE (disk_writer_test1) BOOST_CHECK_EQUAL (matches[1].str(), "128"); } - BOOST_CHECK (ext2_ls(partition.string()) == vector({"disk_writer_test1", "lost+found"})); - BOOST_CHECK (ext2_ls(partition.string() + ":disk_writer_test1") == vector({"foo"})); + BOOST_CHECK (ext2_ls({partition.string()}) == vector({"disk_writer_test1", "lost+found"})); + + string const unset_date = "1-Jan-1970"; + + /* Check timestamp of the directory has been set */ + auto details = ext2_ls({"-l", partition.string()}); + BOOST_REQUIRE (details.size() >= 6); + BOOST_CHECK (details[5] != unset_date); + + auto const dir = partition.string() + ":disk_writer_test1"; + BOOST_CHECK (ext2_ls({dir}) == vector({"foo"})); + + /* Check timestamp of foo */ + details = ext2_ls({"-l", dir}); + BOOST_REQUIRE (details.size() >= 6); + BOOST_CHECK (details[5] != unset_date); system ("e2cp " + partition.string() + ":disk_writer_test1/foo build/test/disk_writer_test1_foo_back"); check_file ("build/test/disk_writer_test1/foo", "build/test/disk_writer_test1_foo_back");