Make check_one_frame more verbose when it fails.
[dcpomatic.git] / test / test.cc
index fc5d9dc83b9d2263f47eccae4cb8e6d02a928d2f..57f4ae203afdf7574bae7fb7bb43c08928a9b249 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 ()
@@ -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;
                }
        }