mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: centralize default memory args in helpers
Replace hard-coded --memory args in simple launch tests with GuestCommand defaults driven by Guest state. Add Guest.mem_size_str with a default of 512M and introduce default_memory_string() and GuestCommand::default_memory(). Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
45a5c7a04e
commit
05aeef06e5
@@ -918,6 +918,7 @@ pub struct Guest {
|
||||
pub console_type: Option<String>,
|
||||
pub num_cpu: u32,
|
||||
pub nested: bool,
|
||||
pub mem_size_str: String,
|
||||
}
|
||||
|
||||
// Return the next id that can be used for this guest. This is stored in a
|
||||
@@ -989,6 +990,7 @@ impl Guest {
|
||||
console_type: None,
|
||||
num_cpu: 1u32,
|
||||
nested: true,
|
||||
mem_size_str: "512M".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1386,6 +1388,10 @@ impl Guest {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn default_memory_string(&self) -> String {
|
||||
format!("size={}", self.mem_size_str)
|
||||
}
|
||||
|
||||
pub fn validate_cpu_count(&self, expected_cpu_count: Option<u32>) {
|
||||
let cpu = match expected_cpu_count {
|
||||
Some(count) => count,
|
||||
@@ -1579,6 +1585,10 @@ impl<'a> GuestCommand<'a> {
|
||||
pub fn default_cpus(&mut self) -> &mut Self {
|
||||
self.args(["--cpus", self.guest.default_cpus_string().as_str()])
|
||||
}
|
||||
|
||||
pub fn default_memory(&mut self) -> &mut Self {
|
||||
self.args(["--memory", self.guest.default_memory_string().as_str()])
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the absolute path into the workspaces target directory to locate the desired
|
||||
|
||||
Reference in New Issue
Block a user