From: Carl Hetherington Date: Sat, 18 Jun 2022 18:24:25 +0000 (+0200) Subject: Use boost::random for make_random_file to make it repeatable across platforms. X-Git-Tag: v2.16.15~9 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=2c43d6e1068704cc4f4d6383217ed9a1a07bb67d Use boost::random for make_random_file to make it repeatable across platforms. --- 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 #include #include +#include #include #include #include @@ -59,8 +60,11 @@ extern "C" { } #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dcpomatic_test -#include #include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include #include #include #include @@ -818,14 +822,21 @@ subtitle_file (shared_ptr 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 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; } }