summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-18 20:24:25 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-21 18:55:16 +0200
commit2c43d6e1068704cc4f4d6383217ed9a1a07bb67d (patch)
tree75097f03edf862d9594f9c7d98fe2fcbbeaef0fe
parent6fe11fc6d50bdcd913d92601567aece6716c7112 (diff)
Use boost::random for make_random_file to make it repeatable across platforms.
-rw-r--r--cscript4
-rw-r--r--test/test.cc23
2 files changed, 19 insertions, 8 deletions
diff --git a/cscript b/cscript
index 0ce8c48cb..90480a343 100644
--- a/cscript
+++ b/cscript
@@ -427,8 +427,8 @@ def dependencies(target, options):
# Use distro-provided FFmpeg on Arch
deps = []
- deps.append(('libdcp', 'v1.8.21'))
- deps.append(('libsub', 'v1.6.22'))
+ deps.append(('libdcp', 'v1.8.22'))
+ deps.append(('libsub', 'v1.6.23'))
deps.append(('leqm-nrt', '93ae9e6'))
deps.append(('rtaudio', 'f619b76'))
# We get our OpenSSL libraries from the environment, but we
diff --git a/test/test.cc b/test/test.cc
index 105939473..fd9c6941b 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -50,6 +50,7 @@
#include <dcp/openjpeg_image.h>
#include <dcp/reel.h>
#include <dcp/reel_picture_asset.h>
+#include <dcp/warnings.h>
#include <asdcp/AS_DCP.h>
#include <png.h>
#include <sndfile.h>
@@ -59,8 +60,11 @@ extern "C" {
}
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE dcpomatic_test
-#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.hpp>
+LIBDCP_DISABLE_WARNINGS
+#include <boost/random.hpp>
+LIBDCP_ENABLE_WARNINGS
+#include <boost/test/unit_test.hpp>
#include <iostream>
#include <list>
#include <vector>
@@ -818,14 +822,21 @@ subtitle_file (shared_ptr<Film> film)
return boost::filesystem::path("/");
}
+
void
make_random_file (boost::filesystem::path path, size_t size)
{
- dcp::File t(path, "wb");
- BOOST_REQUIRE (t);
- for (size_t i = 0; i < size; ++i) {
- uint8_t r = rand() & 0xff;
- t.write(&r, 1, 1);
+ dcp::File random_file(path, "wb");
+ BOOST_REQUIRE (random_file);
+
+ boost::random::mt19937 rng(1);
+ boost::random::uniform_int_distribution<uint64_t> dist(0);
+
+ while (size > 0) {
+ auto this_time = std::min(size, size_t(8));
+ uint64_t random = dist(rng);
+ random_file.write(&random, this_time, 1);
+ size -= this_time;
}
}