summary refs log tree commit diff stats
path: root/rust/qemu-api/tests/tests.rs
diff options
context:
space:
mode:
authorZhao Liu <zhao1.liu@intel.com>2025-03-18 21:02:15 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2025-03-21 12:56:00 +0100
commit1998502196ad81fde58a48aac2256731bf6d0022 (patch)
tree24b8bc2874a5ab3e54ff4ba61689803baf86322d /rust/qemu-api/tests/tests.rs
parentb13100372180fdb052aa6bbce663eea0c59e5db4 (diff)
downloadfocaccia-qemu-1998502196ad81fde58a48aac2256731bf6d0022.tar.gz
focaccia-qemu-1998502196ad81fde58a48aac2256731bf6d0022.zip
rust/vmstate: Add unit test for vmstate_of macro
The vmstate has too many combinations of VMStateFlags and VMStateField.
Currently, the best way to test is to ensure that the Rust vmstate
definition is consistent with the (possibly corresponding) C version.

Add a unit test to cover some patterns accepted by vmstate_of macro,
which correspond to the following C version macros:
 * VMSTATE_U16
 * VMSTATE_UNUSED
 * VMSTATE_VARRAY_UINT16_UNSAFE
 * VMSTATE_VARRAY_MULTIPLY

Note: Because vmstate_info_* are defined in vmstate-types.c, it's
necessary to link libmigration to rust unit tests. In the future,
maybe it's possible to spilt libmigration from rust_qemu_api_objs.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250318130219.1799170-12-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api/tests/tests.rs')
-rw-r--r--rust/qemu-api/tests/tests.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs
index 269122e7ec..99a7aab6fe 100644
--- a/rust/qemu-api/tests/tests.rs
+++ b/rust/qemu-api/tests/tests.rs
@@ -17,6 +17,8 @@ use qemu_api::{
     zeroable::Zeroable,
 };
 
+mod vmstate_tests;
+
 // Test that macros can compile.
 pub static VMSTATE: VMStateDescription = VMStateDescription {
     name: c_str!("name").as_ptr(),