Allow building with C++17 and updated libxml++/pangomm/cairomm.
[dcpomatic.git] / test / test.cc
index 66e638dd5f5fb94321b6ae7dc7b68b3ad4f3d745..9ab7fe4804b0a146880413707efa0c13373038ca 100644 (file)
@@ -163,11 +163,21 @@ struct TestConfig
                setup_test_config ();
                capture_ffmpeg_logs();
 
-               EncodeServerFinder::instance()->stop ();
+               EncodeServerFinder::drop();
 
                signal_manager = new TestSignalManager ();
 
                dcpomatic_log.reset (new FileLog("build/test/log"));
+
+               auto const& suite = boost::unit_test::framework::master_test_suite();
+               int types = LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR;
+               for (int i = 1; i < suite.argc; ++i) {
+                       if (string(suite.argv[i]) == "--log=debug-player") {
+                               types |= LogEntry::TYPE_DEBUG_PLAYER;
+                       }
+               }
+
+               dcpomatic_log->set_types(types);
        }
 
        ~TestConfig ()
@@ -574,7 +584,7 @@ check_dcp(boost::filesystem::path ref, boost::filesystem::path check, bool sound
 }
 
 void
-check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore)
+check_xml(xmlpp::Element* ref, xmlpp::Element* test, list<Glib::ustring> ignore)
 {
        BOOST_CHECK_EQUAL (ref->get_name (), test->get_name ());
        BOOST_CHECK_EQUAL (ref->get_namespace_prefix (), test->get_namespace_prefix ());
@@ -630,7 +640,7 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore)
 }
 
 void
-check_xml (boost::filesystem::path ref, boost::filesystem::path test, list<string> ignore)
+check_xml(boost::filesystem::path ref, boost::filesystem::path test, list<Glib::ustring> ignore)
 {
        auto ref_parser = new xmlpp::DomParser(ref.string());
        auto ref_root = ref_parser->get_document()->get_root_node();
@@ -820,19 +830,22 @@ check_one_frame (boost::filesystem::path dcp_dir, int64_t index, boost::filesyst
        auto asset = dynamic_pointer_cast<dcp::MonoPictureAsset> (dcp.cpls().front()->reels().front()->main_picture()->asset());
        BOOST_REQUIRE (asset);
        auto frame = asset->start_read()->get_frame(index);
-       auto ref_frame (new dcp::MonoPictureFrame (ref));
+       dcp::MonoPictureFrame ref_frame(ref);
 
        auto image = frame->xyz_image ();
-       auto ref_image = ref_frame->xyz_image ();
+       auto ref_image = ref_frame.xyz_image();
 
        BOOST_REQUIRE (image->size() == ref_image->size());
 
        int off = 0;
        for (int y = 0; y < ref_image->size().height; ++y) {
                for (int x = 0; x < ref_image->size().width; ++x) {
-                       BOOST_REQUIRE_EQUAL (ref_image->data(0)[off], image->data(0)[off]);
-                       BOOST_REQUIRE_EQUAL (ref_image->data(1)[off], image->data(1)[off]);
-                       BOOST_REQUIRE_EQUAL (ref_image->data(2)[off], image->data(2)[off]);
+                       auto x_error = std::abs(ref_image->data(0)[off] - image->data(0)[off]);
+                       BOOST_REQUIRE_MESSAGE(x_error == 0, "x component at " << x << "," << y << " differs by " << x_error);
+                       auto y_error = std::abs(ref_image->data(1)[off] - image->data(1)[off]);
+                       BOOST_REQUIRE_MESSAGE(y_error == 0, "y component at " << x << "," << y << " differs by " << y_error);
+                       auto z_error = std::abs(ref_image->data(2)[off] - image->data(2)[off]);
+                       BOOST_REQUIRE_MESSAGE(z_error == 0, "z component at " << x << "," << y << " differs by " << z_error);
                        ++off;
                }
        }
@@ -964,9 +977,9 @@ verify_dcp(boost::filesystem::path dir, vector<dcp::VerificationNote::Code> igno
 
 void
 #ifdef  DCPOMATIC_LINUX
-make_and_verify_dcp(shared_ptr<Film> film, vector<dcp::VerificationNote::Code> ignore, bool dcp_inspect)
+make_and_verify_dcp(shared_ptr<Film> film, vector<dcp::VerificationNote::Code> ignore, bool dcp_inspect, bool clairmeta)
 #else
-make_and_verify_dcp(shared_ptr<Film> film, vector<dcp::VerificationNote::Code> ignore, bool)
+make_and_verify_dcp(shared_ptr<Film> film, vector<dcp::VerificationNote::Code> ignore, bool, bool)
 #endif
 {
        film->write_metadata ();
@@ -1002,6 +1015,12 @@ make_and_verify_dcp(shared_ptr<Film> film, vector<dcp::VerificationNote::Code> i
                auto result = system(cmd.c_str());
                BOOST_CHECK_EQUAL(WEXITSTATUS(result), 0);
        }
+
+       if (clairmeta && getenv("DCPOMATIC_CLAIRMETA")) {
+               auto cmd = String::compose("python3 -m clairmeta.cli check -type dcp %1 > %2 2>&1", film->dir(film->dcp_name()), film->file("clairmeta.log"));
+               auto result = system(cmd.c_str());
+               BOOST_CHECK_EQUAL(WEXITSTATUS(result), 0);
+       }
 #endif
 }