[Qemu-devel] [PATCH 1/7] tests/qapi-schema: Make test-qapi.py print arrays

Markus Armbruster posted 7 patches 6 years, 8 months ago
Maintainers: Markus Armbruster <armbru@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>
[Qemu-devel] [PATCH 1/7] tests/qapi-schema: Make test-qapi.py print arrays
Posted by Markus Armbruster 6 years, 8 months ago
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/qapi-schema/qapi-schema-test.out | 6 ++++++
 tests/qapi-schema/test-qapi.py         | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index d8aec17115..b59f4ca5a4 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -52,6 +52,9 @@ object UserDefTwo
     member dict1: UserDefTwoDict optional=False
 object UserDefThree
     member string0: str optional=False
+array UserDefOneList UserDefOne
+array UserDefTwoList UserDefTwo
+array TestStructList TestStruct
 object ForceArrays
     member unused1: UserDefOneList optional=False
     member unused2: UserDefTwoList optional=False
@@ -248,6 +251,7 @@ object __org.qemu_x-Union1
     member type: __org.qemu_x-Union1Kind optional=False
     tag type
     case __org.qemu_x-branch: q_obj_str-wrapper
+array __org.qemu_x-Union1List __org.qemu_x-Union1
 object __org.qemu_x-Struct2
     member array: __org.qemu_x-Union1List optional=False
 object __org.qemu_x-Union2
@@ -260,6 +264,8 @@ alternate __org.qemu_x-Alt
     case b: __org.qemu_x-Base
 event __ORG.QEMU_X-EVENT __org.qemu_x-Struct
    boxed=False
+array __org.qemu_x-EnumList __org.qemu_x-Enum
+array __org.qemu_x-StructList __org.qemu_x-Struct
 object q_obj___org.qemu_x-command-arg
     member a: __org.qemu_x-EnumList optional=False
     member b: __org.qemu_x-StructList optional=False
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index d592854601..d21fca01fc 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -32,6 +32,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
             self._print_if(m.ifcond, indent=8)
         self._print_if(ifcond)
 
+    def visit_array_type(self, name, info, ifcond, element_type):
+        if not info:
+            return              # suppress built-in arrays
+        print('array %s %s' % (name, element_type.name))
+        self._print_if(ifcond)
+
     def visit_object_type(self, name, info, ifcond, base, members, variants):
         print('object %s' % name)
         if base:
-- 
2.17.2


Re: [Qemu-devel] [PATCH 1/7] tests/qapi-schema: Make test-qapi.py print arrays
Posted by Eric Blake 6 years, 8 months ago
On 3/1/19 9:40 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

Sparse on the why, but I can guess - you intend for the rest of the
series to fix the bug where we don't generate arrays in the same module
as their underlying type when their only use is in a different module,
but to prove that works you need them listed in dump output.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH 1/7] tests/qapi-schema: Make test-qapi.py print arrays
Posted by Markus Armbruster 6 years, 8 months ago
Eric Blake <eblake@redhat.com> writes:

> On 3/1/19 9:40 AM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
> Sparse on the why, but I can guess - you intend for the rest of the
> series to fix the bug where we don't generate arrays in the same module
> as their underlying type when their only use is in a different module,
> but to prove that works you need them listed in dump output.

Could amend like this:

    tests/qapi-schema: Make test-qapi.py print arrays

    The next few commits mess with array types, and having the changes
    exposed in output of test-qapi.py will be useful.

> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!