Il lun 21 ott 2024, 12:34 Junjie Mao <junjie....@hotmail.com> ha scritto:
> > Paolo Bonzini <pbonz...@redhat.com> writes: > > > Adjust the integration test to compile with a subset of QEMU object > > files, and make it actually create an object of the class it defines. > > > > Follow the Rust filesystem conventions, where tests go in tests/ if > > they use the library in the same way any other code would. > > > > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> > > Reviewed-by: Junjie Mao <junjie....@hotmail.com> > > A few minor comments on cosmetic below. > > > --- > > meson.build | 10 ++++- > > rust/qemu-api/meson.build | 20 +++++++-- > > rust/qemu-api/src/tests.rs | 49 ---------------------- > > rust/qemu-api/tests/tests.rs | 78 ++++++++++++++++++++++++++++++++++++ > > 4 files changed, 104 insertions(+), 53 deletions(-) > > delete mode 100644 rust/qemu-api/src/tests.rs > > create mode 100644 rust/qemu-api/tests/tests.rs > > > <snip> > > diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs > > new file mode 100644 > > index 00000000000..57bab62772d > > --- /dev/null > > +++ b/rust/qemu-api/tests/tests.rs > > @@ -0,0 +1,78 @@ > > +// Copyright 2024, Linaro Limited > > +// Author(s): Manos Pitsidianakis <manos.pitsidiana...@linaro.org> > > +// SPDX-License-Identifier: GPL-2.0-or-later > > + > > +use core::ffi::CStr; > > + > > +use qemu_api::{ > > + bindings::*, declare_properties, define_property, > > + definitions::Class, > > + definitions::ObjectImpl, > > + device_class_init, vm_state_description, > > Cargo fmt (with the current rust/rustfmt.toml) formats those lines in a > different way, and ... > I will tweak this. Paolo > +}; > > + > <snip> > > + impl ObjectImpl for DummyState { > > + type Class = DummyClass; > > + const TYPE_INFO: qemu_api::bindings::TypeInfo = > qemu_api::type_info! { Self }; > > + const TYPE_NAME: &'static CStr = c"dummy"; > > + const PARENT_TYPE_NAME: Option<&'static CStr> = > Some(TYPE_DEVICE); > > + const ABSTRACT: bool = false; > > + const INSTANCE_INIT: Option<unsafe extern "C" fn(obj: *mut > Object)> = None; > > + const INSTANCE_POST_INIT: Option<unsafe extern "C" fn(obj: *mut > Object)> = None; > > + const INSTANCE_FINALIZE: Option<unsafe extern "C" fn(obj: *mut > Object)> = None; > > + } > > + > > + impl Class for DummyClass { > > + const CLASS_INIT: Option< > > + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut > core::ffi::c_void), > > + > = Some(dummy_class_init); > > ... ditto. Shall we tweak the formats here or adjust the rustfmt > settings later? > > -- > Best Regards > Junjie Mao > >