/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#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>
if (env_private) {
private_data = env_private;
}
+
+ dcpomatic_log.reset (new FileLog("build/test/log"));
}
~TestConfig ()
}
void
-write_image (shared_ptr<const Image> image, boost::filesystem::path file, string format)
+write_image (shared_ptr<const Image> image, boost::filesystem::path file, string format, MagickCore::StorageType pixel_type)
{
using namespace MagickCore;
- Magick::Image m (image->size().width, image->size().height, format.c_str(), CharPixel, (void *) image->data()[0]);
+ Magick::Image m (image->size().width, image->size().height, format.c_str(), pixel_type, (void *) image->data()[0]);
m.write (file.string ());
}
/* Remove warning */
return boost::filesystem::path("/");
}
+
+void
+make_random_file (boost::filesystem::path path, size_t size)
+{
+ 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);
+}