From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHWtd-0007c5-QV for qemu-devel@nongnu.org; Tue, 21 Jul 2015 08:43:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHWtY-00036c-Qv for qemu-devel@nongnu.org; Tue, 21 Jul 2015 08:43:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHWtY-00035t-JM for qemu-devel@nongnu.org; Tue, 21 Jul 2015 08:43:40 -0400 References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-15-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <55AE3E6D.4000008@redhat.com> Date: Tue, 21 Jul 2015 06:43:25 -0600 MIME-Version: 1.0 In-Reply-To: <1435782155-31412-15-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rNK2AKpuHJnC1cPNe6hSimeJAINVA1eGA" Subject: Re: [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: Markus Armbruster , qemu-devel@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rNK2AKpuHJnC1cPNe6hSimeJAINVA1eGA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/01/2015 02:22 PM, Markus Armbruster wrote: > A command's 'data' must be a struct type, given either as a > dictionary, or as struct type name. >=20 > Existing test case data-int.json covers simple type 'int'. Add test > cases for type names referring to union and alternate types. We could probably relax things to allow a union (which is always a dictionary on the wire), but I agree that allowing an alternate type is not appropriate (the goal here is that we require a dictionary). But it's also easier to be conservative now and relax later. >=20 > The latter is caught (good), but the former is not (bug). >=20 > 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(-) > +++ b/tests/qapi-schema/args-alternate.json > @@ -0,0 +1,4 @@ > +# we do not allow alternate arguments > +# TODO should we support this? I see no reason to allow a non-dictionary in QMP, so this TODO could be dropped. > +++ 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' } This, on the other hand, seems valid from the wire format (it will always be a dictionary). I guess the problem is that we generate a C function signature based by calling out each member of the dictionary - but how do you do that for a union? So I see what you are doing: marking that this test currently passes the parser, but then causes problems for generating C code, so we should either reject it up front, or fix the generator. The FIXME documents what you will do later in the series (reject it up front) and the TODO documents what we can do down the road (fix the generator to allow it). Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rNK2AKpuHJnC1cPNe6hSimeJAINVA1eGA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVrj5tAAoJEKeha0olJ0Nqs1cIAKKAbj3TjJas9HCQsMXXhER8 RfZQwd4vqbu/pSvpdbkejX6MZPHW8OGg06uCsbUJYXOJVStYDRq4cCTWJX52Ue2r HYHP7Xqkdqt8l1hpG0Jqgjvv/k+50iyej4EPgKYkjExQ8rnTTXecBFyYErIs+2wC K+/3UVMEwjLNhbB9hrb0ph8sbFwRuhqLNEoqDF+c5MTW3pZbRcKqBPeSk4PGN/Dp c1CFYBTehofoSkibknnsnqck7PO3SnTqhRFtW1yU0wOgqoEHaqc7AKcfvTCVdKE/ ERYAq+66U/qnEnc67k2bFSvnvf6G9NB1T07VaiTB4tgb7ITS89oUpHfHZNArKQc= =V/rS -----END PGP SIGNATURE----- --rNK2AKpuHJnC1cPNe6hSimeJAINVA1eGA--