From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
Eduardo Habkost <eduardo@habkost.net>,
Fabiano Rosas <farosas@suse.de>,
Laurent Vivier <lvivier@redhat.com>,
Steve Sistare <steven.sistare@oracle.com>
Subject: [PATCH V2 3/5] tests/qtest/qom-test: unit test for qom-tree-get
Date: Mon, 12 May 2025 06:47:13 -0700 [thread overview]
Message-ID: <1747057635-124298-4-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1747057635-124298-1-git-send-email-steven.sistare@oracle.com>
Add a unit test for qom-tree-get
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
tests/qtest/qom-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c
index 27d70bc..d8792bd 100644
--- a/tests/qtest/qom-test.c
+++ b/tests/qtest/qom-test.c
@@ -16,6 +16,54 @@
static int verbosity_level;
+static void test_tree_node(QDict *node)
+{
+ QDict *prop, *child;
+ QList *props, *children;
+ QListEntry *entry;
+
+ g_assert(qdict_haskey(node, "name"));
+ g_assert(qdict_haskey(node, "properties"));
+
+ if (verbosity_level >= 3) {
+ g_test_message("%s", qdict_get_str(node, "name"));
+ }
+
+ props = qobject_to(QList, qdict_get(node, "properties"));
+ QLIST_FOREACH_ENTRY(props, entry) {
+ prop = qobject_to(QDict, qlist_entry_obj(entry));
+ g_assert(qdict_haskey(prop, "name"));
+ g_assert(qdict_haskey(prop, "type"));
+ }
+
+ if (!qdict_haskey(node, "children")) {
+ return;
+ }
+
+ children = qobject_to(QList, qdict_get(node, "children"));
+ QLIST_FOREACH_ENTRY(children, entry) {
+ child = qobject_to(QDict, qlist_entry_obj(entry));
+ test_tree_node(child);
+ }
+}
+
+static void test_tree(QTestState *qts, const char *path)
+{
+ g_autoptr(QDict) response = NULL;
+ QDict *node;
+
+ if (verbosity_level >= 2) {
+ g_test_message("Obtaining tree at %s", path);
+ }
+ response = qtest_qmp(qts, "{ 'execute': 'qom-tree-get',"
+ " 'arguments': { 'path': %s } }", path);
+ g_assert(response);
+
+ g_assert(qdict_haskey(response, "return"));
+ node = qobject_to(QDict, qdict_get(response, "return"));
+ test_tree_node(node);
+}
+
static void test_properties(QTestState *qts, const char *path, bool recurse)
{
char *child_path;
@@ -100,6 +148,7 @@ static void test_machine(gconstpointer data)
}
test_properties(qts, "/machine", true);
+ test_tree(qts, "/machine");
response = qtest_qmp(qts, "{ 'execute': 'quit' }");
g_assert(qdict_haskey(response, "return"));
--
1.8.3.1
next prev parent reply other threads:[~2025-05-12 13:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 13:47 [PATCH V2 0/5] fast qom tree get Steve Sistare
2025-05-12 13:47 ` [PATCH V2 1/5] qom: qom-tree-get Steve Sistare
2025-07-04 12:22 ` Markus Armbruster
2025-07-07 14:44 ` Steven Sistare
2025-07-08 5:06 ` Markus Armbruster
2025-07-08 6:53 ` Markus Armbruster
2025-07-08 7:14 ` Philippe Mathieu-Daudé
2025-07-08 11:50 ` Steven Sistare
2025-07-08 15:17 ` Philippe Mathieu-Daudé
2025-05-12 13:47 ` [PATCH V2 2/5] python: use qom-tree-get Steve Sistare
2025-05-12 13:47 ` Steve Sistare [this message]
2025-07-08 7:15 ` [PATCH V2 3/5] tests/qtest/qom-test: unit test for qom-tree-get Philippe Mathieu-Daudé
2025-05-12 13:47 ` [PATCH V2 4/5] qom: qom-list-getv Steve Sistare
2025-07-04 12:22 ` Markus Armbruster
2025-07-07 14:40 ` Steven Sistare
2025-07-08 4:41 ` Markus Armbruster
2025-05-12 13:47 ` [PATCH V2 5/5] tests/qtest/qom-test: unit test for qom-list-getv Steve Sistare
2025-05-19 21:19 ` [PATCH V2 0/5] fast qom tree get Fabiano Rosas
2025-07-04 12:26 ` Markus Armbruster
2025-07-07 14:39 ` Steven Sistare
2025-07-04 12:33 ` Markus Armbruster
2025-07-07 14:39 ` Steven Sistare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1747057635-124298-4-git-send-email-steven.sistare@oracle.com \
--to=steven.sistare@oracle.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=crosa@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=farosas@suse.de \
--cc=jsnow@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).