mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
tests/plugins: replace rand_ish use with a counter
Rather than generating a random temporary file name for each plugin generated by the test, just use a counter to ensure uniqueness. This was the only remaining rand_ish user, so this change will allow the removal of rand_ish. BUG=None TEST=cargo test --features=plugin Change-Id: I8d42da97870db54a850f686826ca107255b8c3ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3017608 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
771a03b12f
commit
5cf2691610
1 changed files with 6 additions and 3 deletions
|
@ -10,11 +10,11 @@ use std::fs::remove_file;
|
|||
use std::io::{Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
use base::{ioctl, AsRawDescriptor};
|
||||
use rand_ish::urandom_str;
|
||||
use tempfile::tempfile;
|
||||
|
||||
struct RemovePath(PathBuf);
|
||||
|
@ -50,10 +50,13 @@ fn get_crosvm_path() -> PathBuf {
|
|||
}
|
||||
|
||||
fn build_plugin(src: &str) -> RemovePath {
|
||||
static PLUGIN_NUM: AtomicUsize = AtomicUsize::new(0);
|
||||
let libcrosvm_plugin_dir = get_target_path();
|
||||
let mut out_bin = libcrosvm_plugin_dir.clone();
|
||||
let randbin = urandom_str(10).expect("failed to generate random bin name");
|
||||
out_bin.push(randbin);
|
||||
out_bin.push(format!(
|
||||
"plugin-test{}",
|
||||
PLUGIN_NUM.fetch_add(1, Ordering::Relaxed)
|
||||
));
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue