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:
Anatol Belski
2026-05-10 00:57:54 +02:00
committed by Rob Bradford
parent ecffd9494c
commit fcfae4cc4b

View File

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