summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Prilik <prilik@google.com>2019-01-14 14:19:04 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-01-17 20:20:50 -0800
commit2200604d9c101888df658f9483290a13952c6b1c (patch)
tree8b3982baeeb7f61824f95bd8a91a972f3104b729 /tests
parenta4d5bd4bc271c505097f18ea0506926dbdf8d682 (diff)
downloadcrosvm-2200604d9c101888df658f9483290a13952c6b1c.tar
crosvm-2200604d9c101888df658f9483290a13952c6b1c.tar.gz
crosvm-2200604d9c101888df658f9483290a13952c6b1c.tar.bz2
crosvm-2200604d9c101888df658f9483290a13952c6b1c.tar.lz
crosvm-2200604d9c101888df658f9483290a13952c6b1c.tar.xz
crosvm-2200604d9c101888df658f9483290a13952c6b1c.tar.zst
crosvm-2200604d9c101888df658f9483290a13952c6b1c.zip
remove rand crate
the few uses of rand::thread_rng() have been replaced with either
prngs or reads from /dev/urandom. the implementations are under
the `rand_ish` minicrate.

`protoc-rust` depends on `tempdir`, which relies on rand, so
`tempdir` has been patched with a rewritten version that does not
have rand as a dependency.

BUG=chromium:921795
TEST=cargo test --features plugin

Change-Id: I6f1c7d7a1aeef4dd55ac71e58294d16c291b8871
Reviewed-on: https://chromium-review.googlesource.com/1409705
Commit-Ready: Daniel Prilik <prilik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/plugins.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/plugins.rs b/tests/plugins.rs
index 20adcab..6176a32 100644
--- a/tests/plugins.rs
+++ b/tests/plugins.rs
@@ -4,11 +4,9 @@
 
 #![cfg(feature = "plugin")]
 
-extern crate rand;
+extern crate rand_ish;
 extern crate sys_util;
 
-use rand::{thread_rng, Rng};
-
 use std::env::{current_exe, var_os};
 use std::ffi::OsString;
 use std::fs::{remove_file, File};
@@ -19,6 +17,7 @@ use std::process::{Command, Stdio};
 use std::thread::sleep;
 use std::time::Duration;
 
+use rand_ish::urandom_str;
 use sys_util::{ioctl, SharedMemory};
 
 struct RemovePath(PathBuf);
@@ -56,7 +55,8 @@ fn get_crosvm_path() -> PathBuf {
 fn build_plugin(src: &str) -> RemovePath {
     let libcrosvm_plugin_dir = get_target_path();
     let mut out_bin = libcrosvm_plugin_dir.clone();
-    out_bin.push(thread_rng().gen_ascii_chars().take(10).collect::<String>());
+    let randbin = urandom_str(10).expect("failed to generate random bin name");
+    out_bin.push(randbin);
     let mut child = Command::new(var_os("CC").unwrap_or(OsString::from("cc")))
         .args(&["-Icrosvm_plugin", "-pthread", "-o"]) // crosvm.h location and set output path.
         .arg(&out_bin)