Il lun 21 ott 2024, 13:55 Junjie Mao <junjie....@hotmail.com> ha scritto:

>
> Paolo Bonzini <pbonz...@redhat.com> writes:
>
> > 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.
>
> That's odd. What's the version of Rust and meson you have used in your
> test? On my side they're 1.82.0 and 1.5.1.
>

Nightly and 1.5.1, but I also tested with 1.63.0.

Anyhow the extra static_library() is not too nice either; so using test()
and executable() is fine by me.

Paolo

Rust.test() is still preferrable to me for its brevity, as long as it
> works.
>
> --
> Best Regards
> Junjie Mao
>
>

Reply via email to