Add test for recovery-after-crash in 3D.
authorCarl Hetherington <cth@carlh.net>
Thu, 23 Jan 2014 00:16:13 +0000 (00:16 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 23 Jan 2014 00:16:13 +0000 (00:16 +0000)
test/recover_test.cc [new file with mode: 0644]
test/test.cc
test/test.h
test/wscript

diff --git a/test/recover_test.cc b/test/recover_test.cc
new file mode 100644 (file)
index 0000000..d8caf17
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+    This program 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.
+
+    This program 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 this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/test/unit_test.hpp>
+#include <libdcp/stereo_picture_asset.h>
+#include "lib/film.h"
+#include "lib/dcp_content_type.h"
+#include "lib/image_content.h"
+#include "lib/ratio.h"
+#include "test.h"
+
+using std::cout;
+using std::string;
+using boost::shared_ptr;
+
+static void
+note (libdcp::NoteType, string n)
+{
+       cout << n << "\n";
+}
+
+/** Test recovery of a DCP transcode after a crash */
+BOOST_AUTO_TEST_CASE (recover_test)
+{
+       shared_ptr<Film> film = new_test_film ("recover_test");
+       film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR"));
+       film->set_container (Ratio::from_id ("185"));
+       film->set_name ("recover_test");
+       film->set_three_d (true);
+
+       shared_ptr<ImageContent> content (new ImageContent (film, "test/data/3d_test"));
+       content->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
+       film->examine_and_add_content (content);
+       wait_for_jobs ();
+
+       film->make_dcp ();
+       wait_for_jobs ();
+
+       boost::filesystem::copy_file (
+               "build/test/recover_test/video/185_2K_58a090f8d70a2b410c534120d35e5256_24_bicubic_200000000_P_S_3D.mxf",
+               "build/test/recover_test/original.mxf"
+               );
+       
+       boost::filesystem::resize_file ("build/test/recover_test/video/185_2K_58a090f8d70a2b410c534120d35e5256_24_bicubic_200000000_P_S_3D.mxf", 2 * 1024 * 1024);
+
+       film->make_dcp ();
+       wait_for_jobs ();
+
+       shared_ptr<libdcp::StereoPictureAsset> A (new libdcp::StereoPictureAsset ("build/test/recover_test", "original.mxf"));
+       shared_ptr<libdcp::StereoPictureAsset> B (new libdcp::StereoPictureAsset ("build/test/recover_test/video", "185_2K_58a090f8d70a2b410c534120d35e5256_24_bicubic_200000000_P_S_3D.mxf"));
+
+       libdcp::EqualityOptions eq;
+       eq.mxf_names_can_differ = true;
+       BOOST_CHECK (A->equals (B, eq, boost::bind (&note, _1, _2)));
+}
index 22dea1fc4ea537b705d36084731305b808c63df3..be2cf15389949c9ead1d23f5804b65c1c50ab99e 100644 (file)
@@ -94,14 +94,14 @@ new_test_film (string name)
        return f;
 }
 
-static void
-check_file (string ref, string check)
+void
+check_file (boost::filesystem::path ref, boost::filesystem::path check)
 {
        uintmax_t N = boost::filesystem::file_size (ref);
        BOOST_CHECK_EQUAL (N, boost::filesystem::file_size(check));
-       FILE* ref_file = fopen (ref.c_str(), "rb");
+       FILE* ref_file = fopen_boost (ref, "rb");
        BOOST_CHECK (ref_file);
-       FILE* check_file = fopen (check.c_str(), "rb");
+       FILE* check_file = fopen_boost (check, "rb");
        BOOST_CHECK (check_file);
        
        int const buffer_size = 65536;
index e49dfc276fb58db43109bf27cb360354e28b734a..dd007e8c9a15033e0db8112b4f3856bb5582c3e4 100644 (file)
@@ -25,4 +25,5 @@ extern void wait_for_jobs ();
 extern boost::shared_ptr<Film> new_test_film (std::string);
 extern void check_dcp (std::string, std::string);
 extern void check_xml (boost::filesystem::path, boost::filesystem::path, std::list<std::string>);
+extern void check_file (boost::filesystem::path, boost::filesystem::path);
 extern boost::filesystem::path test_film_dir (std::string);
index 5aa95e3244493d4c9ae62f5a38e90ffd9a2cf070..c07f2cc335747a8c092c324d691a1fa34b826554 100644 (file)
@@ -36,6 +36,7 @@ def build(bld):
                  pixel_formats_test.cc
                  play_test.cc
                  ratio_test.cc
+                 recover_test.cc
                  resampler_test.cc
                  scaling_test.cc
                  silence_padding_test.cc