Missing library from test link list.
[dcpomatic.git] / test / test.cc
index 448168f241ddc16eebb518e8463c6491e74569cf..8f92024fc546cce119436aa1359f8cecbb6ed6a0 100644 (file)
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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,
+    DCP-o-matic 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.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
-#include <fstream>
-#include <iostream>
-#include <boost/filesystem.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/date_time.hpp>
-#include "format.h"
-#include "film.h"
-#include "filter.h"
-#include "job_manager.h"
-#include "util.h"
-#include "exceptions.h"
-#include "delay_line.h"
-#include "image.h"
-#include "log.h"
-#include "dcp_video_frame.h"
-#include "config.h"
-#include "server.h"
-#include "cross.h"
-#include "job.h"
-#include "subtitle.h"
-#include "scaler.h"
-#include "ffmpeg_decoder.h"
-#include "external_audio_decoder.h"
+/** @file  test/test.cc
+ *  @brief Overall test stuff and useful methods for tests.
+ */
+
+#include "lib/config.h"
+#include "lib/util.h"
+#include "lib/signal_manager.h"
+#include "lib/film.h"
+#include "lib/job_manager.h"
+#include "lib/job.h"
+#include "lib/cross.h"
+#include "lib/encode_server_finder.h"
+#include "lib/image.h"
+#include "lib/ratio.h"
+#include "lib/dcp_content_type.h"
+#include "lib/log_entry.h"
+#include "lib/compose.hpp"
+#include "lib/file_log.h"
+#include "lib/dcpomatic_log.h"
+#include "test.h"
+#include <dcp/dcp.h>
+#include <dcp/cpl.h>
+#include <dcp/reel.h>
+#include <dcp/reel_picture_asset.h>
+#include <dcp/mono_picture_frame.h>
+#include <dcp/mono_picture_asset.h>
+#include <dcp/openjpeg_image.h>
+#include <asdcp/AS_DCP.h>
+#include <sndfile.h>
+#include <libxml++/libxml++.h>
+#include <Magick++.h>
+extern "C" {
+#include <libavformat/avformat.h>
+}
 #define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_MODULE dvdomatic_test
+#define BOOST_TEST_MODULE dcpomatic_test
 #include <boost/test/unit_test.hpp>
+#include <boost/algorithm/string.hpp>
+#include <list>
+#include <vector>
+#include <iostream>
 
 using std::string;
-using std::list;
-using std::stringstream;
 using std::vector;
+using std::min;
+using std::cout;
+using std::cerr;
+using std::list;
+using std::abs;
 using boost::shared_ptr;
-using boost::thread;
+using boost::scoped_array;
 using boost::dynamic_pointer_cast;
 
+boost::filesystem::path TestPaths::TestPaths::private_data = boost::filesystem::canonical(boost::filesystem::path ("..") / boost::filesystem::path ("dcpomatic-test-private"));
+boost::filesystem::path TestPaths::xsd = boost::filesystem::canonical(boost::filesystem::path("..") / boost::filesystem::path("libdcp") / boost::filesystem::path("xsd"));
+
 void
 setup_test_config ()
 {
-       Config::instance()->set_num_local_encoding_threads (1);
-       Config::instance()->set_servers (vector<ServerDescription*> ());
-       Config::instance()->set_server_port (61920);
-       Config::instance()->set_default_dci_metadata (DCIMetadata ());
+       Config::instance()->set_master_encoding_threads (1);
+       Config::instance()->set_server_encoding_threads (1);
+       Config::instance()->set_server_port_base (61921);
+       Config::instance()->set_default_isdcf_metadata (ISDCFMetadata ());
+       Config::instance()->set_default_container (Ratio::from_id ("185"));
+       Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0));
+       Config::instance()->set_default_audio_delay (0);
+       Config::instance()->set_default_j2k_bandwidth (100000000);
+       Config::instance()->set_default_interop (false);
+       Config::instance()->set_default_still_length (10);
+       Config::instance()->set_log_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR);
+       Config::instance()->set_automatic_audio_analysis (false);
 }
 
+class TestSignalManager : public SignalManager
+{
+public:
+       /* No wakes in tests: we call ui_idle ourselves */
+       void wake_ui ()
+       {
+
+       }
+};
+
+struct TestConfig
+{
+       TestConfig ()
+       {
+               dcpomatic_setup ();
+               setup_test_config ();
+
+               EncodeServerFinder::instance()->stop ();
+
+               signal_manager = new TestSignalManager ();
+
+               char* env_private = getenv("DCPOMATIC_TEST_PRIVATE");
+               if (env_private) {
+                       TestPaths::TestPaths::private_data = env_private;
+               }
+
+               dcpomatic_log.reset (new FileLog("build/test/log"));
+       }
+
+       ~TestConfig ()
+       {
+               JobManager::drop ();
+       }
+};
+
+BOOST_GLOBAL_FIXTURE (TestConfig);
+
 boost::filesystem::path
 test_film_dir (string name)
 {
@@ -78,761 +145,381 @@ new_test_film (string name)
        if (boost::filesystem::exists (p)) {
                boost::filesystem::remove_all (p);
        }
-       
-       return shared_ptr<Film> (new Film (p.string(), false));
-}
-
-
-/* Check that Image::make_black works, and doesn't use values which crash
-   sws_scale().
-*/
-BOOST_AUTO_TEST_CASE (make_black_test)
-{
-       /* This needs to happen in the first test */
-       dvdomatic_setup ();
-
-       libdcp::Size in_size (512, 512);
-       libdcp::Size out_size (1024, 1024);
-
-       list<AVPixelFormat> pix_fmts;
-       pix_fmts.push_back (AV_PIX_FMT_RGB24);
-       pix_fmts.push_back (AV_PIX_FMT_YUV420P);
-       pix_fmts.push_back (AV_PIX_FMT_YUV422P10LE);
-       pix_fmts.push_back (AV_PIX_FMT_YUV444P9LE);
-       pix_fmts.push_back (AV_PIX_FMT_YUV444P9BE);
-       pix_fmts.push_back (AV_PIX_FMT_YUV444P10LE);
-       pix_fmts.push_back (AV_PIX_FMT_YUV444P10BE);
-
-       int N = 0;
-       for (list<AVPixelFormat>::const_iterator i = pix_fmts.begin(); i != pix_fmts.end(); ++i) {
-               boost::shared_ptr<Image> foo (new SimpleImage (*i, in_size, true));
-               foo->make_black ();
-               boost::shared_ptr<Image> bar = foo->scale_and_convert_to_rgb (out_size, 0, Scaler::from_id ("bicubic"), true);
-               
-               uint8_t* p = bar->data()[0];
-               for (int y = 0; y < bar->size().height; ++y) {
-                       uint8_t* q = p;
-                       for (int x = 0; x < bar->line_size()[0]; ++x) {
-                               BOOST_CHECK_EQUAL (*q++, 0);
-                       }
-                       p += bar->stride()[0];
-               }
 
-               ++N;
-       }
+       shared_ptr<Film> film = shared_ptr<Film> (new Film (p));
+       film->write_metadata ();
+       return film;
 }
 
