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:
Anatol Belski 2026-01-22 11:21:07 +01:00 committed by Bo Chen
parent 13198777dd
commit eaafe426a6

View file

@ -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();