From patchwork Wed Apr 29 13:06:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 466008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F1EFD1402B0 for ; Wed, 29 Apr 2015 23:13:49 +1000 (AEST) Received: from localhost ([::1]:38833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnRoB-0002NW-PX for incoming@patchwork.ozlabs.org; Wed, 29 Apr 2015 09:13:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnRho-0007i0-Ag for qemu-devel@nongnu.org; Wed, 29 Apr 2015 09:07:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnRhm-00010i-Dt for qemu-devel@nongnu.org; Wed, 29 Apr 2015 09:07:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnRhm-00010Q-4N for qemu-devel@nongnu.org; Wed, 29 Apr 2015 09:07:10 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3TD78Yp018086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 29 Apr 2015 09:07:09 -0400 Received: from red.redhat.com (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3TD6wvw012100; Wed, 29 Apr 2015 09:07:08 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 29 Apr 2015 07:06:34 -0600 Message-Id: <1430312814-19706-20-git-send-email-eblake@redhat.com> In-Reply-To: <1430312814-19706-1-git-send-email-eblake@redhat.com> References: <1430312814-19706-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berto@igalia.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH v7 19/39] qapi: Add tests of redefined expressions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Demonstrate that the qapi generator doesn't deal very well with redefined expressions. At the parse level, they are silently accepted; and while the testsuite just stops at parsing, I've further tested that many of them cause generator crashes or invalid C code if they were appended to qapi-schema-test.json. A later patch will tighten things up and adjust the testsuite to match. Signed-off-by: Eric Blake Reviewed-by: Markus Armbruster --- tests/Makefile | 2 ++ tests/qapi-schema/command-int.err | 0 tests/qapi-schema/command-int.exit | 1 + tests/qapi-schema/command-int.json | 3 +++ tests/qapi-schema/command-int.out | 3 +++ tests/qapi-schema/event-max.err | 0 tests/qapi-schema/event-max.exit | 1 + tests/qapi-schema/event-max.json | 2 ++ tests/qapi-schema/event-max.out | 3 +++ tests/qapi-schema/redefined-builtin.err | 0 tests/qapi-schema/redefined-builtin.exit | 1 + tests/qapi-schema/redefined-builtin.json | 2 ++ tests/qapi-schema/redefined-builtin.out | 3 +++ tests/qapi-schema/redefined-command.err | 0 tests/qapi-schema/redefined-command.exit | 1 + tests/qapi-schema/redefined-command.json | 3 +++ tests/qapi-schema/redefined-command.out | 4 ++++ tests/qapi-schema/redefined-event.err | 0 tests/qapi-schema/redefined-event.exit | 1 + tests/qapi-schema/redefined-event.json | 3 +++ tests/qapi-schema/redefined-event.out | 4 ++++ tests/qapi-schema/redefined-type.err | 0 tests/qapi-schema/redefined-type.exit | 1 + tests/qapi-schema/redefined-type.json | 3 +++ tests/qapi-schema/redefined-type.out | 4 ++++ 25 files changed, 45 insertions(+) create mode 100644 tests/qapi-schema/command-int.err create mode 100644 tests/qapi-schema/command-int.exit create mode 100644 tests/qapi-schema/command-int.json create mode 100644 tests/qapi-schema/command-int.out create mode 100644 tests/qapi-schema/event-max.err create mode 100644 tests/qapi-schema/event-max.exit create mode 100644 tests/qapi-schema/event-max.json create mode 100644 tests/qapi-schema/event-max.out create mode 100644 tests/qapi-schema/redefined-builtin.err create mode 100644 tests/qapi-schema/redefined-builtin.exit create mode 100644 tests/qapi-schema/redefined-builtin.json create mode 100644 tests/qapi-schema/redefined-builtin.out create mode 100644 tests/qapi-schema/redefined-command.err create mode 100644 tests/qapi-schema/redefined-command.exit create mode 100644 tests/qapi-schema/redefined-command.json create mode 100644 tests/qapi-schema/redefined-command.out create mode 100644 tests/qapi-schema/redefined-event.err create mode 100644 tests/qapi-schema/redefined-event.exit create mode 100644 tests/qapi-schema/redefined-event.json create mode 100644 tests/qapi-schema/redefined-event.out create mode 100644 tests/qapi-schema/redefined-type.err create mode 100644 tests/qapi-schema/redefined-type.exit create mode 100644 tests/qapi-schema/redefined-type.json create mode 100644 tests/qapi-schema/redefined-type.out diff --git a/tests/Makefile b/tests/Makefile index 8e955f9..3c1ae3b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -214,6 +214,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ missing-type.json bad-ident.json ident-with-escape.json \ double-type.json bad-base.json bad-type-bool.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 command-int.json event-max.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/command-int.err b/tests/qapi-schema/command-int.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/command-int.exit b/tests/qapi-schema/command-int.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/command-int.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/command-int.json b/tests/qapi-schema/command-int.json new file mode 100644 index 0000000..fcbb643 --- /dev/null +++ b/tests/qapi-schema/command-int.json @@ -0,0 +1,3 @@ +# FIXME: we should reject collisions between commands and types +{ 'command': 'int', 'data': { 'character': 'str' }, + 'returns': { 'value': 'int' } } diff --git a/tests/qapi-schema/command-int.out b/tests/qapi-schema/command-int.out new file mode 100644 index 0000000..d8e1854 --- /dev/null +++ b/tests/qapi-schema/command-int.out @@ -0,0 +1,3 @@ +[OrderedDict([('command', 'int'), ('data', OrderedDict([('character', 'str')])), ('returns', OrderedDict([('value', 'int')]))])] +[] +[] diff --git a/tests/qapi-schema/event-max.err b/tests/qapi-schema/event-max.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/event-max.exit b/tests/qapi-schema/event-max.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/event-max.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/event-max.json b/tests/qapi-schema/event-max.json new file mode 100644 index 0000000..997c61c --- /dev/null +++ b/tests/qapi-schema/event-max.json @@ -0,0 +1,2 @@ +# FIXME: an event named 'MAX' would conflict with implicit C enum +{ 'event': 'MAX' } diff --git a/tests/qapi-schema/event-max.out b/tests/qapi-schema/event-max.out new file mode 100644 index 0000000..010c42b --- /dev/null +++ b/tests/qapi-schema/event-max.out @@ -0,0 +1,3 @@ +[OrderedDict([('event', 'MAX')])] +[] +[] diff --git a/tests/qapi-schema/redefined-builtin.err b/tests/qapi-schema/redefined-builtin.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/redefined-builtin.exit b/tests/qapi-schema/redefined-builtin.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/redefined-builtin.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/redefined-builtin.json b/tests/qapi-schema/redefined-builtin.json new file mode 100644 index 0000000..a10050d --- /dev/null +++ b/tests/qapi-schema/redefined-builtin.json @@ -0,0 +1,2 @@ +# FIXME: we should reject types that duplicate builtin names +{ 'type': 'size', 'data': { 'myint': 'size' } } diff --git a/tests/qapi-schema/redefined-builtin.out b/tests/qapi-schema/redefined-builtin.out new file mode 100644 index 0000000..b0a9aea --- /dev/null +++ b/tests/qapi-schema/redefined-builtin.out @@ -0,0 +1,3 @@ +[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])] +[] +[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])] diff --git a/tests/qapi-schema/redefined-command.err b/tests/qapi-schema/redefined-command.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/redefined-command.exit b/tests/qapi-schema/redefined-command.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/redefined-command.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/redefined-command.json b/tests/qapi-schema/redefined-command.json new file mode 100644 index 0000000..d8c9975 --- /dev/null +++ b/tests/qapi-schema/redefined-command.json @@ -0,0 +1,3 @@ +# FIXME: we should reject commands defined more than once +{ 'command': 'foo', 'data': { 'one': 'str' } } +{ 'command': 'foo', 'data': { '*two': 'str' } } diff --git a/tests/qapi-schema/redefined-command.out b/tests/qapi-schema/redefined-command.out new file mode 100644 index 0000000..44ddba6 --- /dev/null +++ b/tests/qapi-schema/redefined-command.out @@ -0,0 +1,4 @@ +[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]), + OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])] +[] +[] diff --git a/tests/qapi-schema/redefined-event.err b/tests/qapi-schema/redefined-event.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/redefined-event.exit b/tests/qapi-schema/redefined-event.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/redefined-event.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/redefined-event.json b/tests/qapi-schema/redefined-event.json new file mode 100644 index 0000000..152cce7 --- /dev/null +++ b/tests/qapi-schema/redefined-event.json @@ -0,0 +1,3 @@ +# FIXME: we should reject duplicate events +{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } } +{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } } diff --git a/tests/qapi-schema/redefined-event.out b/tests/qapi-schema/redefined-event.out new file mode 100644 index 0000000..261b183 --- /dev/null +++ b/tests/qapi-schema/redefined-event.out @@ -0,0 +1,4 @@ +[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))]), + OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))])] +[] +[] diff --git a/tests/qapi-schema/redefined-type.err b/tests/qapi-schema/redefined-type.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/redefined-type.exit b/tests/qapi-schema/redefined-type.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/redefined-type.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/redefined-type.json b/tests/qapi-schema/redefined-type.json new file mode 100644 index 0000000..7972194 --- /dev/null +++ b/tests/qapi-schema/redefined-type.json @@ -0,0 +1,3 @@ +# FIXME: we should reject types defined more than once +{ 'type': 'foo', 'data': { 'one': 'str' } } +{ 'enum': 'foo', 'data': [ 'two' ] } diff --git a/tests/qapi-schema/redefined-type.out b/tests/qapi-schema/redefined-type.out new file mode 100644 index 0000000..b509e57 --- /dev/null +++ b/tests/qapi-schema/redefined-type.out @@ -0,0 +1,4 @@ +[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))]), + OrderedDict([('enum', 'foo'), ('data', ['two'])])] +[{'enum_name': 'foo', 'enum_values': ['two']}] +[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))])]