-BOOST_AUTO_TEST_CASE (film_metadata_test)
+shared_ptr<Film>
+new_test_film2 (string name)
 {
-       setup_test_config ();
-
-       string const test_film = "build/test/film_metadata_test";
-       
-       if (boost::filesystem::exists (test_film)) {
-               boost::filesystem::remove_all (test_film);
+       boost::filesystem::path p = test_film_dir (name);
+       if (boost::filesystem::exists (p)) {
+               boost::filesystem::remove_all (p);
        }
 
-       BOOST_CHECK_THROW (new Film (test_film, true), OpenFileError);
-       
-       shared_ptr<Film> f (new Film (test_film, false));
-       f->_dci_date = boost::gregorian::from_undelimited_string ("20130211");
-       BOOST_CHECK (f->format() == 0);
-       BOOST_CHECK (f->dcp_content_type() == 0);
-       BOOST_CHECK (f->filters ().empty());
-
-       f->set_name ("fred");
-       BOOST_CHECK_THROW (f->set_content ("jim"), OpenFileError);
-       f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short"));
-       f->set_format (Format::from_nickname ("Flat"));
-       f->set_left_crop (1);
-       f->set_right_crop (2);
-       f->set_top_crop (3);
-       f->set_bottom_crop (4);
-       vector<Filter const *> f_filters;
-       f_filters.push_back (Filter::from_id ("pphb"));
-       f_filters.push_back (Filter::from_id ("unsharp"));
-       f->set_filters (f_filters);
-       f->set_trim_start (42);
-       f->set_trim_end (99);
-       f->set_dcp_ab (true);
-       f->write_metadata ();
-
-       stringstream s;
-       s << "diff -u test/metadata.ref " << test_film << "/metadata";
-       BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0);
-
-       shared_ptr<Film> g (new Film (test_film, true));
-
-       BOOST_CHECK_EQUAL (g->name(), "fred");
-       BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_pretty_name ("Short"));
-       BOOST_CHECK_EQUAL (g->format(), Format::from_nickname ("Flat"));
-       BOOST_CHECK_EQUAL (g->crop().left, 1);
-       BOOST_CHECK_EQUAL (g->crop().right, 2);
-       BOOST_CHECK_EQUAL (g->crop().top, 3);
-       BOOST_CHECK_EQUAL (g->crop().bottom, 4);
-       vector<Filter const *> g_filters = g->filters ();
-       BOOST_CHECK_EQUAL (g_filters.size(), 2);
-       BOOST_CHECK_EQUAL (g_filters.front(), Filter::from_id ("pphb"));
-       BOOST_CHECK_EQUAL (g_filters.back(), Filter::from_id ("unsharp"));
-       BOOST_CHECK_EQUAL (g->trim_start(), 42);
-       BOOST_CHECK_EQUAL (g->trim_end(), 99);
-       BOOST_CHECK_EQUAL (g->dcp_ab(), true);
-       
-       g->write_metadata ();
-       BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0);
+       shared_ptr<Film> film = shared_ptr<Film> (new Film (p));
+       film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
+       film->set_container (Ratio::from_id ("185"));
+       film->write_metadata ();
+       return film;
 }
 
