On Mon, Oct 21, 2024 at 1:35 PM Junjie Mao <junjie....@hotmail.com> wrote: > > > 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> > > --- > > 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/meson.build b/rust/qemu-api/meson.build > > index 42ea815fa5a..d24e0c0725e 100644 > > --- a/rust/qemu-api/meson.build > > +++ b/rust/qemu-api/meson.build > > @@ -14,11 +14,25 @@ _qemu_api_rs = static_library( > > '--cfg', 'MESON', > > # '--cfg', 'feature="allocator"', > > ], > > - dependencies: [ > > - qemu_api_macros, > > - ], > > ) > > > > qemu_api = declare_dependency( > > link_with: _qemu_api_rs, > > + dependencies: qemu_api_macros, > > ) > > + > > +# Rust executable do not support objects, so add an intermediate step. > > +rust_qemu_api_objs = static_library( > > + 'rust_qemu_api_objs', > > + objects: [libqom.extract_all_objects(recursive: false), > > + libhwcore.extract_all_objects(recursive: false)]) > > + > > +rust.test('rust-qemu-api-integration', > > + static_library( > > + 'rust_qemu_api_integration', > > + 'tests/tests.rs', > > + override_options: ['rust_std=2021', 'build.rust_std=2021'], > > + link_whole: [rust_qemu_api_objs, libqemuutil]), > > + > > + dependencies: [qemu_api, qemu_api_macros], > > + suite: ['unit', 'rust']) > > I met the following error when trying to build the test:
It works for me, but I'll switch to your meson.build code just to be safe. Paolo > test('rust-qemu-api-integration', > executable( > 'rust_qemu_api_integration', > 'tests/tests.rs', > override_options: ['rust_std=2021', 'build.rust_std=2021'], > rust_args: [ > '--test', > ], > install: false, > dependencies: [qemu_api, qemu_api_macros], > link_whole: [rust_qemu_api_objs, libqemuutil]), > args: [ > '--test', > '--format', 'pretty', > ], > protocol: 'rust', > suite: ['unit', 'rust']) > > -- > Best Regards > Junjie Mao >