]> git.ipfire.org Git - thirdparty/qemu.git/commit
rust/vmstate: Add unit test for vmstate_of macro
authorZhao Liu <zhao1.liu@intel.com>
Tue, 18 Mar 2025 13:02:15 +0000 (21:02 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Mar 2025 11:56:00 +0000 (12:56 +0100)
commit1998502196ad81fde58a48aac2256731bf6d0022
tree24b8bc2874a5ab3e54ff4ba61689803baf86322d
parentb13100372180fdb052aa6bbce663eea0c59e5db4
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>
rust/qemu-api/meson.build
rust/qemu-api/tests/tests.rs
rust/qemu-api/tests/vmstate_tests.rs [new file with mode: 0644]