-BOOST_AUTO_TEST_CASE (stream_test)
+void
+check_wav_file (boost::filesystem::path ref, boost::filesystem::path check)
 {
-       FFmpegAudioStream a ("ffmpeg 4 44100 1 hello there world", boost::optional<int> (1));
-       BOOST_CHECK_EQUAL (a.id(), 4);
-       BOOST_CHECK_EQUAL (a.sample_rate(), 44100);
-       BOOST_CHECK_EQUAL (a.channel_layout(), 1);
-       BOOST_CHECK_EQUAL (a.name(), "hello there world");
-       BOOST_CHECK_EQUAL (a.to_string(), "ffmpeg 4 44100 1 hello there world");
-
-       ExternalAudioStream e ("external 44100 1", boost::optional<int> (1));
-       BOOST_CHECK_EQUAL (e.sample_rate(), 44100);
-       BOOST_CHECK_EQUAL (e.channel_layout(), 1);
-       BOOST_CHECK_EQUAL (e.to_string(), "external 44100 1");
-
-       SubtitleStream s ("5 a b c", boost::optional<int> (1));
-       BOOST_CHECK_EQUAL (s.id(), 5);
-       BOOST_CHECK_EQUAL (s.name(), "a b c");
-
-       shared_ptr<AudioStream> ff = audio_stream_factory ("ffmpeg 4 44100 1 hello there world", boost::optional<int> (1));
-       shared_ptr<FFmpegAudioStream> cff = dynamic_pointer_cast<FFmpegAudioStream> (ff);
-       BOOST_CHECK (cff);
-       BOOST_CHECK_EQUAL (cff->id(), 4);
-       BOOST_CHECK_EQUAL (cff->sample_rate(), 44100);
-       BOOST_CHECK_EQUAL (cff->channel_layout(), 1);
-       BOOST_CHECK_EQUAL (cff->name(), "hello there world");
-       BOOST_CHECK_EQUAL (cff->to_string(), "ffmpeg 4 44100 1 hello there world");
-
-       shared_ptr<AudioStream> fe = audio_stream_factory ("external 44100 1", boost::optional<int> (1));
-       BOOST_CHECK_EQUAL (fe->sample_rate(), 44100);
-       BOOST_CHECK_EQUAL (fe->channel_layout(), 1);
-       BOOST_CHECK_EQUAL (fe->to_string(), "external 44100 1");
-}
+       SF_INFO ref_info;
+       ref_info.format = 0;
+       SNDFILE* ref_file = sf_open (ref.string().c_str(), SFM_READ, &ref_info);
+       BOOST_CHECK (ref_file);
+
+       SF_INFO check_info;
+       check_info.format = 0;
+       SNDFILE* check_file = sf_open (check.string().c_str(), SFM_READ, &check_info);
+       BOOST_CHECK (check_file);
+
+       BOOST_CHECK_EQUAL (ref_info.frames, check_info.frames);
+       BOOST_CHECK_EQUAL (ref_info.samplerate, check_info.samplerate);
+       BOOST_CHECK_EQUAL (ref_info.channels, check_info.channels);
+       BOOST_CHECK_EQUAL (ref_info.format, check_info.format);
+
+       /* buffer_size is in frames */
+       sf_count_t const buffer_size = 65536 * ref_info.channels;
+       scoped_array<int32_t> ref_buffer (new int32_t[buffer_size]);
+       scoped_array<int32_t> check_buffer (new int32_t[buffer_size]);
+
+       sf_count_t N = ref_info.frames;
+       while (N) {
+               sf_count_t this_time = min (buffer_size, N);
+               sf_count_t r = sf_readf_int (ref_file, ref_buffer.get(), this_time);
+               BOOST_CHECK_EQUAL (r, this_time);
+               r = sf_readf_int (check_file, check_buffer.get(), this_time);
+               BOOST_CHECK_EQUAL (r, this_time);
+
+               for (sf_count_t i = 0; i < this_time; ++i) {
+                       BOOST_REQUIRE_MESSAGE (
+                               abs (ref_buffer[i] - check_buffer[i]) <= 65536,
+                               ref << " differs from " << check << " at " << (ref_info.frames - N + i) << " of " << ref_info.frames
+                               << "(" << ref_buffer[i] << " vs " << check_buffer[i] << ")"
+                               );
+               }
 
-BOOST_AUTO_TEST_CASE (format_test)
-{
-       Format::setup_formats ();
-       
-       Format const * f = Format::from_nickname ("Flat");
-       BOOST_CHECK (f);
-       BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr<const Film> ()), 185);
-       
-       f = Format::from_nickname ("Scope");
-       BOOST_CHECK (f);
-       BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr<const Film> ()), 239);
+               N -= this_time;
+       }
 }
 
-BOOST_AUTO_TEST_CASE (util_test)
+void
+check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check)
 {
-       string t = "Hello this is a string \"with quotes\" and indeed without them";
-       vector<string> b = split_at_spaces_considering_quotes (t);
-       vector<string>::iterator i = b.begin ();
-       BOOST_CHECK_EQUAL (*i++, "Hello");
-       BOOST_CHECK_EQUAL (*i++, "this");
-       BOOST_CHECK_EQUAL (*i++, "is");
-       BOOST_CHECK_EQUAL (*i++, "a");
-       BOOST_CHECK_EQUAL (*i++, "string");
-       BOOST_CHECK_EQUAL (*i++, "with quotes");
-       BOOST_CHECK_EQUAL (*i++, "and");
-       BOOST_CHECK_EQUAL (*i++, "indeed");
-       BOOST_CHECK_EQUAL (*i++, "without");
-       BOOST_CHECK_EQUAL (*i++, "them");
-}
+       ASDCP::PCM::MXFReader ref_reader;
+       BOOST_REQUIRE (!ASDCP_FAILURE (ref_reader.OpenRead (ref.string().c_str())));
 
-class NullLog : public Log
-{
-public:
-       void do_log (string) {}
-};
+       ASDCP::PCM::AudioDescriptor ref_desc;
+       BOOST_REQUIRE (!ASDCP_FAILURE (ref_reader.FillAudioDescriptor (ref_desc)));
 
-void
-do_positive_delay_line_test (int delay_length, int data_length)
-{
-       shared_ptr<NullLog> log (new NullLog);
-       
-       DelayLine d (log, 6, delay_length);
-       shared_ptr<AudioBuffers> data (new AudioBuffers (6, data_length));
-
-       int in = 0;
-       int out = 0;
-       int returned = 0;
-       int zeros = 0;
-       
-       for (int i = 0; i < 64; ++i) {
-               for (int j = 0; j < data_length; ++j) {
-                       for (int c = 0; c < 6; ++c ) {
-                               data->data(c)[j] = in;
-                               ++in;
-                       }
-               }
+       ASDCP::PCM::MXFReader check_reader;
+       BOOST_REQUIRE (!ASDCP_FAILURE (check_reader.OpenRead (check.string().c_str())));
 
-               /* This only works because the delay line modifies the parameter */
-               d.process_audio (data);
-               returned += data->frames ();
+       ASDCP::PCM::AudioDescriptor check_desc;
+       BOOST_REQUIRE (!ASDCP_FAILURE (check_reader.FillAudioDescriptor (check_desc)));
 
-               for (int j = 0; j < data->frames(); ++j) {
-                       if (zeros < delay_length) {
-                               for (int c = 0; c < 6; ++c) {
-                                       BOOST_CHECK_EQUAL (data->data(c)[j], 0);
-                               }
-                               ++zeros;
-                       } else {
-                               for (int c = 0; c < 6; ++c) {
-                                       BOOST_CHECK_EQUAL (data->data(c)[j], out);
-                                       ++out;
-                               }
-                       }
-               }
-       }
+       BOOST_REQUIRE_EQUAL (ref_desc.ContainerDuration, check_desc.ContainerDuration);
 
-       BOOST_CHECK_EQUAL (returned, 64 * data_length);
+       ASDCP::PCM::FrameBuffer ref_buffer (Kumu::Megabyte);
+       ASDCP::PCM::FrameBuffer check_buffer (Kumu::Megabyte);
+       for (size_t i = 0; i < ref_desc.ContainerDuration; ++i) {
+               ref_reader.ReadFrame (i, ref_buffer, 0);
+               check_reader.ReadFrame (i, check_buffer, 0);
+               BOOST_REQUIRE (memcmp(ref_buffer.RoData(), check_buffer.RoData(), ref_buffer.Size()) == 0);
+       }
 }
 
 void
