Reduce test flakyness a bit.
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Jun 2021 23:27:33 +0000 (01:27 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Jun 2021 23:44:34 +0000 (01:44 +0200)
test/interop_subtitle_test.cc
test/verify_test.cc

index 7fa0e2d142afb8c80e3809210de9701b52953b60..d0d44bb8d95037fd241e8c7f0be50d4fe72b2138 100644 (file)
@@ -859,8 +859,8 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
                );
 
        check_xml (
-               dcp::file_to_string("test/ref/write_interop_subtitle_test3/pkl.xml"),
-               dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
+               dcp::file_to_string(find_file("test/ref/write_interop_subtitle_test3", "pkl")),
+               dcp::file_to_string(find_file("build/test/write_interop_subtitle_test3", "pkl")),
                vector<string>()
                );
 }
index 417b456344b6460bfc5677fbea589e1a7327abd1..dd95ef6ecf1c5890d3c310c303fa0e1c301fd53e 100644 (file)
@@ -74,13 +74,25 @@ using std::shared_ptr;
 
 
 static list<pair<string, optional<path>>> stages;
-static string const dcp_test1_pkl_id = "6af1e0c1-c441-47f8-a502-3efd46b1fa4f";
-static string const dcp_test1_pkl = "pkl_" + dcp_test1_pkl_id + ".xml";
-static string const dcp_test1_cpl_id = "81fb54df-e1bf-4647-8788-ea7ba154375b";
-static string const dcp_test1_cpl = "cpl_" + dcp_test1_cpl_id + ".xml";
+
+static string filename_to_id(boost::filesystem::path path)
+{
+       return path.string().substr(4, path.string().length() - 8);
+}
+
+static boost::filesystem::path const dcp_test1_pkl = find_file("test/ref/DCP/dcp_test1", "pkl_").filename();
+static string const dcp_test1_pkl_id = filename_to_id(dcp_test1_pkl);
+
+static boost::filesystem::path const dcp_test1_cpl = find_file("test/ref/DCP/dcp_test1", "cpl_").filename();
+static string const dcp_test1_cpl_id = filename_to_id(dcp_test1_cpl);
+
 static string const dcp_test1_asset_map_id = "5d51e8a1-b2a5-4da6-9b66-4615c3609440";
-static string const encryption_test_cpl_id = "81fb54df-e1bf-4647-8788-ea7ba154375b";
-static string const encryption_test_pkl_id = "627ad740-ae36-4c49-92bb-553a9f09c4f8";
+
+static boost::filesystem::path const encryption_test_cpl = find_file("test/ref/DCP/encryption_test", "cpl_").filename();
+static string const encryption_test_cpl_id = filename_to_id(encryption_test_cpl);
+
+static boost::filesystem::path const encryption_test_pkl = find_file("test/ref/DCP/encryption_test", "pkl_").filename();
+static string const encryption_test_pkl_id = filename_to_id(encryption_test_pkl);
 
 static void
 stage (string s, optional<path> p)
@@ -166,6 +178,23 @@ public:
                BOOST_REQUIRE (_content != old_content);
        }
 
+       void delete_first_line_containing (string s)
+       {
+               vector<string> lines;
+               boost::algorithm::split (lines, _content, boost::is_any_of("\r\n"), boost::token_compress_on);
+               auto old_content = _content;
+               _content = "";
+               bool done = false;
+               for (auto i: lines) {
+                       if (i.find(s) == string::npos || done) {
+                               _content += i + "\n";
+                       } else {
+                               done = true;
+                       }
+               }
+               BOOST_REQUIRE (_content != old_content);
+       }
+
        void delete_lines (string from, string to)
        {
                vector<string> lines;
@@ -343,9 +372,9 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_picture_sound_hashes)
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, dcp_test1_cpl_id, canonical(dir / dcp_test1_cpl) },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_PICTURE_HASHES, canonical(dir / "video.mxf") },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_SOUND_HASHES, canonical(dir / "audio.mxf") },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xSEEi70vx1WQs67bmu2zKvzIkXvY=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 12 },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xaddO7je2lZSNQp55qjCWo5DLKFQ=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 19 },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xWU0/u1wM17y7Kriq06+65/ViX1o=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 26 }
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xD9HpNAjKsECGtJEWtwV2/T5ndG8=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 26 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xgVKhC9IkWyzQbgzpFcJ1bpqbtwk=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 19 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xz/y4fI+ocWzVB7cr8pVt2OYpOHA=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 12 }
                });
 }
 
@@ -2256,18 +2285,21 @@ BOOST_AUTO_TEST_CASE (verify_missing_hash)
 
        BOOST_REQUIRE_EQUAL (dcp->cpls().size(), 1U);
        auto const cpl = dcp->cpls()[0];
+       BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
+       BOOST_REQUIRE (cpl->reels()[0]->main_picture());
+       auto asset_id = cpl->reels()[0]->main_picture()->id();
 
        {
                BOOST_REQUIRE (cpl->file());
                Editor e(cpl->file().get());
-               e.replace("<Hash>addO7je2lZSNQp55qjCWo5DLKFQ=</Hash>", "");
+               e.delete_first_line_containing("<Hash>");
        }
 
        check_verify_result (
                {dir},
                {
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, cpl->id(), cpl->file().get() },
-                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_HASH, string("1fab8bb0-cfaf-4225-ad6d-01768bc10470") }
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_HASH, asset_id }
                });
 }