mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 20:33:54 -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::{
|
use qemu_api::{
|
||||||
bindings::*,
|
bindings::*,
|
||||||
c_str, declare_properties, define_property,
|
c_str,
|
||||||
|
cell::{self, BqlCell},
|
||||||
|
declare_properties, define_property,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
qdev::{DeviceImpl, DeviceState, Property},
|
qdev::{DeviceImpl, DeviceState, Property},
|
||||||
qom::ObjectImpl,
|
qom::ObjectImpl,
|
||||||
|
@ -14,8 +16,6 @@ use qemu_api::{
|
||||||
zeroable::Zeroable,
|
zeroable::Zeroable,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_device_decl_macros() {
|
|
||||||
// Test that macros can compile.
|
// Test that macros can compile.
|
||||||
pub static VMSTATE: VMStateDescription = VMStateDescription {
|
pub static VMSTATE: VMStateDescription = VMStateDescription {
|
||||||
name: c_str!("name").as_ptr(),
|
name: c_str!("name").as_ptr(),
|
||||||
|
@ -27,8 +27,8 @@ fn test_device_decl_macros() {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(qemu_api_macros::Object)]
|
#[derive(qemu_api_macros::Object)]
|
||||||
pub struct DummyState {
|
pub struct DummyState {
|
||||||
pub _parent: DeviceState,
|
parent: DeviceState,
|
||||||
pub migrate_clock: bool,
|
migrate_clock: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_properties! {
|
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 {
|
unsafe {
|
||||||
module_call_init(module_init_type::MODULE_INIT_QOM);
|
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());
|
object_unref(object_new(DummyState::TYPE_NAME.as_ptr()).cast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue