mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Test config_generation wraps at u8 max
config_generation is a u8 and the spec mandates wrap around. Verify the increment past 0xff lands on 0x00 without panicking under overflow checks. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
ecffd9494c
commit
fcfae4cc4b
@@ -632,4 +632,12 @@ mod unit_tests {
|
||||
regs.consume_config_change();
|
||||
assert_eq!(regs.config_generation.load(Ordering::Acquire), 0x11);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consume_config_change_wraps_at_u8_max() {
|
||||
let regs = make_regs(0xff);
|
||||
regs.config_changed.store(true, Ordering::Release);
|
||||
regs.consume_config_change();
|
||||
assert_eq!(regs.config_generation.load(Ordering::Acquire), 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user