From 5138e2b72f5b8a17588ca717f40c00a747bc6928 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 23 Jan 2014 00:16:13 +0000 Subject: [PATCH] Add test for recovery-after-crash in 3D. --- test/recover_test.cc | 71 ++++++++++++++++++++++++++++++++++++++++++++ test/test.cc | 8 ++--- test/test.h | 1 + test/wscript | 1 + 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 test/recover_test.cc diff --git a/test/recover_test.cc b/test/recover_test.cc new file mode 100644 index 000000000..d8caf17fa --- /dev/null +++ b/test/recover_test.cc @@ -0,0 +1,71 @@ +/* + Copyright (C) 2014 Carl Hetherington + + 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 +#include +#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 = 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 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 A (new libdcp::StereoPictureAsset ("build/test/recover_test", "original.mxf")); + shared_ptr 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 (¬e, _1, _2))); +} diff --git a/test/test.cc b/test/test.cc index 22dea1fc4..be2cf1538 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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; diff --git a/test/test.h b/test/test.h index e49dfc276..dd007e8c9 100644 --- a/test/test.h +++ b/test/test.h @@ -25,4 +25,5 @@ extern void wait_for_jobs (); extern boost::shared_ptr 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); +extern void check_file (boost::filesystem::path, boost::filesystem::path); extern boost::filesystem::path test_film_dir (std::string); diff --git a/test/wscript b/test/wscript index 5aa95e324..c07f2cc33 100644 --- a/test/wscript +++ b/test/wscript @@ -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 -- 2.30.2