diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-10-21 17:25:04 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-10-21 17:25:04 +0200 |
| commit | 48b82de5b6e8e07330a2f72dbddd8d9830fe047e (patch) | |
| tree | 9eab5b143bd389cfa7cd02028a16964abf0baaf9 /test/test.cc | |
| parent | 6dc179f7d08477ecc7bac1257b47dda048a1b878 (diff) | |
Copy with progress updates when we might copy long files (#1574).
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 c87f4e70b..50770a687 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); +} |
