From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32C40D0E6EE for ; Mon, 21 Oct 2024 10:47:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2pwX-0001g6-OJ; Mon, 21 Oct 2024 06:47:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2pwW-0001eL-MG for qemu-devel@nongnu.org; Mon, 21 Oct 2024 06:47:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2pwU-0003a0-U1 for qemu-devel@nongnu.org; Mon, 21 Oct 2024 06:47:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729507638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nOVx/dP4UStu4JJZrHz8GvwYSs/ljoTJ5doKqYykNuU=; b=Hf5ZfBiHiliFnXovAjRM/ilU1rGqj0Yxmo667Khdi12awzNgPls83+0RJZpo11OHs0fojX 4kntlUBIbkuL3RD7a+QSQspl6r9lVtzzNpa1AF1AECOOttH6NFyCkWEp+AOiqQQs+3Cw97 9/Ax8vivHOADCQ3JtyPVRemZsL+0uQ8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-OTl0MqxRMiiVZAMhRN-GKA-1; Mon, 21 Oct 2024 06:47:17 -0400 X-MC-Unique: OTl0MqxRMiiVZAMhRN-GKA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d609ef9f7so2060478f8f.3 for ; Mon, 21 Oct 2024 03:47:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729507635; x=1730112435; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nOVx/dP4UStu4JJZrHz8GvwYSs/ljoTJ5doKqYykNuU=; b=xVZ6QPYAD7VYiR09lcH0mHuqsFLTAlhoWsA5UFKUVJ62lVl0J9BSf3CSymdbKqh3pk ofJhNp9jfYOUMXbdvLP1bp7uQzB1786TNHuAw8Ubr5be2IRsqGdwX/Yr844u4l/yWKSR Qawg2KPht0+z/Wepz47DqQJEUQiUQ2+mLkaHnunKwWvOO73NLg5RNKdv6argtaSh7geX twqMOUGnQtu+z3gpnNuLMQPnD6oFOETYil1h4BLkltJr+f9CywFFW8dzhh7jOKXOG4h2 v7dtXZGZF4uUhFq7S6IlW8dMCuE/sZKaanrJ3DsN41k4wSBlaegapHL8GoJC9+tSC+Xv ZkAA== X-Gm-Message-State: AOJu0Yw3tEIJwTEkwa/6PpJ551FbdPhlYqpcU75VwcMn6jqdyGVjuva8 ECrzsLn/2EmBuVjRjvpSjSXPu97z9lTLFzdqhrwtWp94l4XoK7IHRzIHfmWh4BU6yDqCcc0zUgU peYfw5qeS5z75kicdSPmxRIv4zC82UblmzHNLi4geB9snh/RP8VLu8AvVW0J+jX9ogpWgT6y1gW /0RnMBKBKjfCqNy318QQFE/AdgoT6Qfg7JMWmjcA== X-Received: by 2002:adf:fb45:0:b0:37c:d23f:e465 with SMTP id ffacd0b85a97d-37eab712dbfmr6378525f8f.55.1729507634881; Mon, 21 Oct 2024 03:47:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLv9VUDyQ/Em58uBwbIr45rzFfbC2fXesrjBmWLNWJVRf+dZoJYsnqybub6lBBbGrsjeqSEhbrnHrfavPAus8= X-Received: by 2002:adf:fb45:0:b0:37c:d23f:e465 with SMTP id ffacd0b85a97d-37eab712dbfmr6378514f8f.55.1729507634526; Mon, 21 Oct 2024 03:47:14 -0700 (PDT) MIME-Version: 1.0 References: <20241018144306.954716-1-pbonzini@redhat.com> <20241018144306.954716-9-pbonzini@redhat.com> In-Reply-To: From: Paolo Bonzini Date: Mon, 21 Oct 2024 12:47:04 +0200 Message-ID: Subject: Re: [PATCH 08/13] rust: build integration test for the qemu_api crate To: Junjie Mao Cc: qemu-devel , Manos Pitsidianakis Content-Type: multipart/alternative; boundary="0000000000003150bc0624fa604c" Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --0000000000003150bc0624fa604c Content-Type: text/plain; charset="UTF-8" Il lun 21 ott 2024, 12:34 Junjie Mao ha scritto: > > Paolo Bonzini 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 > > Reviewed-by: Junjie Mao > > 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 > > > > > 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 > > +// 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 > +}; > > + > > > + 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 Object)> = None; > > + const INSTANCE_POST_INIT: Option Object)> = None; > > + const INSTANCE_FINALIZE: Option 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 > > --0000000000003150bc0624fa604c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Il lun 21 ott 2024, 12:34 Junjie Mao <junjie.mao@hotmail.com> ha scritto:
=

Paolo Bonzini <pbonzini@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.<= br> >
> 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 <pbonzini@redhat.com>

Reviewed-by: Junjie Mao <junjie.mao@hotmail.com>

A few minor comments on cosmetic below.

> ---
>=C2=A0 meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 | 10 ++++-
>=C2=A0 rust/qemu-api/meson.build=C2=A0 =C2=A0 | 20 +++++++--
>=C2=A0 rust/qemu-api/src/tests.rs=C2=A0 =C2=A0| 49 ---------------= -------
>=C2=A0 rust/qemu-api/tests/tests.rs | 78 +++++++++++++++++++++++++= +++++++++++
>=C2=A0 4 files changed, 104 insertions(+), 53 deletions(-)
>=C2=A0 delete mode 100644 rust/qemu-api/src/tests.rs
>=C2=A0 create mode 100644 rust/qemu-api/tests/tests.rs
>
<snip>
> diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/<= a href=3D"http://tests.rs" rel=3D"noreferrer noreferrer" target=3D"_blank">= 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.pitsidianakis= @linaro.org>
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +use core::ffi::CStr;
> +
> +use qemu_api::{
> +=C2=A0 =C2=A0 bindings::*, declare_properties, define_property,
> +=C2=A0 =C2=A0 definitions::Class,
> +=C2=A0 =C2=A0 definitions::ObjectImpl,
> +=C2=A0 =C2=A0 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.

<= div dir=3D"auto">Paolo

<= div class=3D"gmail_quote">
> +};
> +
<snip>
> +=C2=A0 =C2=A0 impl ObjectImpl for DummyState {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 type Class =3D DummyClass;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const TYPE_INFO: qemu_api::bindings::Type= Info =3D qemu_api::type_info! { Self };
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const TYPE_NAME: &'static CStr = =3D c"dummy";
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const PARENT_TYPE_NAME: Option<&&#= 39;static CStr> =3D Some(TYPE_DEVICE);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const ABSTRACT: bool =3D false;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const INSTANCE_INIT: Option<unsafe ext= ern "C" fn(obj: *mut Object)> =3D None;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const INSTANCE_POST_INIT: Option<unsaf= e extern "C" fn(obj: *mut Object)> =3D None;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const INSTANCE_FINALIZE: Option<unsafe= extern "C" fn(obj: *mut Object)> =3D None;
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 impl Class for DummyClass {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const CLASS_INIT: Option<
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsafe extern "C"= fn(klass: *mut ObjectClass, data: *mut core::ffi::c_void),
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =3D Some(dummy_class_i= nit);

... ditto. Shall we tweak the formats here or adjust the rustfmt
settings later?

--
Best Regards
Junjie Mao

--0000000000003150bc0624fa604c--