From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAOWs-0003Mp-02 for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAOWn-00061u-PX for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAOWn-000619-JB for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:41 -0400 From: Markus Armbruster Date: Wed, 1 Jul 2015 22:22:02 +0200 Message-Id: <1435782155-31412-15-git-send-email-armbru@redhat.com> In-Reply-To: <1435782155-31412-1-git-send-email-armbru@redhat.com> References: <1435782155-31412-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC v2 14/47] qapi-tests: New tests for union, alternate command arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com A command's 'data' must be a struct type, given either as a dictionary, or as struct type name. Existing test case data-int.json covers simple type 'int'. Add test cases for type names referring to union and alternate types. The latter is caught (good), but the former is not (bug). Signed-off-by: Markus Armbruster --- tests/Makefile | 3 ++- tests/qapi-schema/args-alternate.err | 1 + tests/qapi-schema/args-alternate.exit | 1 + tests/qapi-schema/args-alternate.json | 4 ++++ tests/qapi-schema/args-alternate.out | 0 tests/qapi-schema/args-union.err | 0 tests/qapi-schema/args-union.exit | 1 + tests/qapi-schema/args-union.json | 4 ++++ tests/qapi-schema/args-union.out | 4 ++++ 9 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/qapi-schema/args-alternate.err create mode 100644 tests/qapi-schema/args-alternate.exit create mode 100644 tests/qapi-schema/args-alternate.json create mode 100644 tests/qapi-schema/args-alternate.out create mode 100644 tests/qapi-schema/args-union.err create mode 100644 tests/qapi-schema/args-union.exit create mode 100644 tests/qapi-schema/args-union.json create mode 100644 tests/qapi-schema/args-union.out diff --git a/tests/Makefile b/tests/Makefile index eff5e11..5a38748 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -225,7 +225,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ type-bypass.json type-bypass-no-gen.json type-bypass-bad-gen.json \ data-array-empty.json data-array-unknown.json data-int.json \ data-unknown.json data-member-unknown.json data-member-array.json \ - data-member-array-bad.json returns-array-bad.json returns-int.json \ + data-member-array-bad.json args-union.json args-alternate.json \ + returns-array-bad.json returns-int.json \ returns-unknown.json returns-alternate.json returns-whitelist.json \ missing-colon.json missing-comma-list.json missing-comma-object.json \ nested-struct-data.json nested-struct-returns.json non-objects.json \ diff --git a/tests/qapi-schema/args-alternate.err b/tests/qapi-schema/args-alternate.err new file mode 100644 index 0000000..fc90a9e --- /dev/null +++ b/tests/qapi-schema/args-alternate.err @@ -0,0 +1 @@ +tests/qapi-schema/args-alternate.json:4: 'data' for command 'oops' cannot use alternate type 'Alt' diff --git a/tests/qapi-schema/args-alternate.exit b/tests/qapi-schema/args-alternate.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/qapi-schema/args-alternate.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/args-alternate.json b/tests/qapi-schema/args-alternate.json new file mode 100644 index 0000000..d2f9199 --- /dev/null +++ b/tests/qapi-schema/args-alternate.json @@ -0,0 +1,4 @@ +# we do not allow alternate arguments +# TODO should we support this? +{ 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } } +{ 'command': 'oops', 'data': 'Alt' } diff --git a/tests/qapi-schema/args-alternate.out b/tests/qapi-schema/args-alternate.out new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/args-union.err b/tests/qapi-schema/args-union.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/args-union.exit b/tests/qapi-schema/args-union.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/args-union.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/args-union.json b/tests/qapi-schema/args-union.json new file mode 100644 index 0000000..db97ef6 --- /dev/null +++ b/tests/qapi-schema/args-union.json @@ -0,0 +1,4 @@ +# FIXME we should reject union arguments +# TODO should we support this? +{ 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } } +{ 'command': 'oops', 'data': 'Uni' } diff --git a/tests/qapi-schema/args-union.out b/tests/qapi-schema/args-union.out new file mode 100644 index 0000000..907080c --- /dev/null +++ b/tests/qapi-schema/args-union.out @@ -0,0 +1,4 @@ +[OrderedDict([('union', 'Uni'), ('data', OrderedDict([('case1', 'int'), ('case2', 'str')]))]), + OrderedDict([('command', 'oops'), ('data', 'Uni')])] +[{'enum_name': 'UniKind', 'enum_values': None}] +[] -- 1.9.3