X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Ftest.cc;h=15fd6a3ab14a6dcec6d3770bd9fabc8f52dc4203;hb=b1c4e8572d182a84b9013cc9b640439621660a2f;hp=a2593dca48c70879cb9b56576799d154acbc6410;hpb=1f95e564b1faec3c12869896101e1188d672a2d6;p=dcpomatic.git diff --git a/test/test.cc b/test/test.cc index a2593dca4..15fd6a3ab 100644 --- a/test/test.cc +++ b/test/test.cc @@ -35,6 +35,12 @@ #include "lib/dcp_content_type.h" #include "lib/log_entry.h" #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -45,6 +51,7 @@ extern "C" { #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dcpomatic_test #include +#include #include #include #include @@ -58,6 +65,7 @@ using std::list; using std::abs; using boost::shared_ptr; using boost::scoped_array; +using boost::dynamic_pointer_cast; boost::filesystem::path private_data = boost::filesystem::path ("..") / boost::filesystem::path ("dcpomatic-test-private"); @@ -93,6 +101,11 @@ struct TestConfig EncodeServerFinder::instance()->stop (); signal_manager = new TestSignalManager (); + + char* env_private = getenv("DCPOMATIC_TEST_PRIVATE"); + if (env_private) { + private_data = env_private; + } } ~TestConfig () @@ -459,3 +472,38 @@ check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check, int sk BOOST_REQUIRE_EQUAL (memcmp (ref_p.buf->data, check_p.buf->data, ref_p.buf->size), 0); } } + +void +check_one_frame (boost::filesystem::path dcp_dir, int64_t index, boost::filesystem::path ref) +{ + dcp::DCP dcp (dcp_dir); + dcp.read (); + shared_ptr asset = dynamic_pointer_cast (dcp.cpls().front()->reels().front()->main_picture()->asset()); + BOOST_REQUIRE (asset); + shared_ptr frame = asset->start_read()->get_frame(index); + + boost::uintmax_t const ref_size = boost::filesystem::file_size(ref); + BOOST_CHECK_EQUAL (frame->j2k_size(), ref_size); + + FILE* ref_file = fopen_boost(ref, "rb"); + BOOST_REQUIRE (ref_file); + + uint8_t* ref_data = new uint8_t[ref_size]; + fread (ref_data, ref_size, 1, ref_file); + fclose (ref_file); + + BOOST_CHECK (memcmp(ref_data, frame->j2k_data(), ref_size) == 0); + delete[] ref_data; +} + +boost::filesystem::path +dcp_file (shared_ptr film, string prefix) +{ + boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->dir(film->dcp_name())); + while (i != boost::filesystem::directory_iterator() && !boost::algorithm::starts_with (i->path().leaf().string(), prefix)) { + ++i; + } + + BOOST_REQUIRE (i != boost::filesystem::directory_iterator()); + return i->path(); +}