qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 11/19] qapi: Add tests of type bypass


From: Eric Blake
Subject: [Qemu-devel] [PATCH v4 11/19] qapi: Add tests of type bypass
Date: Fri, 19 Sep 2014 16:24:56 -0600

For a few QMP commands, we are forced to pass an arbitrary type
without tracking it properly in QAPI.  Among the existing clients,
this unnamed type was spelled 'dict', 'visitor', and '**'; this
patch standardizes on '**'.  There is no difference to the generated
code.  As the feature was previously undocumented, add some tests
and documentation on what we'd like to guarantee, although it will
take later patches to clean up test results.

Signed-off-by: Eric Blake <address@hidden>
---
 qapi-schema.json                           | 6 +++---
 tests/Makefile                             | 1 +
 tests/qapi-schema/type-bypass-bad-gen.err  | 0
 tests/qapi-schema/type-bypass-bad-gen.exit | 1 +
 tests/qapi-schema/type-bypass-bad-gen.json | 2 ++
 tests/qapi-schema/type-bypass-bad-gen.out  | 3 +++
 tests/qapi-schema/type-bypass-no-gen.err   | 0
 tests/qapi-schema/type-bypass-no-gen.exit  | 1 +
 tests/qapi-schema/type-bypass-no-gen.json  | 2 ++
 tests/qapi-schema/type-bypass-no-gen.out   | 3 +++
 tests/qapi-schema/type-bypass.err          | 0
 tests/qapi-schema/type-bypass.exit         | 1 +
 tests/qapi-schema/type-bypass.json         | 2 ++
 tests/qapi-schema/type-bypass.out          | 3 +++
 14 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 tests/qapi-schema/type-bypass-bad-gen.err
 create mode 100644 tests/qapi-schema/type-bypass-bad-gen.exit
 create mode 100644 tests/qapi-schema/type-bypass-bad-gen.json
 create mode 100644 tests/qapi-schema/type-bypass-bad-gen.out
 create mode 100644 tests/qapi-schema/type-bypass-no-gen.err
 create mode 100644 tests/qapi-schema/type-bypass-no-gen.exit
 create mode 100644 tests/qapi-schema/type-bypass-no-gen.json
 create mode 100644 tests/qapi-schema/type-bypass-no-gen.out
 create mode 100644 tests/qapi-schema/type-bypass.err
 create mode 100644 tests/qapi-schema/type-bypass.exit
 create mode 100644 tests/qapi-schema/type-bypass.json
 create mode 100644 tests/qapi-schema/type-bypass.out

diff --git a/qapi-schema.json b/qapi-schema.json
index 689b548..0b612bf 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1455,7 +1455,7 @@
 ##
 { 'command': 'qom-get',
   'data': { 'path': 'str', 'property': 'str' },
-  'returns': 'visitor',
+  'returns': '**',
   'gen': 'no' }

 ##
@@ -1473,7 +1473,7 @@
 # Since: 1.2
 ##
 { 'command': 'qom-set',
-  'data': { 'path': 'str', 'property': 'str', 'value': 'visitor' },
+  'data': { 'path': 'str', 'property': 'str', 'value': '**' },
   'gen': 'no' }

 ##
@@ -1850,7 +1850,7 @@
 # Since: 2.0
 ##
 { 'command': 'object-add',
-  'data': {'qom-type': 'str', 'id': 'str', '*props': 'dict'},
+  'data': {'qom-type': 'str', 'id': 'str', '*props': '**'},
   'gen': 'no' }

 ##
diff --git a/tests/Makefile b/tests/Makefile
index 201e006..5e01952 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -202,6 +202,7 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
        double-type.json bad-type-int.json bad-type-dict.json \
        double-data.json unknown-expr-key.json redefined-type.json \
        redefined-command.json redefined-builtin.json redefined-event.json \
+       type-bypass.json type-bypass-no-gen.json type-bypass-bad-gen.json \
        missing-colon.json missing-comma-list.json \
        missing-comma-object.json non-objects.json \
        qapi-schema-test.json quoted-structural-chars.json \
diff --git a/tests/qapi-schema/type-bypass-bad-gen.err 
b/tests/qapi-schema/type-bypass-bad-gen.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/type-bypass-bad-gen.exit 
b/tests/qapi-schema/type-bypass-bad-gen.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/type-bypass-bad-gen.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/type-bypass-bad-gen.json 
b/tests/qapi-schema/type-bypass-bad-gen.json
new file mode 100644
index 0000000..6894526
--- /dev/null
+++ b/tests/qapi-schema/type-bypass-bad-gen.json
@@ -0,0 +1,2 @@
+# FIXME: 'gen' should only appear with value 'no'
+{ 'command': 'foo', 'gen': 'whatever' }
diff --git a/tests/qapi-schema/type-bypass-bad-gen.out 
b/tests/qapi-schema/type-bypass-bad-gen.out
new file mode 100644
index 0000000..e678f2c
--- /dev/null
+++ b/tests/qapi-schema/type-bypass-bad-gen.out
@@ -0,0 +1,3 @@
+[OrderedDict([('command', 'foo'), ('gen', 'whatever')])]
+[]
+[]
diff --git a/tests/qapi-schema/type-bypass-no-gen.err 
b/tests/qapi-schema/type-bypass-no-gen.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/type-bypass-no-gen.exit 
b/tests/qapi-schema/type-bypass-no-gen.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/type-bypass-no-gen.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/type-bypass-no-gen.json 
b/tests/qapi-schema/type-bypass-no-gen.json
new file mode 100644
index 0000000..72c817f
--- /dev/null
+++ b/tests/qapi-schema/type-bypass-no-gen.json
@@ -0,0 +1,2 @@
+# FIXME: type bypass should only work with 'gen':'no'
+{ 'command': 'unsafe', 'data': { 'arg': '**' }, 'returns': '**' }
diff --git a/tests/qapi-schema/type-bypass-no-gen.out 
b/tests/qapi-schema/type-bypass-no-gen.out
new file mode 100644
index 0000000..8b2a9ac
--- /dev/null
+++ b/tests/qapi-schema/type-bypass-no-gen.out
@@ -0,0 +1,3 @@
+[OrderedDict([('command', 'unsafe'), ('data', OrderedDict([('arg', '**')])), 
('returns', '**')])]
+[]
+[]
diff --git a/tests/qapi-schema/type-bypass.err 
b/tests/qapi-schema/type-bypass.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/type-bypass.exit 
b/tests/qapi-schema/type-bypass.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/type-bypass.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/type-bypass.json 
b/tests/qapi-schema/type-bypass.json
new file mode 100644
index 0000000..fd65073
--- /dev/null
+++ b/tests/qapi-schema/type-bypass.json
@@ -0,0 +1,2 @@
+# Use of 'gen':'no' allows bypassing type system
+{ 'command': 'unsafe', 'data': { 'arg': '**' }, 'returns': '**', 'gen': 'no' }
diff --git a/tests/qapi-schema/type-bypass.out 
b/tests/qapi-schema/type-bypass.out
new file mode 100644
index 0000000..8957dcb
--- /dev/null
+++ b/tests/qapi-schema/type-bypass.out
@@ -0,0 +1,3 @@
+[OrderedDict([('command', 'unsafe'), ('data', OrderedDict([('arg', '**')])), 
('returns', '**'), ('gen', 'no')])]
+[]
+[]
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]