Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 429AF606A324 for ; Sun, 1 Nov 2026 20:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I8SBfLXr Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNc1J-0006XW-9E; Sun, 01 Nov 2026 15:19:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNbzk-0004uW-MY for qemu-devel@nongnu.org; Sun, 01 Nov 2026 15:17:37 -0500 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 1xNbzd-0007BP-T2 for qemu-devel@nongnu.org; Sun, 01 Nov 2026 15:17:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793564248; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vNjhBet4yMhVV39knjevH4SHqYj7pufQdSEW6D21yqI=; b=I8SBfLXr4QJMvK3eg0d2XVgs83TZbXGK/WGKplb4hk4QE6+3e8C+owAMEetdlwNuiq3AIb DKJsww3XEn15pJmG3TpjR/8YzuWD2bkauL4YJOJ4LyT6RM+nBeReO4x32IXAl0IlgokKKi uadlI2auHKIZVdBzltUFGu5GnW97cac= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-SFkJZgGnMgylSjQQao0DqQ-1; Sun, 01 Nov 2026 15:17:27 -0500 X-MC-Unique: SFkJZgGnMgylSjQQao0DqQ-1 X-Mimecast-MFC-AGG-ID: SFkJZgGnMgylSjQQao0DqQ_1793564246 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4DB2D1954AE2 for ; Sun, 1 Nov 2026 20:17:26 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD7FA7E1 for ; Sun, 1 Nov 2026 20:17:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DE25021E6895; Sun, 01 Nov 2026 21:17:17 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 17/56] tests: update check-qom-proplist for QAPI-aware property registration Date: Sun, 1 Nov 2026 21:16:38 +0100 Message-ID: <20261101201717.3911097-18-armbru@redhat.com> In-Reply-To: <20261101201717.3911097-1-armbru@redhat.com> References: <20261101201717.3911097-1-armbru@redhat.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Marc-André Lureau Migrate the dummy object's string and enum properties from the legacy object_class_property_add_str/enum() helpers to the new QAPI-aware object_class_property_add_qapi/qapi_enum() registration. Add test cases verifying that the qapi_type metadata is correctly populated on properties registered through the new API, and that it remains NULL for properties using the old-style registration. Signed-off-by: Marc-André Lureau Signed-off-by: Markus Armbruster --- tests/unit/check-qom-proplist.c | 87 ++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplist.c index 804d066f28..246935d714 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -108,22 +108,21 @@ static int dummy_get_av(Object *obj, } -static void dummy_set_sv(Object *obj, - const char *value, - Error **errp) +static void dummy_set_sv(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { DummyObject *dobj = DUMMY_OBJECT(obj); - g_free(dobj->sv); - dobj->sv = g_strdup(value); + g_clear_pointer(&dobj->sv, g_free); + visit_type_str(v, name, &dobj->sv, errp); } -static char *dummy_get_sv(Object *obj, - Error **errp) +static void dummy_get_sv(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { DummyObject *dobj = DUMMY_OBJECT(obj); - return g_strdup(dobj->sv); + visit_type_str(v, name, &dobj->sv, errp); } @@ -135,13 +134,25 @@ static void dummy_init(Object *obj) } +static const QAPITypeInfo dummy_animal_qapi_type_info = { + .name = "DummyAnimal", + .masked_name = "DummyAnimalSchema", + .lookup = &dummy_animal_map, +}; + +static const QAPITypeInfo dummy_str_qapi_type_info = { + .name = "str", + .masked_name = "StrSchema", +}; + static void dummy_class_init(ObjectClass *cls, const void *data) { - object_class_property_add_str(cls, "sv", - dummy_get_sv, - dummy_set_sv); - object_class_property_add_enum(cls, "av", "DummyAnimal", NULL, - &dummy_animal_map, + object_class_property_add(cls, "sv", "str", + &dummy_str_qapi_type_info, + dummy_get_sv, dummy_set_sv, + NULL, NULL); + object_class_property_add_enum(cls, "av", "DummyAnimal", + &dummy_animal_qapi_type_info, NULL, dummy_get_av, dummy_set_av); } @@ -702,6 +713,54 @@ static void test_qom_partial_path(void) object_unparent(cont1); } +static void test_dummy_qapi_enum(void) +{ + ObjectProperty *prop; + Object *parent = object_get_objects_root(); + DummyObject *dobj = DUMMY_OBJECT( + object_new_with_props(TYPE_DUMMY, + parent, + "dummy0", + &error_abort, + "av", "platypus", + NULL)); + + g_assert(dobj->av == DUMMY_PLATYPUS); + + prop = object_property_find(OBJECT(dobj), "av"); + g_assert(prop); + g_assert(prop->qapi_type == &dummy_animal_qapi_type_info); + g_assert_cmpstr(prop->qapi_type->name, ==, "DummyAnimal"); + g_assert_cmpstr(prop->qapi_type->masked_name, ==, "DummyAnimalSchema"); + g_assert(prop->qapi_type->lookup == &dummy_animal_map); + + object_unparent(OBJECT(dobj)); +} + +static void test_dummy_qapi_prop(void) +{ + ObjectProperty *prop; + Object *parent = object_get_objects_root(); + DummyObject *dobj = DUMMY_OBJECT( + object_new_with_props(TYPE_DUMMY, + parent, + "dummy0", + &error_abort, + "sv", "hello", + NULL)); + + g_assert_cmpstr(dobj->sv, ==, "hello"); + + prop = object_property_find(OBJECT(dobj), "sv"); + g_assert(prop); + g_assert(prop->qapi_type == &dummy_str_qapi_type_info); + g_assert_cmpstr(prop->qapi_type->name, ==, "str"); + g_assert_cmpstr(prop->qapi_type->masked_name, ==, "StrSchema"); + g_assert(prop->qapi_type->lookup == NULL); + + object_unparent(OBJECT(dobj)); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -726,6 +785,8 @@ int main(int argc, char **argv) g_test_add_func("/qom/proplist/iterator", test_dummy_iterator); g_test_add_func("/qom/proplist/class_iterator", test_dummy_class_iterator); g_test_add_func("/qom/proplist/delchild", test_dummy_delchild); + g_test_add_func("/qom/proplist/qapi_enum", test_dummy_qapi_enum); + g_test_add_func("/qom/proplist/qapi_prop", test_dummy_qapi_prop); g_test_add_func("/qom/resolve/partial", test_qom_partial_path); return g_test_run(); -- 2.55.0