summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-05 22:27:49 +0200
committerCarl Hetherington <cth@carlh.net>2020-10-13 18:51:11 +0200
commitdc5cce1ec77ba13145bb237c70c34074386f34cd (patch)
tree694ff6238d16575da821601fa84430a5b652a2d9
parent52d26bb7d0e960bbf8b88889a2120f7693e53a64 (diff)
Use rand() instead of /dev/urandom to make test files.
-rw-r--r--test/test.cc17
1 files changed, 3 insertions, 14 deletions
diff --git a/test/test.cc b/test/test.cc
index a576ee0c0..e0cf11a46 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -762,24 +762,13 @@ subtitle_file (shared_ptr<Film> film)
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;
+ for (size_t i = 0; i < size; ++i) {
+ uint8_t r = rand() & 0xff;
+ fwrite (&r, 1, 1, t);
}
fclose (t);
- fclose (r);
- free (buffer);
}