From 729d97e9939ad5143260bcb79fbb1c02e5315142 Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Mon, 12 Sep 2022 19:36:51 +0300 Subject: [PATCH] test_sort: use Pcg32 random number generator --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + tests/by-util/test_sort.rs | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fefbb83c..e90824cb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,6 +367,7 @@ dependencies = [ "pretty_assertions", "procfs", "rand", + "rand_pcg", "regex", "rlimit", "selinux", @@ -1664,6 +1665,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_pcg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" +dependencies = [ + "rand_core", +] + [[package]] name = "rayon" version = "1.5.3" diff --git a/Cargo.toml b/Cargo.toml index 6086b968e..2830ac531 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -391,6 +391,7 @@ glob = "0.3.0" libc = "0.2" pretty_assertions = "1" rand = "0.8" +rand_pcg = "0.3" regex = "1.6" sha1 = { version="0.10", features=["std"] } tempfile = "3" diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index cb0aa2683..5c753470a 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -1119,13 +1119,13 @@ fn test_tmp_files_deleted_on_sigint() { at.mkdir("tmp_dir"); let file_name = "big_file_to_sort.txt"; { - use rand::Rng; + use rand::{Rng, SeedableRng}; use std::io::Write; let mut file = at.make_file(file_name); // approximately 20 MB for _ in 0..40 { - let lines = rand::thread_rng() - .sample_iter(rand::distributions::uniform::Uniform::new(0, 10007)) + let lines = rand_pcg::Pcg32::seed_from_u64(123) + .sample_iter(rand::distributions::uniform::Uniform::new(0, 10000)) .take(100000) .map(|x| x.to_string() + "\n") .collect::();