diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-07-27 12:40:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-07-27 12:40:38 +0100 |
| commit | 2ae3d1c397dd3ca75c707e46592198b3a83f4444 (patch) | |
| tree | d494bcb58a0be779bbbcceb0a8cfab6e35e5ccc9 | |
| parent | 4f459e4761080657bbaa194c1f954d1e7c336624 (diff) | |
Add test of reel digests.
| -rw-r--r-- | test/digest_test.cc | 88 | ||||
| -rw-r--r-- | test/util_test.cc | 2 | ||||
| -rw-r--r-- | test/wscript | 1 |
3 files changed, 90 insertions, 1 deletions
diff --git a/test/digest_test.cc b/test/digest_test.cc new file mode 100644 index 000000000..f7480132e --- /dev/null +++ b/test/digest_test.cc @@ -0,0 +1,88 @@ +/* + Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "lib/film.h" +#include "lib/image_content.h" +#include "lib/dcp_content_type.h" +#include "lib/compose.hpp" +#include "test.h" +#include <dcp/cpl.h> +#include <dcp/reel.h> +#include <dcp/reel_picture_asset.h> +#include <boost/test/unit_test.hpp> + +using std::list; +using std::string; +using boost::shared_ptr; + +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"); + BOOST_REQUIRE (pipe); + char buffer[128]; + string output; + while (!feof (pipe)) { + if (fgets (buffer, sizeof(buffer), pipe)) { + output += buffer; + } + } + pclose (pipe); + if (!output.empty ()) { + output = output.substr (0, output.length() - 1); + } + 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> film = new_test_film ("digest_test"); + film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + film->set_name ("digest_test"); + shared_ptr<ImageContent> r (new ImageContent (film, "test/data/flat_red.png")); + shared_ptr<ImageContent> g (new ImageContent (film, "test/data/flat_green.png")); + shared_ptr<ImageContent> b (new ImageContent (film, "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->make_dcp (); + wait_for_jobs (); + + dcp::DCP dcp (film->dir (film->dcp_name ())); + dcp.read (); + BOOST_CHECK_EQUAL (dcp.cpls().size(), 1); + list<shared_ptr<dcp::Reel> > reels = dcp.cpls().front()->reels (); + + list<shared_ptr<dcp::Reel> >::const_iterator i = reels.begin (); + BOOST_REQUIRE (i != reels.end ()); + BOOST_CHECK_EQUAL ((*i)->main_picture()->hash().get(), openssl_hash ((*i)->main_picture()->asset()->file ())); + ++i; + BOOST_REQUIRE (i != reels.end ()); + BOOST_CHECK_EQUAL ((*i)->main_picture()->hash().get(), openssl_hash ((*i)->main_picture()->asset()->file ())); + ++i; + BOOST_REQUIRE (i != reels.end ()); + BOOST_CHECK_EQUAL ((*i)->main_picture()->hash().get(), openssl_hash ((*i)->main_picture()->asset()->file ())); + ++i; + BOOST_REQUIRE (i == reels.end ()); +} diff --git a/test/util_test.cc b/test/util_test.cc index 0cbb5acd3..881d584d0 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -31,7 +31,7 @@ using std::string; using std::vector; using boost::shared_ptr; -BOOST_AUTO_TEST_CASE (digest_test) +BOOST_AUTO_TEST_CASE (digest_head_tail_test) { vector<boost::filesystem::path> p; p.push_back ("test/data/digest.test"); diff --git a/test/wscript b/test/wscript index d336317e5..49e874ea9 100644 --- a/test/wscript +++ b/test/wscript @@ -53,6 +53,7 @@ def build(bld): colour_conversion_test.cc dcp_subtitle_test.cc dcpomatic_time_test.cc + digest_test.cc ffmpeg_audio_test.cc ffmpeg_audio_only_test.cc ffmpeg_dcp_test.cc |
