mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
rust: tests: allow writing more than one test
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d4873c5d4f
commit
c2f41c1b15
1 changed files with 63 additions and 48 deletions
|
@ -6,7 +6,9 @@ use std::ffi::CStr;
|
|||
|
||||
use qemu_api::{
|
||||
bindings::*,
|
||||
c_str, declare_properties, define_property,
|
||||
c_str,
|
||||
cell::{self, BqlCell},
|
||||
declare_properties, define_property,
|
||||
prelude::*,
|
||||
qdev::{DeviceImpl, DeviceState, Property},
|
||||
qom::ObjectImpl,
|
||||
|
@ -14,8 +16,6 @@ use qemu_api::{
|
|||
zeroable::Zeroable,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_device_decl_macros() {
|
||||
// Test that macros can compile.
|
||||
pub static VMSTATE: VMStateDescription = VMStateDescription {
|
||||
name: c_str!("name").as_ptr(),
|
||||
|
@ -27,8 +27,8 @@ fn test_device_decl_macros() {
|
|||
#[repr(C)]
|
||||
#[derive(qemu_api_macros::Object)]
|
||||
pub struct DummyState {
|
||||
pub _parent: DeviceState,
|
||||
pub migrate_clock: bool,
|
||||
parent: DeviceState,
|
||||
migrate_clock: bool,
|
||||
}
|
||||
|
||||
declare_properties! {
|
||||
|
@ -61,8 +61,23 @@ fn test_device_decl_macros() {
|
|||
}
|
||||
}
|
||||
|
||||
fn init_qom() {
|
||||
static ONCE: BqlCell<bool> = BqlCell::new(false);
|
||||
|
||||
cell::bql_start_test();
|
||||
if !ONCE.get() {
|
||||
unsafe {
|
||||
module_call_init(module_init_type::MODULE_INIT_QOM);
|
||||
}
|
||||
ONCE.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Create and immediately drop an instance.
|
||||
fn test_object_new() {
|
||||
init_qom();
|
||||
unsafe {
|
||||
object_unref(object_new(DummyState::TYPE_NAME.as_ptr()).cast());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue