projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6fe11fc
)
Use boost::random for make_random_file to make it repeatable across platforms.
author
Carl Hetherington
<cth@carlh.net>
Sat, 18 Jun 2022 18:24:25 +0000
(20:24 +0200)
committer
Carl Hetherington
<cth@carlh.net>
Tue, 21 Jun 2022 16:55:16 +0000
(18:55 +0200)
cscript
patch
|
blob
|
history
test/test.cc
patch
|
blob
|
history
diff --git
a/cscript
b/cscript
index 0ce8c48cba42e5ace14e8dea439e34e297ae2d89..90480a34398ad40220e15ca0f6f0751416957ac7 100644
(file)
--- a/
cscript
+++ b/
cscript
@@
-427,8
+427,8
@@
def dependencies(target, options):
# Use distro-provided FFmpeg on Arch
deps = []
# Use distro-provided FFmpeg on Arch
deps = []
- deps.append(('libdcp', 'v1.8.2
1
'))
- deps.append(('libsub', 'v1.6.2
2
'))
+ deps.append(('libdcp', 'v1.8.2
2
'))
+ deps.append(('libsub', 'v1.6.2
3
'))
deps.append(('leqm-nrt', '93ae9e6'))
deps.append(('rtaudio', 'f619b76'))
# We get our OpenSSL libraries from the environment, but we
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 1059394731a9e21917683807f15ffbba64fe9e09..fd9c6941be30e4aac818a3debf3f2b6706df865b 100644
(file)
--- 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/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>
#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
}
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE dcpomatic_test
-#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.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>
#include <iostream>
#include <list>
#include <vector>
@@
-818,14
+822,21
@@
subtitle_file (shared_ptr<Film> film)
return boost::filesystem::path("/");
}
return boost::filesystem::path("/");
}
+
void
make_random_file (boost::filesystem::path path, size_t size)
{
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;
}
}
}
}