From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhgX7-0003JS-G3 for qemu-devel@nongnu.org; Tue, 06 May 2014 10:39:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhgWy-0005cf-KJ for qemu-devel@nongnu.org; Tue, 06 May 2014 10:39:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhgWy-0005cY-Bm for qemu-devel@nongnu.org; Tue, 06 May 2014 10:39:40 -0400 Message-ID: <5368F42A.4080607@redhat.com> Date: Tue, 06 May 2014 10:39:38 -0400 From: Cole Robinson MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= ping On 04/11/2014 06:07 PM, Cole Robinson wrote: > But don't test their properties, otherwise we will recurse forever. > Their properties are already tested when we encounter them as child > properties elsewhere in the hierarchy, like /machine/unattached/... > > This would have caught the crash fixed by 92b3eead > > Signed-off-by: Cole Robinson > --- > tests/qom-test.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/tests/qom-test.c b/tests/qom-test.c > index 6d9a00b..d8d1d8d 100644 > --- a/tests/qom-test.c > +++ b/tests/qom-test.c > @@ -44,7 +44,7 @@ static bool is_blacklisted(const char *arch, const char *mach) > return false; > } > > -static void test_properties(const char *path) > +static void test_properties(const char *path, bool recurse) > { > char *child_path; > QDict *response, *tuple; > @@ -56,14 +56,21 @@ static void test_properties(const char *path) > " 'arguments': { 'path': '%s' } }", path); > g_assert(response); > > + if (!recurse) { > + return; > + } > + > 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)) { > + bool is_child = strstart(qdict_get_str(tuple, "type"), "child<", NULL); > + bool is_link = strstart(qdict_get_str(tuple, "type"), "link<", NULL); > + > + if (is_child || is_link) { > child_path = g_strdup_printf("%s/%s", > path, qdict_get_str(tuple, "name")); > - test_properties(child_path); > + test_properties(child_path, is_child); > g_free(child_path); > } else { > const char *prop = qdict_get_str(tuple, "name"); > @@ -87,7 +94,7 @@ static void test_machine(gconstpointer data) > args = g_strdup_printf("-machine %s", machine); > qtest_start(args); > > - test_properties("/machine"); > + test_properties("/machine", true); > > response = qmp("{ 'execute': 'quit' }"); > g_assert(qdict_haskey(response, "return")); >