mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: qcow: Add unit test for zero bit helpers
Add test for l2_entry_is_zero() and related helper functions. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
@@ -2597,6 +2597,26 @@ mod unit_tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_l2_entry_zero_flag() {
|
||||
let empty_entry: u64 = 0;
|
||||
let standard_entry: u64 = 0x1000;
|
||||
let zero_flag_entry: u64 = 0x1000 | ZERO_FLAG;
|
||||
let compressed_entry: u64 = COMPRESSED_FLAG;
|
||||
|
||||
assert!(l2_entry_is_empty(empty_entry));
|
||||
assert!(!l2_entry_is_empty(standard_entry));
|
||||
|
||||
assert!(!l2_entry_is_compressed(standard_entry));
|
||||
assert!(l2_entry_is_compressed(compressed_entry));
|
||||
|
||||
assert!(!l2_entry_is_zero(standard_entry));
|
||||
assert!(l2_entry_is_zero(zero_flag_entry));
|
||||
|
||||
// Note: l2_entry_is_zero() only checks bit 0, so compressed entries
|
||||
// must be checked first as the code does in file_read.
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_header_1_tb_file() {
|
||||
let mut header = test_huge_header();
|
||||
|
||||
Reference in New Issue
Block a user