-do_negative_delay_line_test (int delay_length, int data_length)
+check_image (boost::filesystem::path ref, boost::filesystem::path check, double threshold)
 {
-       shared_ptr<NullLog> log (new NullLog);
-
-       DelayLine d (log, 6, delay_length);
-       shared_ptr<AudioBuffers> data (new AudioBuffers (6, data_length));
-
-       int in = 0;
-       int out = -delay_length * 6;
-       int returned = 0;
-       
-       for (int i = 0; i < 256; ++i) {
-               data->set_frames (data_length);
-               for (int j = 0; j < data_length; ++j) {
-                       for (int c = 0; c < 6; ++c) {
-                               data->data(c)[j] = in;
-                               ++in;
-                       }
-               }
-
-               /* This only works because the delay line modifies the parameter */
-               d.process_audio (data);
-               returned += data->frames ();
-
-               for (int j = 0; j < data->frames(); ++j) {
-                       for (int c = 0; c < 6; ++c) {
-                               BOOST_CHECK_EQUAL (data->data(c)[j], out);
-                               ++out;
-                       }
-               }
-       }
-
-       returned += -delay_length;
-       BOOST_CHECK_EQUAL (returned, 256 * data_length);
+       using namespace MagickCore;
+
+       Magick::Image ref_image;
+       ref_image.read (ref.string ());
+       Magick::Image check_image;
+       check_image.read (check.string ());
+       /* XXX: this is a hack; we really want the ImageMagick call but GraphicsMagick doesn't have it;
+          this may cause random test failures on platforms that use GraphicsMagick.
+       */
+       double const dist = ref_image.compare(check_image, Magick::RootMeanSquaredErrorMetric);
+       BOOST_CHECK_MESSAGE (dist < threshold, ref << " differs from " << check << " " << dist);
 }
 
-BOOST_AUTO_TEST_CASE (delay_line_test)
+void
+check_file (boost::filesystem::path ref, boost::filesystem::path check)
 {
-       do_positive_delay_line_test (64, 128);
-       do_positive_delay_line_test (128, 64);
-       do_positive_delay_line_test (3, 512);
-       do_positive_delay_line_test (512, 3);
-
-       do_positive_delay_line_test (0, 64);
+       uintmax_t N = boost::filesystem::file_size (ref);
+       BOOST_CHECK_EQUAL (N, boost::filesystem::file_size (check));
+       FILE* ref_file = fopen_boost (ref, "rb");
+       BOOST_CHECK (ref_file);
+       FILE* check_file = fopen_boost (check, "rb");
+       BOOST_CHECK (check_file);
+
+       int const buffer_size = 65536;
+       uint8_t* ref_buffer = new uint8_t[buffer_size];
+       uint8_t* check_buffer = new uint8_t[buffer_size];
+
+       string error = "File " + check.string() + " differs from reference " + ref.string();
+
+       while (N) {
+               uintmax_t this_time = min (uintmax_t (buffer_size), N);
+               size_t r = fread (ref_buffer, 1, this_time, ref_file);
+               BOOST_CHECK_EQUAL (r, this_time);
+               r = fread (check_buffer, 1, this_time, check_file);
+               BOOST_CHECK_EQUAL (r, this_time);
+
+               BOOST_CHECK_MESSAGE (memcmp (ref_buffer, check_buffer, this_time) == 0, error);
+               if (memcmp (ref_buffer, check_buffer, this_time)) {
+                       break;
+               }
 
-       do_negative_delay_line_test (-64, 128);
-       do_negative_delay_line_test (-128, 64);
-       do_negative_delay_line_test (-3, 512);
-       do_negative_delay_line_test (-512, 3);
-}
+               N -= this_time;
+       }
 
-BOOST_AUTO_TEST_CASE (md5_digest_test)
-{
-       string const t = md5_digest ("test/md5.test");
-       BOOST_CHECK_EQUAL (t, "15058685ba99decdc4398c7634796eb0");
+       delete[] ref_buffer;
+       delete[] check_buffer;
 
-       BOOST_CHECK_THROW (md5_digest ("foobar"), OpenFileError);
+       fclose (ref_file);
+       fclose (check_file);
 }
 
-BOOST_AUTO_TEST_CASE (paths_test)
+static void
+note (dcp::NoteType t, string n)
 {
-       shared_ptr<Film> f = new_test_film ("paths_test");
-       f->set_directory ("build/test/a/b/c/d/e");
-
-       f->_content = "/foo/bar/baz";
-       BOOST_CHECK_EQUAL (f->content_path(), "/foo/bar/baz");
-       f->_content = "foo/bar/baz";
-       BOOST_CHECK_EQUAL (f->content_path(), "build/test/a/b/c/d/e/foo/bar/baz");
+       if (t == dcp::DCP_ERROR) {
+               cerr << n << "\n";
+       }
 }
 
 void
-do_remote_encode (shared_ptr<DCPVideoFrame> frame, ServerDescription* description, shared_ptr<EncodedData> locally_encoded)
+check_dcp (boost::filesystem::path ref, boost::filesystem::path check)
 {
-       shared_ptr<EncodedData> remotely_encoded;
-       BOOST_CHECK_NO_THROW (remotely_encoded = frame->encode_remotely (description));
-       BOOST_CHECK (remotely_encoded);
-       
-       BOOST_CHECK_EQUAL (locally_encoded->size(), remotely_encoded->size());
-       BOOST_CHECK (memcmp (locally_encoded->data(), remotely_encoded->data(), locally_encoded->size()) == 0);
+       dcp::DCP ref_dcp (ref);
+       ref_dcp.read ();
+       dcp::DCP check_dcp (check);
+       check_dcp.read ();
+
+       dcp::EqualityOptions options;
+       options.max_mean_pixel_error = 5;
+       options.max_std_dev_pixel_error = 5;
+       options.max_audio_sample_error = 255;
+       options.cpl_annotation_texts_can_differ = true;
+       options.reel_annotation_texts_can_differ = true;
+       options.reel_hashes_can_differ = true;
+       options.issue_dates_can_differ = true;
+
+       BOOST_CHECK (ref_dcp.equals (check_dcp, options, boost::bind (note, _1, _2)));
 }
 
