mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
performance-metrics: Add all supported formats to block tests
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -12,7 +12,7 @@ use std::{fs, thread};
|
||||
use test_infra::{Error as InfraError, *};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{mean, PerformanceTestControl};
|
||||
use crate::{mean, ImageFormat, PerformanceTestControl, PerformanceTestOverrides};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-custom-20210609-0.raw";
|
||||
@@ -30,16 +30,30 @@ enum Error {
|
||||
RestoreTimeParse,
|
||||
}
|
||||
|
||||
// The test image cannot be created on tmpfs (e.g. /tmp) filesystem,
|
||||
// as tmpfs does not support O_DIRECT
|
||||
const BLK_IO_TEST_IMG: &str = "/var/tmp/ch-blk-io-test.img";
|
||||
|
||||
pub fn init_tests() {
|
||||
// The test image cannot be created on tmpfs (e.g. /tmp) filesystem,
|
||||
// as tmpfs does not support O_DIRECT
|
||||
assert!(exec_host_command_output(&format!(
|
||||
"dd if=/dev/zero of={BLK_IO_TEST_IMG} bs=1M count=4096"
|
||||
))
|
||||
.status
|
||||
.success());
|
||||
pub fn init_tests(overrides: &PerformanceTestOverrides) {
|
||||
let mut cmd = format!("dd if=/dev/zero of={BLK_IO_TEST_IMG} bs=1M count=4096");
|
||||
|
||||
if let Some(o) = overrides.test_image_format {
|
||||
match o {
|
||||
ImageFormat::Raw => { /* Nothing to do */ }
|
||||
ImageFormat::Qcow2 => {
|
||||
cmd =
|
||||
format!("qemu-img create -f qcow2 -o preallocation=full {BLK_IO_TEST_IMG} 4G");
|
||||
}
|
||||
ImageFormat::Vhd => {
|
||||
cmd = format!("qemu-img create -f vpc -o subformat=fixed {BLK_IO_TEST_IMG} 4G");
|
||||
}
|
||||
ImageFormat::Vhdx => {
|
||||
cmd = format!("qemu-img create -f vhdx -o subformat=fixed {BLK_IO_TEST_IMG} 4G");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(exec_host_command_output(&cmd).status.success());
|
||||
}
|
||||
|
||||
pub fn cleanup_tests() {
|
||||
|
||||
Reference in New Issue
Block a user