[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 65/65] tests/qmp-cmd-test: assert qapi-type resolves in query-qmp-schema
- To: qemu-devel@xxxxxxxxxx
- From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
- Date: Tue, 20 Oct 2026 14:46:22 +0400
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-Id:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References"
- Cc: Markus Armbruster <armbru@xxxxxxxxxx>, Michael Roth <michael.roth@xxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>, Pierrick Bouvier <pierrick.bouvier@xxxxxxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, Kostiantyn Kostiuk <kkostiuk@xxxxxxxxxx>, Eric Blake <eblake@xxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Igor Mammedov <imammedo@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Jason Wang <jasowangio@xxxxxxxxx>, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, Alberto Garcia <berto@xxxxxxxxxx>, Kevin Wolf <kwolf@xxxxxxxxxx>, Hanna Reitz <hreitz@xxxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx>, Zhao Liu <zhao1.liu@xxxxxxxxx>, Jonathan Cameron <jic23@xxxxxxxxxx>, Junjie Cao <junjie.cao@xxxxxxxxx>, Anisa Su <anisa.su@xxxxxxxxxxx>, Elena Ufimtseva <elena.ufimtseva@xxxxxxxxxx>, Jagannathan Raman <jag.raman@xxxxxxxxxx>, John Levon <john.levon@xxxxxxxxxxx>, Thanos Makatos <thanos.makatos@xxxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, Eric Farman <farman@xxxxxxxxxxxxx>, Matthew Rosato <mjrosato@xxxxxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Ilya Leoshkevich <iii@xxxxxxxxxxxxx>, qemu-block@xxxxxxxxxx, linux-cxl@xxxxxxxxxxxxxxx, qemu-s390x@xxxxxxxxxx, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Sergio Lopez <slp@xxxxxxxxxx>, qemu-arm@xxxxxxxxxx, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Weiwei Li <liwei1518@xxxxxxxxx>, Daniel Henrique Barboza <daniel.barboza@xxxxxxxxxxxxxxxx>, Liu Zhiwei <zhiwei_liu@xxxxxxxxxxxxxxxxx>, Chao Liu <chao.liu@xxxxxxxxxxxxxxxxxx>, qemu-riscv@xxxxxxxxxx, Song Gao <17746591750@xxxxxxx>, Bibo Mao <maobibo@xxxxxxxxxxx>, Xianglai Li <lixianglai@xxxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Pedro Barbuda <pbarbuda@xxxxxxxxxxxxx>, Mohamed Mediouni <mohamed@xxxxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Harsh Prateek Bora <harshpb@xxxxxxxxxxxxx>, Amit Machhiwal <amachhiw@xxxxxxxxxxxxx>, qemu-ppc@xxxxxxxxxx, Zhang Chen <zhangckid@xxxxxxxxx>, Li Zhijian <lizhijian@xxxxxxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Alexander Graf <graf@xxxxxxxxxx>, "Gonglei (Arei)" <arei.gonglei@xxxxxxxxxx>, zhenwei pi <zhenwei.pi@xxxxxxxxx>, Ani Sinha <anisinha@xxxxxxxxxx>, Luc Michel <luc@xxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Jamin Lin <jamin_lin@xxxxxxxxxxxxxx>, Kane Chen <kane_chen@xxxxxxxxxxxxxx>, Samuel Tardieu <sam@xxxxxxxxxxx>, "Denis V. Lunev" <den@xxxxxxxxxx>, FangSheng Huang <FangSheng.Huang@xxxxxxx>, Tyrone Ting <kfting@xxxxxxxxxxx>, Hao Wu <wuhaotsh@xxxxxxxxxx>, Keith Busch <kbusch@xxxxxxxxxx>, Klaus Jensen <its@xxxxxxxxxxxxx>, Jesper Devantier <foss@xxxxxxxxxxx>, Aditya Gupta <adityag@xxxxxxxxxxxxx>, Glenn Miles <milesg@xxxxxxxxxxxxx>, Conor Dooley <conor@xxxxxxxxxx>, Sebastian Huber <sebastian.huber@xxxxxxxxxxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Jason Herne <jjherne@xxxxxxxxxxxxx>, Titus Rwantare <titusr@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Chinmay Rath <rathc@xxxxxxxxxxxxx>, Hendrik Brueckner <brueckner@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Roman Bolshakov <rbolshakov@xxxxxxx>, Phil Dennis-Jordan <phil@xxxxxxxxxxxxx>, Fam Zheng <fam@xxxxxxxxxx>, Farhan Ali <alifm@xxxxxxxxxxxxx>, Alex Williamson <alex@xxxxxxxxxxx>, Tao Tang <tangtao1634@xxxxxxxxxxxxxx>, Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>, Fabiano Rosas <farosas@xxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Yoshinori Sato <yoshinori.sato@xxxxxxxxx>, Jiri Pirko <jiri@xxxxxxxxxxx>, Eric Auger <eric.auger@xxxxxxxxxx>, Laurent Vivier <lvivier@xxxxxxxxxx>, Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
- Delivery-date: Tue, 20 Oct 2026 10:58:02 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
For every QOM type returned by qom-list-types, call qom-list-properties
and verify that each property's qapi-type value (when present) maps to
a valid entry in the query-qmp-schema introspection output.
The test is gated behind g_test_slow() since it iterates all registered
QOM types.
Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
tests/qtest/qmp-cmd-test.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index 279a8f5614e9..acb7b0dd6a9f 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -15,6 +15,7 @@
#include "qapi/error.h"
#include "qapi/qapi-visit-introspect.h"
#include "qobject/qdict.h"
+#include "qobject/qlist.h"
#include "qapi/qobject-input-visitor.h"
const char common_args[] = "-nodefaults -machine none";
@@ -131,6 +132,8 @@ typedef struct {
GHashTable *hash;
} QmpSchema;
+static QmpSchema schema;
+
static void qmp_schema_init(QmpSchema *schema)
{
QDict *resp;
@@ -343,9 +346,56 @@ static void test_object_add_failure_modes(void)
qtest_quit(qts);
}
+static void test_qapi_type(void)
+{
+ QTestState *qts;
+ g_autoptr(QDict) resp = NULL;
+ QList *types;
+ QListEntry *type_entry, *prop_entry;
+
+ qts = qtest_init(common_args);
+
+ resp = qtest_qmp(qts,
+ "{ 'execute': 'qom-list-types',"
+ " 'arguments': { 'abstract': true } }");
+ g_assert(qdict_haskey(resp, "return"));
+ types = qdict_get_qlist(resp, "return");
+
+ QLIST_FOREACH_ENTRY(types, type_entry) {
+ QDict *type = qobject_to(QDict, qlist_entry_obj(type_entry));
+ const char *name = qdict_get_str(type, "name");
+ g_autoptr(QDict) props_resp = NULL;
+ QList *props;
+
+ props_resp = qtest_qmp(qts,
+ "{ 'execute': 'qom-list-properties',"
+ " 'arguments': { 'typename': %s } }",
+ name);
+ if (!qdict_haskey(props_resp, "return")) {
+ continue;
+ }
+ props = qdict_get_qlist(props_resp, "return");
+
+ QLIST_FOREACH_ENTRY(props, prop_entry) {
+ QDict *prop = qobject_to(QDict, qlist_entry_obj(prop_entry));
+ const char *qapi_type = qdict_get_try_str(prop, "qapi-type");
+ const char *propname = qdict_get_str(prop, "name");
+ const char *ty = qdict_get_str(prop, "type");
+
+ if (qapi_type) {
+ g_assert_nonnull(qmp_schema_lookup(&schema, qapi_type));
+ } else if (!g_str_has_prefix(ty, "child<") &&
+ !g_str_has_prefix(ty, "link<")) {
+ g_test_message("%s.%s %s has no associated qapi-type",
+ name, propname, ty);
+ }
+ }
+ }
+ qtest_quit(qts);
+}
+
int main(int argc, char *argv[])
{
- QmpSchema schema;
int ret;
g_test_init(&argc, &argv, NULL);
@@ -355,6 +405,9 @@ int main(int argc, char *argv[])
qtest_add_func("qmp/object-add-failure-modes",
test_object_add_failure_modes);
+ if (g_test_slow()) {
+ qtest_add_func("qmp/qapi-type", test_qapi_type);
+ }
ret = g_test_run();
--
2.56.0.116.g6de20f6092dc
|