qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, armbru@redhat.com, aliguori@amazon.com,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH qom-test] qom-test: Test QOM properties
Date: Fri,  7 Feb 2014 15:39:13 +0100	[thread overview]
Message-ID: <1391783953-1974-1-git-send-email-afaerber@suse.de> (raw)

Recursively walk all properties under /machine and try to retrieve their
value. This is a regression test for link<> properties.

Cf. be2f78b6b062eec5170e2612299fb8953046993f

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 tests/qom-test.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tests/qom-test.c b/tests/qom-test.c
index 3316a11..779cd1d 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -10,6 +10,7 @@
 
 #include <glib.h>
 #include <string.h>
+#include "qemu-common.h"
 #include "qemu/osdep.h"
 #include "qapi/qmp/types.h"
 
@@ -42,6 +43,39 @@ static bool is_blacklisted(const char *arch, const char *mach)
     return false;
 }
 
+static void test_properties(const char *path)
+{
+    char *cmd, *child_path;
+    QDict *response, *tuple;
+    QList *list;
+    QListEntry *entry;
+
+    cmd = g_strdup_printf("{ 'execute': 'qom-list',"
+                          "  'arguments': { 'path': '%s' } }", path);
+    response = qmp(cmd);
+    g_free(cmd);
+
+    g_assert(qdict_haskey(response, "return"));
+    list = qobject_to_qlist(qdict_get(response, "return"));
+    QLIST_FOREACH_ENTRY(list, entry) {
+        tuple = qobject_to_qdict(qlist_entry_obj(entry));
+        if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) {
+            child_path = g_strdup_printf("%s/%s",
+                                         path, qdict_get_str(tuple, "name"));
+            test_properties(child_path);
+            g_free(child_path);
+        } else {
+            cmd = g_strdup_printf("{ 'execute': 'qom-get',"
+                                  "  'arguments': { 'path': '%s',"
+                                  "                 'property': '%s' } }",
+                                  path, qdict_get_str(tuple, "name"));
+            response = qmp(cmd);
+            g_free(cmd);
+            /* This may fail but should not, e.g., segfault. */
+        }
+    }
+}
+
 static void test_machine(gconstpointer data)
 {
     const char *machine = data;
@@ -50,8 +84,12 @@ static void test_machine(gconstpointer data)
 
     args = g_strdup_printf("-machine %s", machine);
     qtest_start(args);
+
+    test_properties("/machine");
+
     response = qmp("{ 'execute': 'quit' }");
     g_assert(qdict_haskey(response, "return"));
+
     qtest_end();
     g_free(args);
 }
-- 
1.8.4.5

             reply	other threads:[~2014-02-07 14:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 14:39 Andreas Färber [this message]
2014-03-07 16:02 ` [Qemu-devel] [PATCH qom-test] qom-test: Test QOM properties Andreas Färber

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=1391783953-1974-1-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=armbru@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).