diff options
Diffstat (limited to 'tests')
24 files changed, 31 insertions, 95 deletions
diff --git a/tests/Makefile b/tests/Makefile index 209eca9bae..cb221dec22 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -230,7 +230,6 @@ qapi-schema += alternate-clash.json qapi-schema += alternate-conflict-dict.json qapi-schema += alternate-conflict-string.json qapi-schema += alternate-empty.json -qapi-schema += alternate-good.json qapi-schema += alternate-nested.json qapi-schema += alternate-unknown.json qapi-schema += args-alternate.json @@ -240,7 +239,6 @@ qapi-schema += args-array-unknown.json qapi-schema += args-int.json qapi-schema += args-invalid.json qapi-schema += args-member-array-bad.json -qapi-schema += args-member-array.json qapi-schema += args-member-unknown.json qapi-schema += args-name-clash.json qapi-schema += args-union.json @@ -261,7 +259,6 @@ qapi-schema += enum-bad-name.json qapi-schema += enum-bad-prefix.json qapi-schema += enum-clash-member.json qapi-schema += enum-dict-member.json -qapi-schema += enum-empty.json qapi-schema += enum-int-member.json qapi-schema += enum-max-member.json qapi-schema += enum-missing-data.json @@ -288,7 +285,6 @@ qapi-schema += flat-union-invalid-branch-key.json qapi-schema += flat-union-invalid-discriminator.json qapi-schema += flat-union-no-base.json qapi-schema += flat-union-optional-discriminator.json -qapi-schema += flat-union-reverse-define.json qapi-schema += flat-union-string-discriminator.json qapi-schema += funny-char.json qapi-schema += ident-with-escape.json @@ -320,7 +316,6 @@ qapi-schema += redefined-type.json qapi-schema += returns-alternate.json qapi-schema += returns-array-bad.json qapi-schema += returns-dict.json -qapi-schema += returns-int.json qapi-schema += returns-unknown.json qapi-schema += returns-whitelist.json qapi-schema += struct-base-clash-base.json diff --git a/tests/qapi-schema/alternate-good.err b/tests/qapi-schema/alternate-good.err deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/qapi-schema/alternate-good.err +++ /dev/null diff --git a/tests/qapi-schema/alternate-good.exit b/tests/qapi-schema/alternate-good.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/alternate-good.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/alternate-good.json b/tests/qapi-schema/alternate-good.json deleted file mode 100644 index 33717704ce..0000000000 --- a/tests/qapi-schema/alternate-good.json +++ /dev/null @@ -1,9 +0,0 @@ -# Working example of alternate -{ 'struct': 'Data', - 'data': { '*number': 'int', '*name': 'str' } } -{ 'enum': 'Enum', - 'data': [ 'hello', 'world' ] } -{ 'alternate': 'Alt', - 'data': { 'value': 'int', - 'string': 'Enum', - 'struct': 'Data' } } diff --git a/tests/qapi-schema/alternate-good.out b/tests/qapi-schema/alternate-good.out deleted file mode 100644 index 65af7278f4..0000000000 --- a/tests/qapi-schema/alternate-good.out +++ /dev/null @@ -1,10 +0,0 @@ -object :empty -alternate Alt - case value: int - case string: Enum - case struct: Data -enum AltKind ['value', 'string', 'struct'] -object Data - member number: int optional=True - member name: str optional=True -enum Enum ['hello', 'world'] diff --git a/tests/qapi-schema/args-member-array.err b/tests/qapi-schema/args-member-array.err deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/qapi-schema/args-member-array.err +++ /dev/null diff --git a/tests/qapi-schema/args-member-array.exit b/tests/qapi-schema/args-member-array.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/args-member-array.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/args-member-array.json b/tests/qapi-schema/args-member-array.json deleted file mode 100644 index e6f7f5da13..0000000000 --- a/tests/qapi-schema/args-member-array.json +++ /dev/null @@ -1,4 +0,0 @@ -# valid array members -{ 'enum': 'abc', 'data': [ 'a', 'b', 'c' ] } -{ 'struct': 'def', 'data': { 'array': [ 'abc' ] } } -{ 'command': 'okay', 'data': { 'member1': [ 'int' ], 'member2': [ 'def' ] } } diff --git a/tests/qapi-schema/args-member-array.out b/tests/qapi-schema/args-member-array.out deleted file mode 100644 index b3b92dfc8e..0000000000 --- a/tests/qapi-schema/args-member-array.out +++ /dev/null @@ -1,9 +0,0 @@ -object :empty -object :obj-okay-arg - member member1: intList optional=False - member member2: defList optional=False -enum abc ['a', 'b', 'c'] -object def - member array: abcList optional=False -command okay :obj-okay-arg -> None - gen=True success_response=True diff --git a/tests/qapi-schema/enum-empty.err b/tests/qapi-schema/enum-empty.err deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/qapi-schema/enum-empty.err +++ /dev/null diff --git a/tests/qapi-schema/enum-empty.exit b/tests/qapi-schema/enum-empty.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/enum-empty.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/enum-empty.json b/tests/qapi-schema/enum-empty.json deleted file mode 100644 index 40d4e85a2f..0000000000 --- a/tests/qapi-schema/enum-empty.json +++ /dev/null @@ -1,2 +0,0 @@ -# An empty enum, although unusual, is currently acceptable -{ 'enum': 'MyEnum', 'data': [ ] } diff --git a/tests/qapi-schema/enum-empty.out b/tests/qapi-schema/enum-empty.out deleted file mode 100644 index a449d455fb..0000000000 --- a/tests/qapi-schema/enum-empty.out +++ /dev/null @@ -1,2 +0,0 @@ -object :empty -enum MyEnum [] diff --git a/tests/qapi-schema/flat-union-reverse-define.err b/tests/qapi-schema/flat-union-reverse-define.err deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/qapi-schema/flat-union-reverse-define.err +++ /dev/null diff --git a/tests/qapi-schema/flat-union-reverse-define.exit b/tests/qapi-schema/flat-union-reverse-define.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/flat-union-reverse-define.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/flat-union-reverse-define.json b/tests/qapi-schema/flat-union-reverse-define.json deleted file mode 100644 index 648bbfe2b7..0000000000 --- a/tests/qapi-schema/flat-union-reverse-define.json +++ /dev/null @@ -1,17 +0,0 @@ -{ 'union': 'TestUnion', - 'base': 'TestBase', - 'discriminator': 'enum1', - 'data': { 'value1': 'TestTypeA', - 'value2': 'TestTypeB' } } - -{ 'struct': 'TestBase', - 'data': { 'enum1': 'TestEnum' } } - -{ 'enum': 'TestEnum', - 'data': [ 'value1', 'value2' ] } - -{ 'struct': 'TestTypeA', - 'data': { 'string': 'str' } } - -{ 'struct': 'TestTypeB', - 'data': { 'integer': 'int' } } diff --git a/tests/qapi-schema/flat-union-reverse-define.out b/tests/qapi-schema/flat-union-reverse-define.out deleted file mode 100644 index a5a9134e7e..0000000000 --- a/tests/qapi-schema/flat-union-reverse-define.out +++ /dev/null @@ -1,13 +0,0 @@ -object :empty -object TestBase - member enum1: TestEnum optional=False -enum TestEnum ['value1', 'value2'] -object TestTypeA - member string: str optional=False -object TestTypeB - member integer: int optional=False -object TestUnion - base TestBase - tag enum1 - case value1: TestTypeA - case value2: TestTypeB diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index abe59fd137..4e2d7c2063 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -1,10 +1,15 @@ # *-*- Mode: Python -*-* +# This file is a stress test of supported qapi constructs that must +# parse and compile correctly. + # for testing enums -{ 'enum': 'EnumOne', - 'data': [ 'value1', 'value2', 'value3' ] } { 'struct': 'NestedEnumsOne', - 'data': { 'enum1': 'EnumOne', '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } } + 'data': { 'enum1': 'EnumOne', # Intentional forward reference + '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } } + +# An empty enum, although unusual, is currently acceptable +{ 'enum': 'MyEnum', 'data': [ ] } # for testing override of default naming heuristic { 'enum': 'QEnumTwo', @@ -14,7 +19,11 @@ # for testing nested structs { 'struct': 'UserDefOne', 'base': 'UserDefZero', # intentional forward reference - 'data': { 'string': 'str', '*enum1': 'EnumOne' } } + 'data': { 'string': 'str', + '*enum1': 'EnumOne' } } # intentional forward reference + +{ 'enum': 'EnumOne', + 'data': [ 'value1', 'value2', 'value3' ] } { 'struct': 'UserDefZero', 'data': { 'integer': 'int' } } @@ -31,6 +40,10 @@ 'data': { 'string0': 'str', 'dict1': 'UserDefTwoDict' } } +# dummy struct to force generation of array types not otherwise mentioned +{ 'struct': 'ForceArrays', + 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'] } } + # for testing unions # Among other things, test that a name collision between branches does # not cause any problems (since only one branch can be in use at a time), @@ -98,9 +111,10 @@ { 'command': 'user_def_cmd2', 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } -{ 'command': 'user_def_cmd3', 'data': {'a': 'int', '*b': 'int' }, + +# Returning a non-dictionary requires a name from the whitelist +{ 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' }, 'returns': 'int' } -# note: command name 'guest-sync' chosen to avoid "cannot use built-in" error { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } # For testing integer range flattening in opts-visitor. The following schema diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index 8f817842df..a6c80e04d7 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -17,6 +17,9 @@ object :obj-anyList-wrapper member data: anyList optional=False object :obj-boolList-wrapper member data: boolList optional=False +object :obj-guest-get-time-arg + member a: int optional=False + member b: int optional=True object :obj-guest-sync-arg member arg: any optional=False object :obj-int16List-wrapper @@ -50,9 +53,6 @@ object :obj-user_def_cmd1-arg object :obj-user_def_cmd2-arg member ud1a: UserDefOne optional=False member ud1b: UserDefOne optional=True -object :obj-user_def_cmd3-arg - member a: int optional=False - member b: int optional=True alternate AltIntNum case i: int case n: number @@ -86,6 +86,10 @@ object EventStructOne member struct1: UserDefOne optional=False member string: str optional=False member enum2: EnumOne optional=True +object ForceArrays + member unused1: UserDefOneList optional=False + member unused2: UserDefTwoList optional=False +enum MyEnum [] object NestedEnumsOne member enum1: EnumOne optional=False member enum2: EnumOne optional=True @@ -183,6 +187,8 @@ object __org.qemu_x-Union2 case __org.qemu_x-value: __org.qemu_x-Struct2 command __org.qemu_x-command :obj-__org.qemu_x-command-arg -> __org.qemu_x-Union1 gen=True success_response=True +command guest-get-time :obj-guest-get-time-arg -> int + gen=True success_response=True command guest-sync :obj-guest-sync-arg -> any gen=True success_response=True command user_def_cmd None -> None @@ -191,5 +197,3 @@ command user_def_cmd1 :obj-user_def_cmd1-arg -> None gen=True success_response=True command user_def_cmd2 :obj-user_def_cmd2-arg -> UserDefTwo gen=True success_response=True -command user_def_cmd3 :obj-user_def_cmd3-arg -> int - gen=True success_response=True diff --git a/tests/qapi-schema/returns-int.err b/tests/qapi-schema/returns-int.err deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/qapi-schema/returns-int.err +++ /dev/null diff --git a/tests/qapi-schema/returns-int.exit b/tests/qapi-schema/returns-int.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/returns-int.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/returns-int.json b/tests/qapi-schema/returns-int.json deleted file mode 100644 index 870ec6366b..0000000000 --- a/tests/qapi-schema/returns-int.json +++ /dev/null @@ -1,3 +0,0 @@ -# It is okay (although not extensible) to return a non-dictionary -# But to make it work, the name must be in a whitelist -{ 'command': 'guest-get-time', 'returns': 'int' } diff --git a/tests/qapi-schema/returns-int.out b/tests/qapi-schema/returns-int.out deleted file mode 100644 index a2da259be4..0000000000 --- a/tests/qapi-schema/returns-int.out +++ /dev/null @@ -1,3 +0,0 @@ -object :empty -command guest-get-time None -> int - gen=True success_response=True diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 8d5249e7e4..bc59835835 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -46,7 +46,7 @@ UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, return ret; } -int64_t qmp_user_def_cmd3(int64_t a, bool has_b, int64_t b, Error **errp) +int64_t qmp_guest_get_time(int64_t a, bool has_b, int64_t b, Error **errp) { return a + (has_b ? b : 0); } @@ -160,7 +160,7 @@ static void test_dispatch_cmd_io(void) qdict_put(args3, "a", qint_from_int(66)); qdict_put(req, "arguments", args3); - qdict_put(req, "execute", qstring_from_str("user_def_cmd3")); + qdict_put(req, "execute", qstring_from_str("guest-get-time")); ret3 = qobject_to_qint(test_qmp_dispatch(req)); assert(qint_get_int(ret3) == 66); |