X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fdigest_test.cc;h=59a8cb7a772f8b7d92dbf0c98aa964df2e812f1e;hb=01cfa8b85b93589476ce3dbff5f9f207ad737abf;hp=ce3edb95e55b89c33c5966d9307e7042cb2102b3;hpb=1f7f758273eb3c98356438da897b7709f8cb87f0;p=dcpomatic.git diff --git a/test/digest_test.cc b/test/digest_test.cc index ce3edb95e..59a8cb7a7 100644 --- a/test/digest_test.cc +++ b/test/digest_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/digest_test.cc * @brief Check computed DCP digests against references calculated by the `openssl` binary. - * @ingroup specific + * @ingroup feature */ + #include "lib/film.h" #include "lib/image_content.h" #include "lib/dcp_content_type.h" @@ -34,14 +36,17 @@ #include #include + using std::list; using std::string; -using boost::shared_ptr; +using std::shared_ptr; +using std::make_shared; + static string openssl_hash (boost::filesystem::path file) { - FILE* pipe = popen (String::compose ("openssl sha1 -binary %1 | openssl base64 -e", file.string()).c_str (), "r"); + auto pipe = popen (String::compose ("openssl sha1 -binary %1 | openssl base64 -e", file.string()).c_str (), "r"); BOOST_REQUIRE (pipe); char buffer[128]; string output; @@ -57,39 +62,44 @@ openssl_hash (boost::filesystem::path file) return output; } + /** Test the digests made by the DCP writing code on a multi-reel DCP */ BOOST_AUTO_TEST_CASE (digest_test) { - shared_ptr film = new_test_film ("digest_test"); + auto film = new_test_film ("digest_test"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->set_name ("digest_test"); - shared_ptr r (new ImageContent (film, "test/data/flat_red.png")); - shared_ptr g (new ImageContent (film, "test/data/flat_green.png")); - shared_ptr b (new ImageContent (film, "test/data/flat_blue.png")); + auto r = make_shared("test/data/flat_red.png"); + auto g = make_shared("test/data/flat_green.png"); + auto b = make_shared("test/data/flat_blue.png"); film->examine_and_add_content (r); film->examine_and_add_content (g); film->examine_and_add_content (b); - film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT); - wait_for_jobs (); + film->set_reel_type (ReelType::BY_VIDEO_CONTENT); + BOOST_REQUIRE (!wait_for_jobs()); - Config::instance()->set_master_encoding_threads (4); - film->make_dcp (); - wait_for_jobs (); - Config::instance()->set_master_encoding_threads (1); + BOOST_CHECK (Config::instance()->master_encoding_threads() > 1); + make_and_verify_dcp (film); dcp::DCP dcp (film->dir (film->dcp_name ())); dcp.read (); - BOOST_CHECK_EQUAL (dcp.cpls().size(), 1); - list > reels = dcp.cpls().front()->reels (); + BOOST_CHECK_EQUAL (dcp.cpls().size(), 1U); + auto reels = dcp.cpls()[0]->reels(); - list >::const_iterator i = reels.begin (); + auto i = reels.begin (); BOOST_REQUIRE (i != reels.end ()); + BOOST_REQUIRE ((*i)->main_picture()->hash()); + BOOST_REQUIRE ((*i)->main_picture()->asset()->file()); BOOST_CHECK_EQUAL ((*i)->main_picture()->hash().get(), openssl_hash ((*i)->main_picture()->asset()->file().get())); ++i; BOOST_REQUIRE (i != reels.end ()); + BOOST_REQUIRE ((*i)->main_picture()->hash()); + BOOST_REQUIRE ((*i)->main_picture()->asset()->file()); BOOST_CHECK_EQUAL ((*i)->main_picture()->hash().get(), openssl_hash ((*i)->main_picture()->asset()->file().get())); ++i; BOOST_REQUIRE (i != reels.end ()); + BOOST_REQUIRE ((*i)->main_picture()->hash()); + BOOST_REQUIRE ((*i)->main_picture()->asset()->file()); BOOST_CHECK_EQUAL ((*i)->main_picture()->hash().get(), openssl_hash ((*i)->main_picture()->asset()->file().get())); ++i; BOOST_REQUIRE (i == reels.end ());