diff --git a/local/recipes/drivers/linux-kpi/source/src/rust_impl/drm_shim.rs b/local/recipes/drivers/linux-kpi/source/src/rust_impl/drm_shim.rs index df0be52849..6622e03bf1 100644 --- a/local/recipes/drivers/linux-kpi/source/src/rust_impl/drm_shim.rs +++ b/local/recipes/drivers/linux-kpi/source/src/rust_impl/drm_shim.rs @@ -907,4 +907,28 @@ mod tests { "an unseen crtc pointer must return 0 from get()" ); } + + #[test] + fn drm_crtc_handle_vblank_is_monotonic_over_many_calls() { + let crtc: *mut u8 = 0x2600 as *mut u8; + let mut last = drm_crtc_handle_vblank(crtc); + let iterations = 1000_u32; + for _ in 0..iterations { + let next = drm_crtc_handle_vblank(crtc); + assert!( + next == last.wrapping_add(1), + "counter must be strictly monotonic over many calls: \ + last={} next={} (delta={})", + last, + next, + next.wrapping_sub(last) + ); + last = next; + } + assert_eq!( + drm_crtc_handle_vblank_get(crtc), + last, + "get() must observe the in-flight latest counter value" + ); + } }