From nobody Sat May 4 13:00:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14958306862981022.8194926538819; Fri, 26 May 2017 13:31:26 -0700 (PDT) Received: from localhost ([::1]:38321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dELtM-0005Hb-Ob for importer@patchew.org; Fri, 26 May 2017 16:31:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dELlb-0005as-5k for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dELlZ-0005PE-7g for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dELlY-0005P3-VC for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE6D2C04BD38 for ; Fri, 26 May 2017 20:23:19 +0000 (UTC) Received: from localhost (ovpn-116-57.gru2.redhat.com [10.97.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8770091735; Fri, 26 May 2017 20:23:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EE6D2C04BD38 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EE6D2C04BD38 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 26 May 2017 17:23:14 -0300 Message-Id: <20170526202316.22736-2-ehabkost@redhat.com> In-Reply-To: <20170526202316.22736-1-ehabkost@redhat.com> References: <20170526202316.22736-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 26 May 2017 20:23:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/3] tests: Simplify abstract-interfaces check with a helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a new type_list_find() helper to device-introspect-test.c, to simplify the code at test_abstract_interfaces(). Signed-off-by: Eduardo Habkost Reviewed-by: Eric Blake --- tests/device-introspect-test.c | 43 ++++++++++++++++++++++++--------------= ---- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index b1abb2ad89..f1e6dddfa3 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -45,6 +45,22 @@ static QList *qom_list_types(const char *implements, boo= l abstract) return ret; } =20 +/* Find an entry on a list returned by qom-list-types */ +static QDict *type_list_find(QList *types, const char *name) +{ + QListEntry *e; + + QLIST_FOREACH_ENTRY(types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *ename =3D qdict_get_str(d, "name"); + if (!strcmp(ename, name)) { + return d; + } + } + + return NULL; +} + static QList *device_type_list(bool abstract) { return qom_list_types("device", abstract); @@ -125,7 +141,7 @@ static void test_abstract_interfaces(void) { QList *all_types; QList *obj_types; - QListEntry *ae; + QListEntry *e; =20 qtest_start(common_args); /* qom-list-types implements=3Dinterface would return any type @@ -138,24 +154,15 @@ static void test_abstract_interfaces(void) all_types =3D qom_list_types(NULL, false); obj_types =3D qom_list_types("object", false); =20 - QLIST_FOREACH_ENTRY(all_types, ae) { - QDict *at =3D qobject_to_qdict(qlist_entry_obj(ae)); - const char *aname =3D qdict_get_str(at, "name"); - QListEntry *oe; - const char *found =3D NULL; - - QLIST_FOREACH_ENTRY(obj_types, oe) { - QDict *ot =3D qobject_to_qdict(qlist_entry_obj(oe)); - const char *oname =3D qdict_get_str(ot, "name"); - if (!strcmp(aname, oname)) { - found =3D oname; - break; - } - } + QLIST_FOREACH_ENTRY(all_types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + + /* + * An interface (incorrectly) marked as non-abstract would + * appear on all_types, but not on obj_types: + */ + g_assert(type_list_find(obj_types, qdict_get_str(d, "name"))); =20 - /* Using g_assert_cmpstr() will give more useful failure - * messages than g_assert(found) */ - g_assert_cmpstr(aname, =3D=3D, found); } =20 QDECREF(all_types); --=20 2.11.0.259.g40922b1 From nobody Sat May 4 13:00:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495830756553217.8402932612081; Fri, 26 May 2017 13:32:36 -0700 (PDT) Received: from localhost ([::1]:38324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dELuV-0006DF-6F for importer@patchew.org; Fri, 26 May 2017 16:32:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dELlc-0005bu-7E for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dELlb-0005Ps-3a for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32980) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dELla-0005PQ-RK for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFC3B753C0 for ; Fri, 26 May 2017 20:23:21 +0000 (UTC) Received: from localhost (ovpn-116-57.gru2.redhat.com [10.97.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 628CF173A7; Fri, 26 May 2017 20:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CFC3B753C0 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CFC3B753C0 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 26 May 2017 17:23:15 -0300 Message-Id: <20170526202316.22736-3-ehabkost@redhat.com> In-Reply-To: <20170526202316.22736-1-ehabkost@redhat.com> References: <20170526202316.22736-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 26 May 2017 20:23:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/3] qmp: Include 'abstract' field on 'qom-list-types' output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A client may be interested in getting the list of both abstract and non-abstract types. Instead of requiring them to make multiple queries with different filter arguments, just return an 'abstract' field in 'qom-list-types'. In addition to the new test code for validating this field, update the abstract-interfaces test case to query for all 'interface' subtypes (including abstract ones), and to look at the 'abstract' field directly. Signed-off-by: Eduardo Habkost Reviewed-by: Eric Blake --- Changes v1 -> v2: * Omit field if false, to keep command output smaller. --- qapi-schema.json | 5 +++- qmp.c | 1 + tests/device-introspect-test.c | 53 +++++++++++++++++++++++++++++++-------= ---- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index e38c5f0423..6af4b38851 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3056,12 +3056,15 @@ # # @name: the type name found in the search # +# @abstract: the type is abstract and can't be directly instantiated. +# Omitted if false. (since 2.10) +# # Since: 1.1 # # Notes: This command is experimental and may change syntax in future rele= ases. ## { 'struct': 'ObjectTypeInfo', - 'data': { 'name': 'str' } } + 'data': { 'name': 'str', '*abstract': 'bool' } } =20 ## # @qom-list-types: diff --git a/qmp.c b/qmp.c index f656940769..413a917802 100644 --- a/qmp.c +++ b/qmp.c @@ -443,6 +443,7 @@ static void qom_list_types_tramp(ObjectClass *klass, vo= id *data) =20 info =3D g_malloc0(sizeof(*info)); info->name =3D g_strdup(object_class_get_name(klass)); + info->has_abstract =3D info->abstract =3D object_class_is_abstract(kla= ss); =20 e =3D g_malloc0(sizeof(*e)); e->value =3D info; diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index f1e6dddfa3..78d4811ba3 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -103,6 +103,33 @@ static void test_device_intro_list(void) qtest_end(); } =20 +static void test_qom_list_fields(void) +{ + QList *all_types; + QList *non_abstract; + QListEntry *e; + + qtest_start(common_args); + + all_types =3D qom_list_types(NULL, true); + non_abstract =3D qom_list_types(NULL, false); + + QLIST_FOREACH_ENTRY(all_types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); + bool abstract =3D qdict_haskey(d, "abstract") ? + qdict_get_bool(d, "abstract") : + false; + bool expected_abstract =3D !type_list_find(non_abstract, name); + + g_assert(abstract =3D=3D expected_abstract); + } + + QDECREF(all_types); + QDECREF(non_abstract); + qtest_end(); +} + static void test_device_intro_none(void) { qtest_start(common_args); @@ -144,25 +171,24 @@ static void test_abstract_interfaces(void) QListEntry *e; =20 qtest_start(common_args); - /* qom-list-types implements=3Dinterface would return any type - * that implements _any_ interface (not just interface types), - * so use a trick to find the interface type names: - * - list all object types - * - list all types, and look for items that are not - * on the first list + /* + * qom-list-types implements=3Dinterface returns all types that + * implement _any_ interface (not just interface types), but + * we can filter them out because interfaces don't implement + * the "object" type. */ - all_types =3D qom_list_types(NULL, false); - obj_types =3D qom_list_types("object", false); + all_types =3D qom_list_types("interface", true); + obj_types =3D qom_list_types("object", true); =20 QLIST_FOREACH_ENTRY(all_types, e) { QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); =20 - /* - * An interface (incorrectly) marked as non-abstract would - * appear on all_types, but not on obj_types: - */ - g_assert(type_list_find(obj_types, qdict_get_str(d, "name"))); + if (type_list_find(obj_types, qdict_get_str(d, "name"))) { + /* Not an interface type */ + continue; + } =20 + g_assert(qdict_haskey(d, "abstract") && qdict_get_bool(d, "abstrac= t")); } =20 QDECREF(all_types); @@ -175,6 +201,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 qtest_add_func("device/introspect/list", test_device_intro_list); + qtest_add_func("device/introspect/list-fields", test_qom_list_fields); qtest_add_func("device/introspect/none", test_device_intro_none); qtest_add_func("device/introspect/abstract", test_device_intro_abstrac= t); qtest_add_func("device/introspect/concrete", test_device_intro_concret= e); --=20 2.11.0.259.g40922b1 From nobody Sat May 4 13:00:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495830918293890.0556733078765; Fri, 26 May 2017 13:35:18 -0700 (PDT) Received: from localhost ([::1]:38334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dELx4-0001Xs-Im for importer@patchew.org; Fri, 26 May 2017 16:35:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dELld-0005eb-U8 for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dELlc-0005Qr-R5 for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dELlc-0005QE-JA for qemu-devel@nongnu.org; Fri, 26 May 2017 16:23:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E0568005D for ; Fri, 26 May 2017 20:23:23 +0000 (UTC) Received: from localhost (ovpn-116-57.gru2.redhat.com [10.97.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EF09179E8; Fri, 26 May 2017 20:23:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E0568005D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9E0568005D From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 26 May 2017 17:23:16 -0300 Message-Id: <20170526202316.22736-4-ehabkost@redhat.com> In-Reply-To: <20170526202316.22736-1-ehabkost@redhat.com> References: <20170526202316.22736-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 May 2017 20:23:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/3] qmp: Include parent type on 'qom-list-types' output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Include name of parent type of each type on 'qom-list-types' output. Without this, there's no way to figure out the parents of a given type without making additional 'qom-list-types' queries. In addition to the test case for the new feature, update the abstract-interface test case to use the new field and avoid the "qom-list-types implements=3Dobject" trick. Signed-off-by: Eduardo Habkost Reviewed-by: Eric Blake --- Changes v1 -> v2: * Include only immediate parent type, rename new field to 'parent' --- qapi-schema.json | 4 +- qmp.c | 5 +++ tests/device-introspect-test.c | 84 +++++++++++++++++++++++++++++++++++++-= ---- 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 6af4b38851..14b09fd069 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3059,12 +3059,14 @@ # @abstract: the type is abstract and can't be directly instantiated. # Omitted if false. (since 2.10) # +# @parent: Name of parent type, if any (since 2.10) +# # Since: 1.1 # # Notes: This command is experimental and may change syntax in future rele= ases. ## { 'struct': 'ObjectTypeInfo', - 'data': { 'name': 'str', '*abstract': 'bool' } } + 'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str' } } =20 ## # @qom-list-types: diff --git a/qmp.c b/qmp.c index 413a917802..db87a74315 100644 --- a/qmp.c +++ b/qmp.c @@ -440,10 +440,15 @@ static void qom_list_types_tramp(ObjectClass *klass, = void *data) { ObjectTypeInfoList *e, **pret =3D data; ObjectTypeInfo *info; + ObjectClass *parent =3D object_class_get_parent(klass); =20 info =3D g_malloc0(sizeof(*info)); info->name =3D g_strdup(object_class_get_name(klass)); info->has_abstract =3D info->abstract =3D object_class_is_abstract(kla= ss); + if (parent) { + info->has_parent =3D true; + info->parent =3D g_strdup(object_class_get_name(parent)); + } =20 e =3D g_malloc0(sizeof(*e)); e->value =3D info; diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index 78d4811ba3..f7162c023f 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -45,6 +45,40 @@ static QList *qom_list_types(const char *implements, boo= l abstract) return ret; } =20 +/* Build a name -> ObjectTypeInfo index from a ObjectTypeInfo list */ +static QDict *qom_type_index(QList *types) +{ + QDict *index =3D qdict_new(); + QListEntry *e; + + QLIST_FOREACH_ENTRY(types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); + QINCREF(d); + qdict_put(index, name, d); + } + return index; +} + +/* Check if @parent is present in the parent chain of @type */ +static bool qom_has_parent(QDict *index, const char *type, const char *par= ent) +{ + while (type) { + QDict *d =3D qdict_get_qdict(index, type); + const char *p =3D d && qdict_haskey(d, "parent") ? + qdict_get_str(d, "parent") : + NULL; + + if (!strcmp(type, parent)) { + return true; + } + + type =3D p; + } + + return false; +} + /* Find an entry on a list returned by qom-list-types */ static QDict *type_list_find(QList *types, const char *name) { @@ -103,6 +137,30 @@ static void test_device_intro_list(void) qtest_end(); } =20 +/* + * Ensure all entries returned by qom-list-types implements=3D + * have as a parent. + */ +static void test_qom_list_parents(const char *parent) +{ + QList *types; + QListEntry *e; + QDict *index; + + types =3D qom_list_types(parent, true); + index =3D qom_type_index(types); + + QLIST_FOREACH_ENTRY(types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); + + g_assert(qom_has_parent(index, name, parent)); + } + + QDECREF(types); + QDECREF(index); +} + static void test_qom_list_fields(void) { QList *all_types; @@ -125,6 +183,10 @@ static void test_qom_list_fields(void) g_assert(abstract =3D=3D expected_abstract); } =20 + test_qom_list_parents("object"); + test_qom_list_parents("device"); + test_qom_list_parents("sys-bus-device"); + QDECREF(all_types); QDECREF(non_abstract); qtest_end(); @@ -167,23 +229,25 @@ static void test_device_intro_concrete(void) static void test_abstract_interfaces(void) { QList *all_types; - QList *obj_types; QListEntry *e; + QDict *index; =20 qtest_start(common_args); - /* - * qom-list-types implements=3Dinterface returns all types that - * implement _any_ interface (not just interface types), but - * we can filter them out because interfaces don't implement - * the "object" type. - */ + all_types =3D qom_list_types("interface", true); - obj_types =3D qom_list_types("object", true); + index =3D qom_type_index(all_types); =20 QLIST_FOREACH_ENTRY(all_types, e) { QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); =20 - if (type_list_find(obj_types, qdict_get_str(d, "name"))) { + /* + * qom-list-types implements=3Dinterface returns all types + * that implement _any_ interface (not just interface + * types), so skip the ones that don't have "interface" + * on the parent type chain. + */ + if (!qom_has_parent(index, name, "interface")) { /* Not an interface type */ continue; } @@ -192,7 +256,7 @@ static void test_abstract_interfaces(void) } =20 QDECREF(all_types); - QDECREF(obj_types); + QDECREF(index); qtest_end(); } =20 --=20 2.11.0.259.g40922b1