From 07fd48623d8767aaec333a73e4d1e84543b2cc29 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 26 Nov 2026 12:41:22 -0800 Subject: [PATCH] :bug: Give rvg_write_counts the exports' shape and a call in the C harness 344b04ce6 added rvg_write_counts and failed two of reims-vgpu-c's checks of the C boundary. Its body was `ffi::export()` where every export's whole body is one `ffi::export(|| { ... })` (tests/exports.rs), and tests/c/harness.c, which calls every function the header declares from C, never called it, so the header's 19 functions did not match the harness test's count of 18 (tests/c_harness.rs). The body is now the closure form, which runs the same call, and the C harness calls the function before its quiesce, as QEMU does when a report asks; the count is 19. --- crates/reims-vgpu-c/src/graphics.rs | 4 +++- crates/reims-vgpu-c/tests/c/harness.c | 3 +++ crates/reims-vgpu-c/tests/c_harness.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/reims-vgpu-c/src/graphics.rs b/crates/reims-vgpu-c/src/graphics.rs index 41ed5661b..89ab1d0ba 100644 --- a/crates/reims-vgpu-c/src/graphics.rs +++ b/crates/reims-vgpu-c/src/graphics.rs @@ -846,7 +846,9 @@ pub extern "C" fn rvg_quiesce_for_exit(timeout_ms: u64) -> bool { /// library's. Calls back: never. #[unsafe(no_mangle)] pub extern "C" fn rvg_write_counts() { - ffi::export(GraphicsDevice::::write_counts) + ffi::export(|| { + GraphicsDevice::::write_counts(); + }) } /// The device's region: its first byte, page-aligned, and, through `size` where it is not NULL, diff --git a/crates/reims-vgpu-c/tests/c/harness.c b/crates/reims-vgpu-c/tests/c/harness.c index fcf3b29a3..dc5fecd94 100644 --- a/crates/reims-vgpu-c/tests/c/harness.c +++ b/crates/reims-vgpu-c/tests/c/harness.c @@ -452,6 +452,9 @@ int main(int argc, char **argv) { check_graphics(); check_memory_files(); check_displays(); + /* As QEMU does when reims-ctl's report asks for them while the guest runs: the degradation + * counts on stderr now, where they changed since the library last wrote them. */ + rvg_write_counts(); /* As QEMU does at its quit, the last call before the exit, whose answer is whether the exit * may run; a second call answers at once, with the first answer. On false the harness ends as * QEMU then does: its streams flushed, then _Exit, which runs no exit handler. */ diff --git a/crates/reims-vgpu-c/tests/c_harness.rs b/crates/reims-vgpu-c/tests/c_harness.rs index 64ea45813..b6135fa8d 100644 --- a/crates/reims-vgpu-c/tests/c_harness.rs +++ b/crates/reims-vgpu-c/tests/c_harness.rs @@ -242,7 +242,7 @@ fn c_harness_calls_every_function() { // A function with a form of each OS's (Windows's under `#if defined(_WIN32)`, the others' // under `#if !defined(_WIN32)`) is declared once per form, one after the other. declared.dedup(); - assert_eq!(declared.len(), 18, "{declared:?}"); + assert_eq!(declared.len(), 19, "{declared:?}"); let missing: Vec<&str> = declared .iter() .copied()