-BOOST_AUTO_TEST_CASE (client_server_test)
+void
+check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore)
 {
-       shared_ptr<Image> image (new SimpleImage (PIX_FMT_RGB24, libdcp::Size (1998, 1080), true));
-       uint8_t* p = image->data()[0];
-       
-       for (int y = 0; y < 1080; ++y) {
-               uint8_t* q = p;
-               for (int x = 0; x < 1998; ++x) {
-                       *q++ = x % 256;
-                       *q++ = y % 256;
-                       *q++ = (x + y) % 256;
-               }
-               p += image->stride()[0];
-       }
+       BOOST_CHECK_EQUAL (ref->get_name (), test->get_name ());
+       BOOST_CHECK_EQUAL (ref->get_namespace_prefix (), test->get_namespace_prefix ());
 
-       shared_ptr<Image> sub_image (new SimpleImage (PIX_FMT_RGBA, libdcp::Size (100, 200), true));
-       p = sub_image->data()[0];
-       for (int y = 0; y < 200; ++y) {
-               uint8_t* q = p;
-               for (int x = 0; x < 100; ++x) {
-                       *q++ = y % 256;
-                       *q++ = x % 256;
-                       *q++ = (x + y) % 256;
-                       *q++ = 1;
-               }
-               p += sub_image->stride()[0];
+       if (find (ignore.begin(), ignore.end(), ref->get_name()) != ignore.end ()) {
+               return;
        }
 
-       shared_ptr<Subtitle> subtitle (new Subtitle (Position (50, 60), sub_image));
-
-       shared_ptr<FileLog> log (new FileLog ("build/test/client_server_test.log"));
-
-       shared_ptr<DCPVideoFrame> frame (
-               new DCPVideoFrame (
-                       image,
-                       subtitle,
-                       libdcp::Size (1998, 1080),
-                       0,
-                       0,
-                       1,
-                       Scaler::from_id ("bicubic"),
-                       0,
-                       24,
-                       "",
-                       0,
-                       200000000,
-                       log
-                       )
+       xmlpp::Element::NodeList ref_children = ref->get_children ();
+       xmlpp::Element::NodeList test_children = test->get_children ();
+       BOOST_REQUIRE_MESSAGE (
+               ref_children.size() == test_children.size(),
+               ref->get_name() << " has " << ref_children.size() << " or " << test_children.size() << " children"
                );
 
-       shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
-       BOOST_ASSERT (locally_encoded);
-       
-       Server* server = new Server (log);
+       xmlpp::Element::NodeList::iterator k = ref_children.begin ();
+       xmlpp::Element::NodeList::iterator l = test_children.begin ();
+       while (k != ref_children.end ()) {
 
-       new thread (boost::bind (&Server::run, server, 2));
+               /* XXX: should be doing xmlpp::EntityReference, xmlpp::XIncludeEnd, xmlpp::XIncludeStart */
 
-       /* Let the server get itself ready */
-       dvdomatic_sleep (1);
+               xmlpp::Element* ref_el = dynamic_cast<xmlpp::Element*> (*k);
+               xmlpp::Element* test_el = dynamic_cast<xmlpp::Element*> (*l);
+               BOOST_CHECK ((ref_el && test_el) || (!ref_el && !test_el));
+               if (ref_el && test_el) {
+                       check_xml (ref_el, test_el, ignore);
+               }
 
-       ServerDescription description ("localhost", 2);
+               xmlpp::ContentNode* ref_cn = dynamic_cast<xmlpp::ContentNode*> (*k);
+               xmlpp::ContentNode* test_cn = dynamic_cast<xmlpp::ContentNode*> (*l);
+               BOOST_CHECK ((ref_cn && test_cn) || (!ref_cn && !test_cn));
+               if (ref_cn && test_cn) {
+                       BOOST_CHECK_EQUAL (ref_cn->get_content(), test_cn->get_content ());
+               }
 
-       list<thread*> threads;
-       for (int i = 0; i < 8; ++i) {
-               threads.push_back (new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded)));
+               ++k;
+               ++l;
        }
 
-       for (list<thread*>::iterator i = threads.begin(); i != threads.end(); ++i) {
-               (*i)->join ();
-       }
+       xmlpp::Element::AttributeList ref_attributes = ref->get_attributes ();
+       xmlpp::Element::AttributeList test_attributes = test->get_attributes ();
+       BOOST_CHECK_EQUAL (ref_attributes.size(), test_attributes.size ());
 
-       for (list<thread*>::iterator i = threads.begin(); i != threads.end(); ++i) {
-               delete *i;
+       xmlpp::Element::AttributeList::const_iterator m = ref_attributes.begin();
+       xmlpp::Element::AttributeList::const_iterator n = test_attributes.begin();
+       while (m != ref_attributes.end ()) {
+               BOOST_CHECK_EQUAL ((*m)->get_name(), (*n)->get_name());
+               BOOST_CHECK_EQUAL ((*m)->get_value(), (*n)->get_value());
+
+               ++m;
+               ++n;
        }
 }
 
-BOOST_AUTO_TEST_CASE (make_dcp_test)
+void
+check_xml (boost::filesystem::path ref, boost::filesystem::path test, list<string> ignore)
 {
-       shared_ptr<Film> film = new_test_film ("make_dcp_test");
-       film->set_name ("test_film2");
-       film->set_content ("../../../test/test.mp4");
-       film->set_format (Format::from_nickname ("Flat"));
-       film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
-       film->make_dcp ();
-       film->write_metadata ();
+       xmlpp::DomParser* ref_parser = new xmlpp::DomParser (ref.string ());
+       xmlpp::Element* ref_root = ref_parser->get_document()->get_root_node ();
+       xmlpp::DomParser* test_parser = new xmlpp::DomParser (test.string ());
+       xmlpp::Element* test_root = test_parser->get_document()->get_root_node ();
 
-       while (JobManager::instance()->work_to_do ()) {
-               dvdomatic_sleep (1);
-       }
-       
-       BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false);
+       check_xml (ref_root, test_root, ignore);
 }
 
-/** Test Film::have_dcp().  Requires the output from make_dcp_test above */
-BOOST_AUTO_TEST_CASE (have_dcp_test)
+bool
+wait_for_jobs ()
 {
-       boost::filesystem::path p = test_film_dir ("make_dcp_test");
-       Film f (p.string ());
-       BOOST_CHECK (f.have_dcp());
-
-       p /= f.dcp_name();
-       p /= "video.mxf";
-       boost::filesystem::remove (p);
-       BOOST_CHECK (!f.have_dcp ());
-}
+       JobManager* jm = JobManager::instance ();
+       while (jm->work_to_do ()) {
+               while (signal_manager->ui_idle ()) {}
+               dcpomatic_sleep_seconds (1);
+       }
 
-BOOST_AUTO_TEST_CASE (make_dcp_with_range_test)
-{
-       shared_ptr<Film> film = new_test_film ("make_dcp_with_range_test");
-       film->set_name ("test_film3");
-       film->set_content ("../../../test/test.mp4");
-       film->examine_content ();
-       film->set_format (Format::from_nickname ("Flat"));
-       film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
-       film->set_trim_end (42);
-       film->make_dcp ();
-
-       while (JobManager::instance()->work_to_do() && !JobManager::instance()->errors()) {
-               dvdomatic_sleep (1);
+       if (jm->errors ()) {
+               int N = 0;
+               for (list<shared_ptr<Job> >::iterator i = jm->_jobs.begin(); i != jm->_jobs.end(); ++i) {
+                       if ((*i)->finished_in_error ()) {
+                               ++N;
+                       }
+               }
+               cerr << N << " errors.\n";
+
+               for (list<shared_ptr<Job> >::iterator i = jm->_jobs.begin(); i != jm->_jobs.end(); ++i) {
+                       if ((*i)->finished_in_error ()) {
+                               cerr << (*i)->name() << ":\n"
+                                    << "\tsummary: " << (*i)->error_summary () << "\n"
+                                    << "\tdetails: " << (*i)->error_details () << "\n";
+                       }
+               }
        }
 
-       BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false);
+       while (signal_manager->ui_idle ()) {}
+
+       if (jm->errors ()) {
+               JobManager::drop ();
+               return true;
+       }
+
+       return false;
 }
 
-/* Test best_dcp_frame_rate and FrameRateConversion */
-BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test)
+void
+write_image (shared_ptr<const Image> image, boost::filesystem::path file, string format, MagickCore::StorageType pixel_type)
 {
-       /* Run some tests with a limited range of allowed rates */
-       
-       std::list<int> afr;
-       afr.push_back (24);
-       afr.push_back (25);
-       afr.push_back (30);
-       Config::instance()->set_allowed_dcp_frame_rates (afr);
-
-       int best = best_dcp_frame_rate (60);
-       FrameRateConversion frc = FrameRateConversion (60, best);
-       BOOST_CHECK_EQUAL (best, 30);
-       BOOST_CHECK_EQUAL (frc.skip, true);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-       
-       best = best_dcp_frame_rate (50);
-       frc = FrameRateConversion (50, best);
-       BOOST_CHECK_EQUAL (best, 25);
-       BOOST_CHECK_EQUAL (frc.skip, true);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       best = best_dcp_frame_rate (48);
-       frc = FrameRateConversion (48, best);
-       BOOST_CHECK_EQUAL (best, 24);
-       BOOST_CHECK_EQUAL (frc.skip, true);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-       
-       best = best_dcp_frame_rate (30);
-       frc = FrameRateConversion (30, best);
-       BOOST_CHECK_EQUAL (best, 30);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       best = best_dcp_frame_rate (29.97);
-       frc = FrameRateConversion (29.97, best);
-       BOOST_CHECK_EQUAL (best, 30);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, true);
-       
-       best = best_dcp_frame_rate (25);
-       frc = FrameRateConversion (25, best);
-       BOOST_CHECK_EQUAL (best, 25);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       best = best_dcp_frame_rate (24);
-       frc = FrameRateConversion (24, best);
-       BOOST_CHECK_EQUAL (best, 24);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       best = best_dcp_frame_rate (14.5);
-       frc = FrameRateConversion (14.5, best);
-       BOOST_CHECK_EQUAL (best, 30);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, true);
-       BOOST_CHECK_EQUAL (frc.change_speed, true);
-
-       best = best_dcp_frame_rate (12.6);
-       frc = FrameRateConversion (12.6, best);
-       BOOST_CHECK_EQUAL (best, 25);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, true);
-       BOOST_CHECK_EQUAL (frc.change_speed, true);
-
-       best = best_dcp_frame_rate (12.4);
-       frc = FrameRateConversion (12.4, best);
-       BOOST_CHECK_EQUAL (best, 25);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, true);
-       BOOST_CHECK_EQUAL (frc.change_speed, true);
-
-       best = best_dcp_frame_rate (12);
-       frc = FrameRateConversion (12, best);
-       BOOST_CHECK_EQUAL (best, 24);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, true);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       /* Now add some more rates and see if it will use them
-          in preference to skip/repeat.
-       */
+       using namespace MagickCore;
 
