qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties
@ 2014-04-11 22:07 Cole Robinson
  2014-05-06 14:39 ` Cole Robinson
  2014-05-07 13:06 ` Andreas Färber
  0 siblings, 2 replies; 3+ messages in thread
From: Cole Robinson @ 2014-04-11 22:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber, Cole Robinson

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 <crobinso@redhat.com>
---
 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"));
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties
  2014-04-11 22:07 [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties Cole Robinson
@ 2014-05-06 14:39 ` Cole Robinson
  2014-05-07 13:06 ` Andreas Färber
  1 sibling, 0 replies; 3+ messages in thread
From: Cole Robinson @ 2014-05-06 14:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber

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 <crobinso@redhat.com>
> ---
>  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"));
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties
  2014-04-11 22:07 [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties Cole Robinson
  2014-05-06 14:39 ` Cole Robinson
@ 2014-05-07 13:06 ` Andreas Färber
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2014-05-07 13:06 UTC (permalink / raw)
  To: Cole Robinson, qemu-devel

Am 12.04.2014 00:07, schrieb Cole Robinson:
> 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 <crobinso@redhat.com>
> ---
>  tests/qom-test.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)

Sorry, slipped through... Tested and applied now:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Thanks,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-07 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11 22:07 [Qemu-devel] [PATCH] tests/qom-test: Test qom-list on link properties Cole Robinson
2014-05-06 14:39 ` Cole Robinson
2014-05-07 13:06 ` Andreas Färber

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).