diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-02-26 01:24:48 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-02-26 01:24:48 +0100 |
| commit | ea63ad9560757e56505551db3bf2e1c31be5c76c (patch) | |
| tree | ec0f539b89d9c8ac627e65886241cc086246ab09 /test/remake_id_test.cc | |
| parent | cbb8260e395058da76b3de518ebc535a114c54b1 (diff) | |
More verification of DCPs during tests.
Diffstat (limited to 'test/remake_id_test.cc')
| -rw-r--r-- | test/remake_id_test.cc | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/test/remake_id_test.cc b/test/remake_id_test.cc index 8f8ab820b..c4953f980 100644 --- a/test/remake_id_test.cc +++ b/test/remake_id_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" #include "lib/text_content.h" @@ -30,11 +31,14 @@ #include <boost/test/unit_test.hpp> #include <iostream> + using std::string; using std::vector; using std::shared_ptr; -using boost::optional; using std::dynamic_pointer_cast; +using std::make_shared; +using boost::optional; + /** Check for bug #1126 whereby making a new DCP using the same video asset as an old one * corrupts the old one. @@ -42,54 +46,47 @@ using std::dynamic_pointer_cast; BOOST_AUTO_TEST_CASE (remake_id_test1) { /* Make a DCP */ - shared_ptr<Film> film = new_test_film2 ("remake_id_test1_1"); - shared_ptr<Content> content = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("remake_id_test1_1", {content}); + make_and_verify_dcp (film); /* Copy the video file */ - boost::filesystem::path first_video = dcp_file(film, "j2c"); + auto first_video = dcp_file(film, "j2c"); boost::filesystem::copy_file (first_video, first_video.string() + ".copy"); /* Make a new DCP with the same video file */ film->set_name ("remake_id_test1_2"); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); /* Check that the video in the first DCP hasn't changed */ check_file (first_video, first_video.string() + ".copy"); } + /** Check for bug #1232 where remaking an encrypted DCP causes problems with HMAC IDs (?) */ BOOST_AUTO_TEST_CASE (remake_id_test2) { /* Make a DCP */ - shared_ptr<Film> film = new_test_film2 ("remake_id_test2_1"); - shared_ptr<Content> content = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (content); + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("remake_id_test2_1", {content}); film->set_encrypted (true); - BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); /* Remove and remake it */ boost::filesystem::remove_all(film->dir(film->dcp_name())); - film->make_dcp(); - BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp (film); /* Find the CPL */ optional<boost::filesystem::path> cpl; - for (boost::filesystem::directory_iterator i(film->dir(film->dcp_name())); i != boost::filesystem::directory_iterator(); ++i) { - if (i->path().filename().string().substr(0, 4) == "cpl_") { - cpl = i->path(); + for (auto i: boost::filesystem::directory_iterator(film->dir(film->dcp_name()))) { + if (i.path().filename().string().substr(0, 4) == "cpl_") { + cpl = i.path(); } } BOOST_REQUIRE(cpl); /* Make a DKDM */ - dcp::EncryptedKDM kdm = film->make_kdm ( + auto kdm = film->make_kdm ( Config::instance()->decryption_chain()->leaf(), vector<string>(), *cpl, @@ -101,13 +98,10 @@ BOOST_AUTO_TEST_CASE (remake_id_test2) ); /* Import the DCP into a new film */ - shared_ptr<Film> film2 = new_test_film2("remake_id_test2_2"); - shared_ptr<DCPContent> dcp_content(new DCPContent(film->dir(film->dcp_name()))); - film2->examine_and_add_content(dcp_content); - BOOST_REQUIRE(!wait_for_jobs()); + auto dcp_content = make_shared<DCPContent>(film->dir(film->dcp_name())); + auto film2 = new_test_film2("remake_id_test2_2", {dcp_content}); dcp_content->add_kdm(kdm); - JobManager::instance()->add(shared_ptr<Job>(new ExamineContentJob(film2, dcp_content))); - BOOST_REQUIRE(!wait_for_jobs()); - film2->make_dcp(); + JobManager::instance()->add(make_shared<ExamineContentJob>(film2, dcp_content)); BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp (film2); } |