-       afr.push_back (48);
-       afr.push_back (50);
-       afr.push_back (60);
-       Config::instance()->set_allowed_dcp_frame_rates (afr);
-
-       best = best_dcp_frame_rate (60);
-       frc = FrameRateConversion (60, best);
-       BOOST_CHECK_EQUAL (best, 60);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-       
-       best = best_dcp_frame_rate (50);
-       frc = FrameRateConversion (50, best);
-       BOOST_CHECK_EQUAL (best, 50);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       best = best_dcp_frame_rate (48);
-       frc = FrameRateConversion (48, best);
-       BOOST_CHECK_EQUAL (best, 48);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, false);
-
-       /* Check some out-there conversions (not the best) */
-       
-       frc = FrameRateConversion (14.99, 24);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, true);
-       BOOST_CHECK_EQUAL (frc.change_speed, true);
-
-       /* Check some conversions with limited DCP targets */
-
-       afr.clear ();
-       afr.push_back (24);
-       Config::instance()->set_allowed_dcp_frame_rates (afr);
-
-       best = best_dcp_frame_rate (25);
-       frc = FrameRateConversion (25, best);
-       BOOST_CHECK_EQUAL (best, 24);
-       BOOST_CHECK_EQUAL (frc.skip, false);
-       BOOST_CHECK_EQUAL (frc.repeat, false);
-       BOOST_CHECK_EQUAL (frc.change_speed, true);
+       Magick::Image m (image->size().width, image->size().height, format.c_str(), pixel_type, (void *) image->data()[0]);
+       m.write (file.string ());
 }
 
-BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
+void
+check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check, int audio_tolerance)
 {
-       std::list<int> afr;
-       afr.push_back (24);
-       afr.push_back (25);
-       afr.push_back (30);
-       Config::instance()->set_allowed_dcp_frame_rates (afr);
-
-       shared_ptr<Film> f = new_test_film ("audio_sampling_rate_test");
-       f->set_source_frame_rate (24);
-       f->set_dcp_frame_rate (24);
-
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 48000);
-
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 44100, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 48000);
-
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 80000, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 96000);
-
-       f->set_source_frame_rate (23.976);
-       f->set_dcp_frame_rate (best_dcp_frame_rate (23.976));
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 47952);
-
-       f->set_source_frame_rate (29.97);
-       f->set_dcp_frame_rate (best_dcp_frame_rate (29.97));
-       BOOST_CHECK_EQUAL (f->dcp_frame_rate (), 30);
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 47952);
-
-       f->set_source_frame_rate (25);
-       f->set_dcp_frame_rate (24);
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 50000);
-
-       f->set_source_frame_rate (25);
-       f->set_dcp_frame_rate (24);
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 44100, 0)));
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), 50000);
-
-       /* Check some out-there conversions (not the best) */
-       
-       f->set_source_frame_rate (14.99);
-       f->set_dcp_frame_rate (25);
-       f->set_content_audio_stream (shared_ptr<AudioStream> (new FFmpegAudioStream ("a", 42, 16000, 0)));
-       /* The FrameRateConversion within target_audio_sample_rate should choose to double-up
-          the 14.99 fps video to 30 and then run it slow at 25.
-       */
-       BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), rint (48000 * 2 * 14.99 / 25));
+       int const r = system (String::compose("ffcmp -t %1 %2 %3", audio_tolerance, ref.string(), check.string()).c_str());
+       BOOST_REQUIRE_EQUAL (WEXITSTATUS(r), 0);
 }
 
-class TestJob : public Job
+void
+check_one_frame (boost::filesystem::path dcp_dir, int64_t index, boost::filesystem::path ref)
 {
-public:
-       TestJob (shared_ptr<Film> f)
-               : Job (f)
-       {
-
+       dcp::DCP dcp (dcp_dir);
+       dcp.read ();
+       shared_ptr<dcp::MonoPictureAsset> asset = dynamic_pointer_cast<dcp::MonoPictureAsset> (dcp.cpls().front()->reels().front()->main_picture()->asset());
+       BOOST_REQUIRE (asset);
+       shared_ptr<const dcp::MonoPictureFrame> frame = asset->start_read()->get_frame(index);
+       shared_ptr<const dcp::MonoPictureFrame> ref_frame (new dcp::MonoPictureFrame (ref));
+
+       shared_ptr<dcp::OpenJPEGImage> image = frame->xyz_image ();
+       shared_ptr<dcp::OpenJPEGImage> 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]);
+                       ++off;
+               }
        }
+}
 
-       void set_finished_ok () {
-               set_state (FINISHED_OK);
+boost::filesystem::path
+dcp_file (shared_ptr<const Film> 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;
        }
 
-       void set_finished_error () {
-               set_state (FINISHED_ERROR);
-       }
+       BOOST_REQUIRE (i != boost::filesystem::directory_iterator());
+       return i->path();
+}
 
