From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNqPm-00082o-78 for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNqPf-0008Ug-9p for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45522 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNqPe-0008SV-Tz for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:07 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AB4FA7502A for ; Wed, 12 Mar 2014 21:10:06 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 12 Mar 2014 22:09:49 +0100 Message-Id: <1394658603-13650-18-git-send-email-afaerber@suse.de> In-Reply-To: <1394658603-13650-1-git-send-email-afaerber@suse.de> References: <1394658603-13650-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL for-2.0-rc0 17/31] qom-test: Test QOM properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= 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=C3=A4rber --- tests/qom-test.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/qom-test.c b/tests/qom-test.c index b6671fb..550efb8 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -10,6 +10,7 @@ #include #include =20 +#include "qemu-common.h" #include "libqtest.h" #include "qemu/osdep.h" #include "qapi/qmp/types.h" @@ -43,6 +44,44 @@ static bool is_blacklisted(const char *arch, const cha= r *mach) return false; } =20 +static void test_properties(const char *path) +{ + char *cmd, *child_path; + QDict *response, *tuple; + QList *list; + QListEntry *entry; + + g_test_message("Obtaining properties of %s", path); + cmd =3D g_strdup_printf("{ 'execute': 'qom-list'," + " 'arguments': { 'path': '%s' } }", path); + response =3D qmp(cmd); + g_free(cmd); + g_assert(response); + + g_assert(qdict_haskey(response, "return")); + list =3D qobject_to_qlist(qdict_get(response, "return")); + QLIST_FOREACH_ENTRY(list, entry) { + tuple =3D qobject_to_qdict(qlist_entry_obj(entry)); + if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) { + child_path =3D g_strdup_printf("%s/%s", + path, qdict_get_str(tuple, "nam= e")); + test_properties(child_path); + g_free(child_path); + } else { + const char *prop =3D qdict_get_str(tuple, "name"); + g_test_message("Testing property %s.%s", path, prop); + cmd =3D g_strdup_printf("{ 'execute': 'qom-get'," + " 'arguments': { 'path': '%s'," + " 'property': '%s' } }= ", + path, prop); + response =3D qmp(cmd); + g_free(cmd); + /* qom-get may fail but should not, e.g., segfault. */ + g_assert(response); + } + } +} + static void test_machine(gconstpointer data) { const char *machine =3D data; @@ -51,8 +90,12 @@ static void test_machine(gconstpointer data) =20 args =3D g_strdup_printf("-machine %s", machine); qtest_start(args); + + test_properties("/machine"); + response =3D qmp("{ 'execute': 'quit' }"); g_assert(qdict_haskey(response, "return")); + qtest_end(); g_free(args); } --=20 1.8.4.5