aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2014-02-07 15:36:16 +0100
committerAndreas Färber <afaerber@suse.de>2014-03-13 01:21:45 +0100
commitdc06cbd28611c366096fd1c9b8bba7b459a96877 (patch)
treecb6c3f5dc979a16b8c7bb79e4df59f76dbe55827
parent0056ae24bc36798fdd96d0b31e217e9f73896736 (diff)
qom-test: Test QOM properties
Recursively walk all properties under /machine and try to retrieve their value. This is a regression test for link<> properties and the DeviceState::hotpluggable property. Cf. be2f78b6b062eec5170e2612299fb8953046993f and 1a37eca107cece3ed454bae29eef0bd1fac4a244 Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r--tests/qom-test.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/qom-test.c b/tests/qom-test.c
index b6671fbec3..6d9a00b448 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 "libqtest.h"
#include "qemu/osdep.h"
#include "qapi/qmp/types.h"
@@ -43,6 +44,40 @@ static bool is_blacklisted(const char *arch, const char *mach)
return false;
}
+static void test_properties(const char *path)
+{
+ char *child_path;
+ QDict *response, *tuple;
+ QList *list;
+ QListEntry *entry;
+
+ g_test_message("Obtaining properties of %s", path);
+ response = qmp("{ 'execute': 'qom-list',"
+ " 'arguments': { 'path': '%s' } }", path);
+ g_assert(response);
+
+ 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 {
+ const char *prop = qdict_get_str(tuple, "name");
+ g_test_message("Testing property %s.%s", path, prop);
+ response = qmp("{ 'execute': 'qom-get',"
+ " 'arguments': { 'path': '%s',"
+ " 'property': '%s' } }",
+ path, prop);
+ /* qom-get may fail but should not, e.g., segfault. */
+ g_assert(response);
+ }
+ }
+}
+
static void test_machine(gconstpointer data)
{
const char *machine = data;
@@ -51,8 +86,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);
}