mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Test O_DIRECT write and read roundtrip
Write 128K of patterned data and read it back with O_DIRECT active to verify the aligned I/O paths produce correct results. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
e67195ce48
commit
98c533a501
@@ -1053,4 +1053,22 @@ mod unit_tests {
|
||||
"sub-sector O_DIRECT read should return written data"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_qcow_async_direct_io_write_read_roundtrip() {
|
||||
let temp_file = TempFile::new().unwrap();
|
||||
let disk = match try_create_direct_io_disk(&temp_file, 100 * 1024 * 1024) {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
eprintln!("skipping: O_DIRECT not supported on this filesystem");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let pattern: Vec<u8> = (0..128 * 1024).map(|i| (i % 251) as u8).collect();
|
||||
async_write(&disk, 0, &pattern);
|
||||
|
||||
let buf = async_read(&disk, 0, pattern.len());
|
||||
assert_eq!(buf, pattern, "O_DIRECT roundtrip should match");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user