aboutsummaryrefslogtreecommitdiff
path: root/tests/qom-test.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-03-13 12:32:47 +0000
committerPeter Maydell <peter.maydell@linaro.org>2014-03-13 12:32:47 +0000
commitc8d146aecceb560664b112279ffddf6fe1db99db (patch)
treeee6ad1ab9701df1b9fb69be823b0a6ac9cd03933 /tests/qom-test.c
parent0100f42550201f346cc0c20c1864f941509eb592 (diff)
parentf8762027a33e2f5d0915c56a904962b1481f75c1 (diff)
Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging
QOM/QTest infrastructure fixes and device conversions * QTest cleanups and test cases for some virtio devices * QTest for sPAPR PCI host bridge * qom-test now tests reading all properties beneath /machine * QOM API leak fixes * QOM cleanups for SSI devices * QOM conversion of QEMUMachine * QOM realize for buses * sPAPR PCI bus name change # gpg: Signature made Thu 13 Mar 2014 00:22:40 GMT using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" * remotes/afaerber/tags/qom-devices-for-peter: (31 commits) libqtest: Fix possible deadlock in qtest initialization pci: Move VMState registration/unregistration to QOM realize/unrealize qdev: Realize buses on device realization qdev: Prepare realize/unrealize hooks for BusState tests: Add spapr-pci-host-bridge qtest virtio-serial-port: Convert to QOM realize/unrealize virtio-console: QOM cast cleanup for VirtConsole tests: Add virtio-console qtest tests: Add virtio-serial qtest tests: Add virtio-scsi qtest tests: Add virtio-rng qtest tests: Add virtio-balloon qtest tests: Add virtio-blk qtest tests: Clean up IndustryPack TPCI200 gcov paths qom-test: Test QOM properties hw/boards: Convert current_machine to MachineState vl: Use MachineClass instead of global QEMUMachine list hw/core: Introduce QEMU machine as QOM object qdev-monitor-test: Don't test human-readable error message qdev-monitor-test: Simplify using g_assert_cmpstr() ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qom-test.c')
-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);
}