block: qcow: Port tests to QcowTempDisk

Port tests over to QcowTempDisk and also over to QcowDisk rather than
QcowFile where necessary.

Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-06-05 14:56:20 +01:00
parent 31ee5e99e4
commit cfce14edd1
4 changed files with 237 additions and 320 deletions
+4 -8
View File
@@ -205,13 +205,12 @@ fn open_qcow2(
#[cfg(test)]
mod unit_tests {
use std::io::Write;
use std::path::Path;
use vmm_sys_util::tempfile::TempFile;
use super::*;
use crate::qcow::{QcowFile, RawFile};
use crate::formats::qcow;
fn default_options(path: &Path) -> DiskOpenOptions<'_> {
DiskOpenOptions {
@@ -247,12 +246,9 @@ mod unit_tests {
#[test]
fn detect_qcow2_image() {
let tmp = TempFile::new().unwrap();
{
let raw = RawFile::new(tmp.as_file().try_clone().unwrap(), false);
let mut qcow = QcowFile::new(raw, 3, 100 * 1024 * 1024, true).unwrap();
qcow.flush().unwrap();
}
let tmp = qcow::QcowTempDisk::new(100 * 1024 * 1024, None, false, true, false)
.unwrap()
.into_tempfile();
let path = tmp.as_path().to_owned();
let options = default_options(&path);
let opened = open_disk(&options).unwrap();