-       void run ()
-       {
-               while (1) {
-                       if (finished ()) {
-                               return;
+boost::filesystem::path
+subtitle_file (shared_ptr<Film> film)
+{
+       for (
+               boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->directory().get() / film->dcp_name (false));
+               i != boost::filesystem::directory_iterator ();
+               ++i) {
+
+               if (boost::filesystem::is_directory (i->path ())) {
+                       for (
+                               boost::filesystem::directory_iterator j = boost::filesystem::directory_iterator (i->path ());
+                               j != boost::filesystem::directory_iterator ();
+                               ++j) {
+
+                               if (boost::algorithm::starts_with (j->path().leaf().string(), "sub_")) {
+                                       return j->path();
+                               }
                        }
                }
        }
 
-       string name () const {
-               return "";
-       }
-};
-
-BOOST_AUTO_TEST_CASE (job_manager_test)
-{
-       shared_ptr<Film> f;
-
-       /* Single job */
-       shared_ptr<TestJob> a (new TestJob (f));
-
-       JobManager::instance()->add (a);
-       dvdomatic_sleep (1);
-       BOOST_CHECK_EQUAL (a->running (), true);
-       a->set_finished_ok ();
-       dvdomatic_sleep (2);
-       BOOST_CHECK_EQUAL (a->finished_ok(), true);
-}
-
-BOOST_AUTO_TEST_CASE (compact_image_test)
-{
-       SimpleImage* s = new SimpleImage (PIX_FMT_RGB24, libdcp::Size (50, 50), false);
-       BOOST_CHECK_EQUAL (s->components(), 1);
-       BOOST_CHECK_EQUAL (s->stride()[0], 50 * 3);
-       BOOST_CHECK_EQUAL (s->line_size()[0], 50 * 3);
-       BOOST_CHECK (s->data()[0]);
-       BOOST_CHECK (!s->data()[1]);
-       BOOST_CHECK (!s->data()[2]);
-       BOOST_CHECK (!s->data()[3]);
-
-       /* copy constructor */
-       SimpleImage* t = new SimpleImage (*s);
-       BOOST_CHECK_EQUAL (t->components(), 1);
-       BOOST_CHECK_EQUAL (t->stride()[0], 50 * 3);
-       BOOST_CHECK_EQUAL (t->line_size()[0], 50 * 3);
-       BOOST_CHECK (t->data()[0]);
-       BOOST_CHECK (!t->data()[1]);
-       BOOST_CHECK (!t->data()[2]);
-       BOOST_CHECK (!t->data()[3]);
-       BOOST_CHECK (t->data() != s->data());
-       BOOST_CHECK (t->data()[0] != s->data()[0]);
-       BOOST_CHECK (t->line_size() != s->line_size());
-       BOOST_CHECK (t->line_size()[0] == s->line_size()[0]);
-       BOOST_CHECK (t->stride() != s->stride());
-       BOOST_CHECK (t->stride()[0] == s->stride()[0]);
-
-       /* assignment operator */
-       SimpleImage* u = new SimpleImage (PIX_FMT_YUV422P, libdcp::Size (150, 150), true);
-       *u = *s;
-       BOOST_CHECK_EQUAL (u->components(), 1);
-       BOOST_CHECK_EQUAL (u->stride()[0], 50 * 3);
-       BOOST_CHECK_EQUAL (u->line_size()[0], 50 * 3);
-       BOOST_CHECK (u->data()[0]);
-       BOOST_CHECK (!u->data()[1]);
-       BOOST_CHECK (!u->data()[2]);
-       BOOST_CHECK (!u->data()[3]);
-       BOOST_CHECK (u->data() != s->data());
-       BOOST_CHECK (u->data()[0] != s->data()[0]);
-       BOOST_CHECK (u->line_size() != s->line_size());
-       BOOST_CHECK (u->line_size()[0] == s->line_size()[0]);
-       BOOST_CHECK (u->stride() != s->stride());
-       BOOST_CHECK (u->stride()[0] == s->stride()[0]);
-
-       delete s;
-       delete t;
-       delete u;
+       BOOST_REQUIRE (false);
+       /* Remove warning */
+       return boost::filesystem::path("/");
 }
 
-BOOST_AUTO_TEST_CASE (aligned_image_test)
+void
+make_random_file (boost::filesystem::path path, size_t size)
 {
-       SimpleImage* s = new SimpleImage (PIX_FMT_RGB24, libdcp::Size (50, 50), true);
-       BOOST_CHECK_EQUAL (s->components(), 1);
-       /* 160 is 150 aligned to the nearest 32 bytes */
-       BOOST_CHECK_EQUAL (s->stride()[0], 160);
-       BOOST_CHECK_EQUAL (s->line_size()[0], 150);
-       BOOST_CHECK (s->data()[0]);
-       BOOST_CHECK (!s->data()[1]);
-       BOOST_CHECK (!s->data()[2]);
-       BOOST_CHECK (!s->data()[3]);
-
-       /* copy constructor */
-       SimpleImage* t = new SimpleImage (*s);
-       BOOST_CHECK_EQUAL (t->components(), 1);
-       BOOST_CHECK_EQUAL (t->stride()[0], 160);
-       BOOST_CHECK_EQUAL (t->line_size()[0], 150);
-       BOOST_CHECK (t->data()[0]);
-       BOOST_CHECK (!t->data()[1]);
-       BOOST_CHECK (!t->data()[2]);
-       BOOST_CHECK (!t->data()[3]);
-       BOOST_CHECK (t->data() != s->data());
-       BOOST_CHECK (t->data()[0] != s->data()[0]);
-       BOOST_CHECK (t->line_size() != s->line_size());
-       BOOST_CHECK (t->line_size()[0] == s->line_size()[0]);
-       BOOST_CHECK (t->stride() != s->stride());
-       BOOST_CHECK (t->stride()[0] == s->stride()[0]);
-
-       /* assignment operator */
-       SimpleImage* u = new SimpleImage (PIX_FMT_YUV422P, libdcp::Size (150, 150), false);
-       *u = *s;
-       BOOST_CHECK_EQUAL (u->components(), 1);
-       BOOST_CHECK_EQUAL (u->stride()[0], 160);
-       BOOST_CHECK_EQUAL (u->line_size()[0], 150);
-       BOOST_CHECK (u->data()[0]);
-       BOOST_CHECK (!u->data()[1]);
-       BOOST_CHECK (!u->data()[2]);
-       BOOST_CHECK (!u->data()[3]);
-       BOOST_CHECK (u->data() != s->data());
-       BOOST_CHECK (u->data()[0] != s->data()[0]);
-       BOOST_CHECK (u->line_size() != s->line_size());
-       BOOST_CHECK (u->line_size()[0] == s->line_size()[0]);
-       BOOST_CHECK (u->stride() != s->stride());
-       BOOST_CHECK (u->stride()[0] == s->stride()[0]);
-
-       delete s;
-       delete t;
-       delete u;
+       size_t const chunk = 128 * 1024;
+       uint8_t* buffer = static_cast<uint8_t*> (malloc(chunk));
+       BOOST_REQUIRE (buffer);
+       FILE* r = fopen("/dev/urandom", "rb");
+       BOOST_REQUIRE (r);
+       FILE* t = fopen_boost(path, "wb");
+       BOOST_REQUIRE (t);
+       while (size) {
+               size_t this_time = min (size, chunk);
+               size_t N = fread (buffer, 1, this_time, r);
+               BOOST_REQUIRE (N == this_time);
+               N = fwrite (buffer, 1, this_time, t);
+               BOOST_REQUIRE (N == this_time);
+               size -= this_time;
+       }
+       fclose (t);
+       fclose (r);
+       free (buffer);
 }