mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
tests: Use incrementing IP and mac address for VMs
This allows us to test multiple VMs at once. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
93c2099ab6
commit
80f33113cb
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -154,6 +154,7 @@ dependencies = [
|
||||
"clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"credibility 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ssh2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vmm 0.1.0",
|
||||
|
@ -13,6 +13,7 @@ ssh2 = "=0.3.3"
|
||||
dirs = "2.0.0"
|
||||
credibility = "0.1.3"
|
||||
tempdir="0.3.7"
|
||||
lazy_static=">=1.1.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
20
src/main.rs
20
src/main.rs
@ -152,6 +152,11 @@ fn main() {
|
||||
#[macro_use]
|
||||
extern crate credibility;
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "integration_tests")]
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "integration_tests")]
|
||||
mod tests {
|
||||
@ -161,9 +166,14 @@ mod tests {
|
||||
use std::net::TcpStream;
|
||||
use std::process::Command;
|
||||
use std::string::String;
|
||||
use std::sync::Mutex;
|
||||
use std::thread;
|
||||
use tempdir::TempDir;
|
||||
|
||||
lazy_static! {
|
||||
static ref NEXT_VM_ID: Mutex<u8> = Mutex::new(1);
|
||||
}
|
||||
|
||||
struct Guest {
|
||||
tmp_dir: TempDir,
|
||||
disks: Vec<String>,
|
||||
@ -206,13 +216,17 @@ mod tests {
|
||||
fn new() -> Self {
|
||||
let tmp_dir = TempDir::new("ch").unwrap();
|
||||
|
||||
let mut guard = NEXT_VM_ID.lock().unwrap();
|
||||
let id = *guard;
|
||||
*guard = id + 1;
|
||||
|
||||
let mut guest = Guest {
|
||||
tmp_dir,
|
||||
disks: Vec::new(),
|
||||
fw_path: String::new(),
|
||||
guest_ip: String::from("192.168.2.2"),
|
||||
host_ip: String::from("192.168.2.1"),
|
||||
guest_mac: String::from("12:34:56:78:90:ab"),
|
||||
guest_ip: format!("192.168.{}.2", id),
|
||||
host_ip: format!("192.168.{}.1", id),
|
||||
guest_mac: format!("12:34:56:78:90:{:02x}", id),
|
||||
};
|
||||
|
||||
guest.prepare_files();
|
||||
|
Loading…
x
Reference in New Issue
Block a user