diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-10-21 18:42:03 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-10-21 18:42:03 +0200 |
| commit | f37e6b5a0f320d4352b87b97f78afae762512b93 (patch) | |
| tree | 354a5a8b3882f69fa3de3fed175b30576c58bf6b /test/test.cc | |
| parent | 231644e75f537342c3442c03a3cd5ef34bfa25ec (diff) | |
| parent | dfd42d2a546d14c32057a34002543877ea2f99cb (diff) | |
Merge branch 'v2.15.x' of ssh://git.carlh.net/home/carl/git/dcpomatic into v2.15.xv2.15.25
Diffstat (limited to 'test/test.cc')
| -rw-r--r-- | test/test.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test.cc b/test/test.cc index 318ac4799..c5bc417f3 100644 --- a/test/test.cc +++ b/test/test.cc @@ -495,3 +495,26 @@ subtitle_file (shared_ptr<Film> film) /* 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); +} |
