mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: factory: Add test for RAW image detection
Verify that open_disk() detects a plain temporary file as RAW and returns a working backend with synchronous fallback. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
9ada7a9afd
commit
01c4e0512f
@@ -200,6 +200,8 @@ fn open_qcow2(
|
||||
mod unit_tests {
|
||||
use std::path::Path;
|
||||
|
||||
use vmm_sys_util::tempfile::TempFile;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn default_options(path: &Path) -> DiskOpenOptions<'_> {
|
||||
@@ -223,4 +225,14 @@ mod unit_tests {
|
||||
Ok(_) => panic!("expected error for nonexistent path"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detect_raw_image() {
|
||||
let tmp = TempFile::new().unwrap();
|
||||
tmp.as_file().set_len(1 << 20).unwrap();
|
||||
let path = tmp.as_path().to_owned();
|
||||
let options = default_options(&path);
|
||||
let opened = open_disk(&options).unwrap();
|
||||
assert_eq!(opened.image_type, ImageType::Raw);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user