tests: Fix path handling for qemu-img check

The image passed for the guest construction is copied. Previously,
check-img has been checking the unchanged image from the workspace dir,
which is supposed to be error free.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2025-11-28 17:36:33 +01:00
committed by Rob Bradford
parent e6dd429a64
commit f56adb8a5a

View File

@@ -3396,7 +3396,12 @@ mod common_parallel {
handle_child_output(r, &output); handle_child_output(r, &output);
} }
fn _test_virtio_block(image_name: &str, disable_io_uring: bool, disable_aio: bool) { fn _test_virtio_block(
image_name: &str,
disable_io_uring: bool,
disable_aio: bool,
verify_os_disk: bool,
) {
let disk_config = UbuntuDiskConfig::new(image_name.to_string()); let disk_config = UbuntuDiskConfig::new(image_name.to_string());
let guest = Guest::new(Box::new(disk_config)); let guest = Guest::new(Box::new(disk_config));
@@ -3479,21 +3484,25 @@ mod common_parallel {
let output = cloud_child.wait_with_output().unwrap(); let output = cloud_child.wait_with_output().unwrap();
handle_child_output(r, &output); handle_child_output(r, &output);
if verify_os_disk {
disk_check_consistency(guest.disk_config.disk(DiskType::OperatingSystem).unwrap());
}
} }
#[test] #[test]
fn test_virtio_block_io_uring() { fn test_virtio_block_io_uring() {
_test_virtio_block(FOCAL_IMAGE_NAME, false, true); _test_virtio_block(FOCAL_IMAGE_NAME, false, true, false);
} }
#[test] #[test]
fn test_virtio_block_aio() { fn test_virtio_block_aio() {
_test_virtio_block(FOCAL_IMAGE_NAME, true, false); _test_virtio_block(FOCAL_IMAGE_NAME, true, false, false);
} }
#[test] #[test]
fn test_virtio_block_sync() { fn test_virtio_block_sync() {
_test_virtio_block(FOCAL_IMAGE_NAME, true, true); _test_virtio_block(FOCAL_IMAGE_NAME, true, true, false);
} }
/// Uses `qemu-img check` to verify disk image consistency. /// Uses `qemu-img check` to verify disk image consistency.
@@ -3529,32 +3538,32 @@ mod common_parallel {
#[test] #[test]
fn test_virtio_block_qcow2() { fn test_virtio_block_qcow2() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2, false, false); _test_virtio_block(JAMMY_IMAGE_NAME_QCOW2, false, false, true);
disk_check_consistency(JAMMY_IMAGE_NAME_QCOW2);
} }
#[test] #[test]
fn test_virtio_block_qcow2_zlib() { fn test_virtio_block_qcow2_zlib() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZLIB, false, false); _test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZLIB, false, false, true);
disk_check_consistency(JAMMY_IMAGE_NAME_QCOW2_ZLIB);
} }
#[test] #[test]
fn test_virtio_block_qcow2_zstd() { fn test_virtio_block_qcow2_zstd() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZSTD, false, false); _test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZSTD, false, false, true);
disk_check_consistency(JAMMY_IMAGE_NAME_QCOW2_ZSTD);
} }
#[test] #[test]
fn test_virtio_block_qcow2_backing_zstd_file() { fn test_virtio_block_qcow2_backing_zstd_file() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_BACKING_ZSTD_FILE, false, false); _test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_BACKING_ZSTD_FILE, false, false, true);
disk_check_consistency(JAMMY_IMAGE_NAME_QCOW2_BACKING_ZSTD_FILE);
} }
#[test] #[test]
fn test_virtio_block_qcow2_backing_uncompressed_file() { fn test_virtio_block_qcow2_backing_uncompressed_file() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_BACKING_UNCOMPRESSED_FILE, false, false); _test_virtio_block(
disk_check_consistency(JAMMY_IMAGE_NAME_QCOW2_BACKING_UNCOMPRESSED_FILE); JAMMY_IMAGE_NAME_QCOW2_BACKING_UNCOMPRESSED_FILE,
false,
false,
true,
);
} }
#[test] #[test]
@@ -3579,7 +3588,7 @@ mod common_parallel {
.output() .output()
.expect("Expect generating VHD image from RAW image"); .expect("Expect generating VHD image from RAW image");
_test_virtio_block(FOCAL_IMAGE_NAME_VHD, false, false); _test_virtio_block(FOCAL_IMAGE_NAME_VHD, false, false, false);
} }
#[test] #[test]
@@ -3603,8 +3612,7 @@ mod common_parallel {
.output() .output()
.expect("Expect generating dynamic VHDx image from RAW image"); .expect("Expect generating dynamic VHDx image from RAW image");
_test_virtio_block(FOCAL_IMAGE_NAME_VHDX, false, false); _test_virtio_block(FOCAL_IMAGE_NAME_VHDX, false, false, true);
disk_check_consistency(FOCAL_IMAGE_NAME_VHDX);
} }
#[test] #[test]