From patchwork Fri Sep 19 22:24:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 391431 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 CD34B140161 for ; Sat, 20 Sep 2014 08:30:09 +1000 (EST) Received: from localhost ([::1]:60844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV6gp-0004T2-MJ for incoming@patchwork.ozlabs.org; Fri, 19 Sep 2014 18:30:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV6cX-0004Pe-Ft for qemu-devel@nongnu.org; Fri, 19 Sep 2014 18:25:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XV6cR-0004Zh-6W for qemu-devel@nongnu.org; Fri, 19 Sep 2014 18:25:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV6cQ-0004Wx-S7 for qemu-devel@nongnu.org; Fri, 19 Sep 2014 18:25:35 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8JMPSLx006135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Sep 2014 18:25:28 -0400 Received: from red.redhat.com (ovpn-113-164.phx2.redhat.com [10.3.113.164]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8JMPLPe007538; Fri, 19 Sep 2014 18:25:27 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 19 Sep 2014 16:24:56 -0600 Message-Id: <1411165504-18198-12-git-send-email-eblake@redhat.com> In-Reply-To: <1411165504-18198-1-git-send-email-eblake@redhat.com> References: <1411165504-18198-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Luiz Capitulino , Fam Zheng , Markus Armbruster , wenchaoqemu@gmail.com Subject: [Qemu-devel] [PATCH v4 11/19] qapi: Add tests of type bypass 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 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 Reviewed-by: Markus Armbruster --- 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')])] +[] +[]