From patchwork Tue Mar 5 16:52:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 722C91669 for ; Tue, 5 Mar 2019 17:15:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 524D92B8D0 for ; Tue, 5 Mar 2019 17:15:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 466A82B9BF; Tue, 5 Mar 2019 17:15:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E07DD2B8D0 for ; Tue, 5 Mar 2019 17:15:27 +0000 (UTC) Received: from localhost ([127.0.0.1]:46212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1Df4-0005oL-OY for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:15:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJI-00031q-9S for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002f3-53 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJG-0002Uu-S8 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 649FA30EBE69 for ; Tue, 5 Mar 2019 16:52:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34940608C1 for ; Tue, 5 Mar 2019 16:52:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A30941138661; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:30 +0100 Message-Id: <20190305165236.8389-2-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 05 Mar 2019 16:52:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/7] tests/qapi-schema: Make test-qapi.py print arrays X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The next few commits mess with array types, and having the changes exposed in output of test-qapi.py will be useful. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-2-armbru@redhat.com> Reviewed-by: Eric Blake [Rationale added to commit message] --- tests/qapi-schema/qapi-schema-test.out | 6 ++++++ tests/qapi-schema/test-qapi.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index d8aec17115..b59f4ca5a4 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -52,6 +52,9 @@ object UserDefTwo member dict1: UserDefTwoDict optional=False object UserDefThree member string0: str optional=False +array UserDefOneList UserDefOne +array UserDefTwoList UserDefTwo +array TestStructList TestStruct object ForceArrays member unused1: UserDefOneList optional=False member unused2: UserDefTwoList optional=False @@ -248,6 +251,7 @@ object __org.qemu_x-Union1 member type: __org.qemu_x-Union1Kind optional=False tag type case __org.qemu_x-branch: q_obj_str-wrapper +array __org.qemu_x-Union1List __org.qemu_x-Union1 object __org.qemu_x-Struct2 member array: __org.qemu_x-Union1List optional=False object __org.qemu_x-Union2 @@ -260,6 +264,8 @@ alternate __org.qemu_x-Alt case b: __org.qemu_x-Base event __ORG.QEMU_X-EVENT __org.qemu_x-Struct boxed=False +array __org.qemu_x-EnumList __org.qemu_x-Enum +array __org.qemu_x-StructList __org.qemu_x-Struct object q_obj___org.qemu_x-command-arg member a: __org.qemu_x-EnumList optional=False member b: __org.qemu_x-StructList optional=False diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index d592854601..d21fca01fc 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -32,6 +32,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_if(m.ifcond, indent=8) self._print_if(ifcond) + def visit_array_type(self, name, info, ifcond, element_type): + if not info: + return # suppress built-in arrays + print('array %s %s' % (name, element_type.name)) + self._print_if(ifcond) + def visit_object_type(self, name, info, ifcond, base, members, variants): print('object %s' % name) if base: From patchwork Tue Mar 5 16:52:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 867CB1669 for ; Tue, 5 Mar 2019 17:18:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B7D2B995 for ; Tue, 5 Mar 2019 17:18:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 593BB2BA05; Tue, 5 Mar 2019 17:18:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 099312B995 for ; Tue, 5 Mar 2019 17:18:02 +0000 (UTC) Received: from localhost ([127.0.0.1]:46269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DhZ-0007iW-CK for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:18:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJI-00031i-5y for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002fB-7Z for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJG-0002UY-V7 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70FD43092647 for ; Tue, 5 Mar 2019 16:52:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FEA1282D0 for ; Tue, 5 Mar 2019 16:52:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A60C311385D4; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:31 +0100 Message-Id: <20190305165236.8389-3-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 05 Mar 2019 16:52:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/7] tests/qapi-schema: Cover conditional arrays X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit 967c885108f neglected to cover arrays of conditional types. Do that now. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-3-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/qapi-schema-test.out | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index cb0857df52..70612f394e 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -236,5 +236,5 @@ { 'event': 'TestIfEvent', 'data': { 'foo': 'TestIfStruct', - 'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_EVT_BAR)' } }, + 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index b59f4ca5a4..97f671ca5f 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -325,9 +325,11 @@ command TestIfCmd q_obj_TestIfCmd-arg -> UserDefThree if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] command TestCmdReturnDefThree None -> UserDefThree gen=True success_response=True boxed=False oob=False preconfig=False +array TestIfEnumList TestIfEnum + if ['defined(TEST_IF_ENUM)'] object q_obj_TestIfEvent-arg member foo: TestIfStruct optional=False - member bar: TestIfEnum optional=False + member bar: TestIfEnumList optional=False if ['defined(TEST_IF_EVT_BAR)'] if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] event TestIfEvent q_obj_TestIfEvent-arg From patchwork Tue Mar 5 16:52:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1971D14DE for ; Tue, 5 Mar 2019 17:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA3202C520 for ; Tue, 5 Mar 2019 17:12:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB8D72C8F0; Tue, 5 Mar 2019 17:12:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4340B2C520 for ; Tue, 5 Mar 2019 17:12:47 +0000 (UTC) Received: from localhost ([127.0.0.1]:46111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DcU-0003ME-JF for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:12:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJI-00031y-FQ for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002ex-2D for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41623) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJG-0002Z1-NC for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 959B23DD99 for ; Tue, 5 Mar 2019 16:52:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E7BD5D9CC for ; Tue, 5 Mar 2019 16:52:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AA91A11385D5; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:32 +0100 Message-Id: <20190305165236.8389-4-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 05 Mar 2019 16:52:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/7] qapi: Pass file name to QAPIGen constructor instead of methods X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Not much of an improvement now, but the next commit will profit. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-4-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/commands.py | 2 +- scripts/qapi/common.py | 68 +++++++++++++++++++++------------------- scripts/qapi/doc.py | 4 +-- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index ebf488953d..6d66bf6aa3 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -239,7 +239,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-commands', ' * Schema-defined QAPI/QMP commands', __doc__) - self._regy = QAPIGenCCode() + self._regy = QAPIGenCCode(None) self._visited_ret_types = {} def _begin_user_module(self, name): diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index c327ae5036..8512cac427 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -2158,7 +2158,8 @@ def build_params(arg_type, boxed, extra=None): class QAPIGen(object): - def __init__(self): + def __init__(self, fname): + self.fname = fname self._preamble = '' self._body = '' @@ -2168,18 +2169,17 @@ class QAPIGen(object): def add(self, text): self._body += text - def get_content(self, fname=None): - return (self._top(fname) + self._preamble + self._body - + self._bottom(fname)) + def get_content(self): + return self._top() + self._preamble + self._body + self._bottom() - def _top(self, fname): + def _top(self): return '' - def _bottom(self, fname): + def _bottom(self): return '' - def write(self, output_dir, fname): - pathname = os.path.join(output_dir, fname) + def write(self, output_dir): + pathname = os.path.join(output_dir, self.fname) dir = os.path.dirname(pathname) if dir: try: @@ -2192,7 +2192,7 @@ class QAPIGen(object): f = open(fd, 'r+', encoding='utf-8') else: f = os.fdopen(fd, 'r+') - text = self.get_content(fname) + text = self.get_content() oldtext = f.read(len(text) + 1) if text != oldtext: f.seek(0) @@ -2229,8 +2229,8 @@ def ifcontext(ifcond, *args): class QAPIGenCCode(QAPIGen): - def __init__(self): - QAPIGen.__init__(self) + def __init__(self, fname): + QAPIGen.__init__(self, fname) self._start_if = None def start_if(self, ifcond): @@ -2248,20 +2248,20 @@ class QAPIGenCCode(QAPIGen): self._preamble = _wrap_ifcond(self._start_if[0], self._start_if[2], self._preamble) - def get_content(self, fname=None): + def get_content(self): assert self._start_if is None - return QAPIGen.get_content(self, fname) + return QAPIGen.get_content(self) class QAPIGenC(QAPIGenCCode): - def __init__(self, blurb, pydoc): - QAPIGenCCode.__init__(self) + def __init__(self, fname, blurb, pydoc): + QAPIGenCCode.__init__(self, fname) self._blurb = blurb self._copyright = '\n * '.join(re.findall(r'^Copyright .*', pydoc, re.MULTILINE)) - def _top(self, fname): + def _top(self): return mcgen(''' /* AUTOMATICALLY GENERATED, DO NOT MODIFY */ @@ -2277,28 +2277,28 @@ class QAPIGenC(QAPIGenCCode): ''', blurb=self._blurb, copyright=self._copyright) - def _bottom(self, fname): + def _bottom(self): return mcgen(''' /* Dummy declaration to prevent empty .o file */ char dummy_%(name)s; ''', - name=c_name(fname)) + name=c_name(self.fname)) class QAPIGenH(QAPIGenC): - def _top(self, fname): - return QAPIGenC._top(self, fname) + guardstart(fname) + def _top(self): + return QAPIGenC._top(self) + guardstart(self.fname) - def _bottom(self, fname): - return guardend(fname) + def _bottom(self): + return guardend(self.fname) class QAPIGenDoc(QAPIGen): - def _top(self, fname): - return (QAPIGen._top(self, fname) + def _top(self): + return (QAPIGen._top(self) + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') @@ -2307,12 +2307,14 @@ class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): def __init__(self, prefix, what, blurb, pydoc): self._prefix = prefix self._what = what - self._genc = QAPIGenC(blurb, pydoc) - self._genh = QAPIGenH(blurb, pydoc) + self._genc = QAPIGenC(self._prefix + self._what + '.c', + blurb, pydoc) + self._genh = QAPIGenH(self._prefix + self._what + '.h', + blurb, pydoc) def write(self, output_dir): - self._genc.write(output_dir, self._prefix + self._what + '.c') - self._genh.write(output_dir, self._prefix + self._what + '.h') + self._genc.write(output_dir) + self._genh.write(output_dir) class QAPISchemaModularCVisitor(QAPISchemaVisitor): @@ -2349,8 +2351,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): return ret def _add_module(self, name, blurb): - genc = QAPIGenC(blurb, self._pydoc) - genh = QAPIGenH(blurb, self._pydoc) + basename = self._module_basename(self._what, name) + genc = QAPIGenC(basename + '.c', blurb, self._pydoc) + genh = QAPIGenH(basename + '.h', blurb, self._pydoc) self._module[name] = (genc, genh) self._set_module(name) @@ -2370,10 +2373,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): for name in self._module: if self._is_builtin_module(name) and not opt_builtins: continue - basename = self._module_basename(self._what, name) (genc, genh) = self._module[name] - genc.write(output_dir, basename + '.c') - genh.write(output_dir, basename + '.h') + genc.write(output_dir) + genh.write(output_dir) def _begin_user_module(self, name): pass diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index c03b690161..5c8c136899 100755 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -207,11 +207,11 @@ def texi_entity(doc, what, ifcond, base=None, variants=None, class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): def __init__(self, prefix): self._prefix = prefix - self._gen = qapi.common.QAPIGenDoc() + self._gen = qapi.common.QAPIGenDoc(self._prefix + 'qapi-doc.texi') self.cur_doc = None def write(self, output_dir): - self._gen.write(output_dir, self._prefix + 'qapi-doc.texi') + self._gen.write(output_dir) def visit_enum_type(self, name, info, ifcond, members, prefix): doc = self.cur_doc From patchwork Tue Mar 5 16:52:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13CE8139A for ; Tue, 5 Mar 2019 17:21:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E77002C6A0 for ; Tue, 5 Mar 2019 17:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAB012C6E7; Tue, 5 Mar 2019 17:21:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E91472C6A0 for ; Tue, 5 Mar 2019 17:21:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:46377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1Dke-0001fW-33 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:21:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJJ-00033S-T0 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002fs-KM for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32870) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJH-0002Xe-7g for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4AC7309264C for ; Tue, 5 Mar 2019 16:52:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4252E5D9CC for ; Tue, 5 Mar 2019 16:52:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B373111384DA; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:33 +0100 Message-Id: <20190305165236.8389-5-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 05 Mar 2019 16:52:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/7] qapi: Fix code generation for sub-modules in other directories X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The #include directives to pull in sub-modules use file names relative to the main module. Works only when all modules are in the same directory, or the main module's output directory is in the compiler's include path. Use relative file names instead. The dummy variable we generate to avoid empty .o files has an invalid name for sub-modules in other directories. Fix that. Both messed up in commit 252dc3105fc "qapi: Generate separate .h, .c for each module". Escaped testing because tests/qapi-schema-test.json doesn't cover sub-modules in other directories, only tests/qapi-schema/include-relpath.json does, and we generate and compile C code only for the former, not the latter. Fold the latter into the former. This would have caught the mistakes fixed in this commit. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-5-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/common.py | 33 ++++++++++------ tests/.gitignore | 8 ++++ tests/Makefile.include | 44 +++++++++++++++++++--- tests/qapi-schema/include-relpath-sub.json | 2 - tests/qapi-schema/include-relpath.err | 0 tests/qapi-schema/include-relpath.exit | 1 - tests/qapi-schema/include-relpath.json | 1 - tests/qapi-schema/include-relpath.out | 20 ---------- tests/qapi-schema/include/relpath.json | 1 - tests/qapi-schema/include/sub-module.json | 5 +++ tests/qapi-schema/qapi-schema-test.json | 3 ++ tests/qapi-schema/qapi-schema-test.out | 9 +++++ tests/qapi-schema/sub-sub-module.json | 6 +++ 13 files changed, 91 insertions(+), 42 deletions(-) delete mode 100644 tests/qapi-schema/include-relpath-sub.json delete mode 100644 tests/qapi-schema/include-relpath.err delete mode 100644 tests/qapi-schema/include-relpath.exit delete mode 100644 tests/qapi-schema/include-relpath.json delete mode 100644 tests/qapi-schema/include-relpath.out delete mode 100644 tests/qapi-schema/include/relpath.json create mode 100644 tests/qapi-schema/include/sub-module.json create mode 100644 tests/qapi-schema/sub-sub-module.json diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 8512cac427..f51948364c 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -2017,8 +2017,8 @@ def mcgen(code, **kwds): return cgen(code, **kwds) -def guardname(filename): - return re.sub(r'[^A-Za-z0-9_]', '_', filename).upper() +def c_fname(filename): + return re.sub(r'[^A-Za-z0-9_]', '_', filename) def guardstart(name): @@ -2027,7 +2027,7 @@ def guardstart(name): #define %(name)s ''', - name=guardname(name)) + name=c_fname(name).upper()) def guardend(name): @@ -2035,7 +2035,7 @@ def guardend(name): #endif /* %(name)s */ ''', - name=guardname(name)) + name=c_fname(name).upper()) def gen_if(ifcond): @@ -2281,9 +2281,9 @@ class QAPIGenC(QAPIGenCCode): return mcgen(''' /* Dummy declaration to prevent empty .o file */ -char dummy_%(name)s; +char qapi_dummy_%(name)s; ''', - name=c_name(self.fname)) + name=c_fname(self.fname)) class QAPIGenH(QAPIGenC): @@ -2337,21 +2337,29 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): def _is_builtin_module(name): return not name + def _module_dirname(self, what, name): + if self._is_user_module(name): + return os.path.dirname(name) + return '' + def _module_basename(self, what, name): ret = '' if self._is_builtin_module(name) else self._prefix if self._is_user_module(name): - dirname, basename = os.path.split(name) + basename = os.path.basename(name) ret += what if name != self._main_module: ret += '-' + os.path.splitext(basename)[0] - ret = os.path.join(dirname, ret) else: name = name[2:] if name else 'builtin' ret += re.sub(r'-', '-' + name + '-', what) return ret + def _module_filename(self, what, name): + return os.path.join(self._module_dirname(what, name), + self._module_basename(what, name)) + def _add_module(self, name, blurb): - basename = self._module_basename(self._what, name) + basename = self._module_filename(self._what, name) genc = QAPIGenC(basename + '.c', blurb, self._pydoc) genh = QAPIGenH(basename + '.h', blurb, self._pydoc) self._module[name] = (genc, genh) @@ -2393,8 +2401,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): self._begin_user_module(name) def visit_include(self, name, info): - basename = self._module_basename(self._what, name) + relname = os.path.relpath(self._module_filename(self._what, name), + os.path.dirname(self._genh.fname)) self._genh.preamble_add(mcgen(''' -#include "%(basename)s.h" +#include "%(relname)s.h" ''', - basename=basename)) + relname=relname)) diff --git a/tests/.gitignore b/tests/.gitignore index f2bf85c8c4..c88f8f2537 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -12,9 +12,17 @@ test-* !test-*.c !docker/test-* test-qapi-commands.[ch] +include/test-qapi-commands-sub-module.[ch] +test-qapi-commands-sub-sub-module.[ch] test-qapi-events.[ch] +include/test-qapi-events-sub-module.[ch] +test-qapi-events-sub-sub-module.[ch] test-qapi-types.[ch] +include/test-qapi-types-sub-module.[ch] +test-qapi-types-sub-sub-module.[ch] test-qapi-visit.[ch] +include/test-qapi-visit-sub-module.[ch] +test-qapi-visit-sub-sub-module.[ch] test-qapi-introspect.[ch] *-test qapi-schema/*.test.* diff --git a/tests/Makefile.include b/tests/Makefile.include index 5527581f67..97e1cb90a3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -441,7 +441,6 @@ qapi-schema += include-format-err.json qapi-schema += include-nested-err.json qapi-schema += include-no-file.json qapi-schema += include-non-file.json -qapi-schema += include-relpath.json qapi-schema += include-repetition.json qapi-schema += include-self-cycle.json qapi-schema += include-simple.json @@ -508,8 +507,18 @@ qapi-schema += unknown-expr-key.json check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) -GENERATED_FILES += tests/test-qapi-types.h tests/test-qapi-visit.h \ - tests/test-qapi-commands.h tests/test-qapi-events.h \ +GENERATED_FILES += tests/test-qapi-types.h \ + tests/include/test-qapi-types-sub-module.h \ + tests/test-qapi-types-sub-sub-module.h \ + tests/test-qapi-visit.h \ + tests/include/test-qapi-visit-sub-module.h \ + tests/test-qapi-visit-sub-sub-module.h \ + tests/test-qapi-commands.h \ + tests/include/test-qapi-commands-sub-module.h \ + tests/test-qapi-commands-sub-sub-module.h \ + tests/test-qapi-events.h \ + tests/include/test-qapi-events-sub-module.h \ + tests/test-qapi-events-sub-sub-module.h \ tests/test-qapi-introspect.h test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \ @@ -537,7 +546,12 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests # Deps that are common to various different sets of tests below test-util-obj-y = libqemuutil.a test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) -test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ +test-qapi-obj-y = tests/test-qapi-types.o \ + tests/include/test-qapi-types-sub-module.o \ + tests/test-qapi-types-sub-sub-module.o \ + tests/test-qapi-visit.o \ + tests/include/test-qapi-visit-sub-module.o \ + tests/test-qapi-visit-sub-sub-module.o \ tests/test-qapi-introspect.o \ $(test-qom-obj-y) benchmark-crypto-obj-y = $(authz-obj-y) $(crypto-obj-y) $(test-qom-obj-y) @@ -613,12 +627,32 @@ tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-y) \ $(test-block-obj-y) tests/test-qapi-types.c tests/test-qapi-types.h \ +tests/include/test-qapi-types-sub-module.c \ +tests/include/test-qapi-types-sub-module.h \ +tests/test-qapi-types-sub-sub-module.c \ +tests/test-qapi-types-sub-sub-module.h \ tests/test-qapi-visit.c tests/test-qapi-visit.h \ +tests/include/test-qapi-visit-sub-module.c \ +tests/include/test-qapi-visit-sub-module.h \ +tests/test-qapi-visit-sub-sub-module.c \ +tests/test-qapi-visit-sub-sub-module.h \ tests/test-qapi-commands.h tests/test-qapi-commands.c \ +tests/include/test-qapi-commands-sub-module.h \ +tests/include/test-qapi-commands-sub-module.c \ +tests/test-qapi-commands-sub-sub-module.h \ +tests/test-qapi-commands-sub-sub-module.c \ tests/test-qapi-events.c tests/test-qapi-events.h \ +tests/include/test-qapi-events-sub-module.c \ +tests/include/test-qapi-events-sub-module.h \ +tests/test-qapi-events-sub-sub-module.c \ +tests/test-qapi-events-sub-sub-module.h \ tests/test-qapi-introspect.c tests/test-qapi-introspect.h: \ tests/test-qapi-gen-timestamp ; -tests/test-qapi-gen-timestamp: $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(qapi-py) +tests/test-qapi-gen-timestamp: \ + $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json \ + $(SRC_PATH)/tests/qapi-schema/include/sub-module.json \ + $(SRC_PATH)/tests/qapi-schema/sub-sub-module.json \ + $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ -o tests -p "test-" $<, \ "GEN","$(@:%-timestamp=%)") diff --git a/tests/qapi-schema/include-relpath-sub.json b/tests/qapi-schema/include-relpath-sub.json deleted file mode 100644 index 4bd4af4162..0000000000 --- a/tests/qapi-schema/include-relpath-sub.json +++ /dev/null @@ -1,2 +0,0 @@ -{ 'enum': 'Status', - 'data': [ 'good', 'bad', 'ugly' ] } diff --git a/tests/qapi-schema/include-relpath.err b/tests/qapi-schema/include-relpath.err deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/include-relpath.exit b/tests/qapi-schema/include-relpath.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/include-relpath.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/include-relpath.json b/tests/qapi-schema/include-relpath.json deleted file mode 100644 index 05018f3908..0000000000 --- a/tests/qapi-schema/include-relpath.json +++ /dev/null @@ -1 +0,0 @@ -{ 'include': 'include/relpath.json' } diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/include-relpath.out deleted file mode 100644 index cf8636b78f..0000000000 --- a/tests/qapi-schema/include-relpath.out +++ /dev/null @@ -1,20 +0,0 @@ -module None -object q_empty -enum QType - prefix QTYPE - member none - member qnull - member qnum - member qstring - member qdict - member qlist - member qbool -module include-relpath.json -include include/relpath.json -module include/relpath.json -include include-relpath-sub.json -module include-relpath-sub.json -enum Status - member good - member bad - member ugly diff --git a/tests/qapi-schema/include/relpath.json b/tests/qapi-schema/include/relpath.json deleted file mode 100644 index 45dee24704..0000000000 --- a/tests/qapi-schema/include/relpath.json +++ /dev/null @@ -1 +0,0 @@ -{ 'include': '../include-relpath-sub.json' } diff --git a/tests/qapi-schema/include/sub-module.json b/tests/qapi-schema/include/sub-module.json new file mode 100644 index 0000000000..f2bdbd3990 --- /dev/null +++ b/tests/qapi-schema/include/sub-module.json @@ -0,0 +1,5 @@ +# *-*- Mode: Python -*-* + +# Sub-module of ../qapi-schema-test.json + +{ 'include': '../sub-sub-module.json' } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index 70612f394e..1f130a0491 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -130,6 +130,9 @@ 'sizes': ['size'], 'any': ['any'] } } +# for testing sub-modules +{ 'include': 'include/sub-module.json' } + # testing commands { 'command': 'user_def_cmd', 'data': {} } { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index 97f671ca5f..baba4c8384 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -176,6 +176,15 @@ object UserDefNativeListUnion case string: q_obj_strList-wrapper case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper +include include/sub-module.json +module include/sub-module.json +include sub-sub-module.json +module sub-sub-module.json +enum Status + member good + member bad + member ugly +module qapi-schema-test.json command user_def_cmd None -> None gen=True success_response=True boxed=False oob=False preconfig=False object q_obj_user_def_cmd1-arg diff --git a/tests/qapi-schema/sub-sub-module.json b/tests/qapi-schema/sub-sub-module.json new file mode 100644 index 0000000000..524ef9b83f --- /dev/null +++ b/tests/qapi-schema/sub-sub-module.json @@ -0,0 +1,6 @@ +# *-*- Mode: Python -*-* + +# Sub-module of sub-module include/sub-module.json of qapi-schema-test.json + +{ 'enum': 'Status', + 'data': [ 'good', 'bad', 'ugly' ] } From patchwork Tue Mar 5 16:52:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC8B8139A for ; Tue, 5 Mar 2019 17:16:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 991C42B8D0 for ; Tue, 5 Mar 2019 17:16:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D7E22BA04; Tue, 5 Mar 2019 17:16:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADEA02B8D0 for ; Tue, 5 Mar 2019 17:16:26 +0000 (UTC) Received: from localhost ([127.0.0.1]:46197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1Dg1-0005ZC-Nn for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:16:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJL-00036w-F1 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:53:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002fT-Ex for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJG-0002WZ-Ud for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9EFFE59463 for ; Tue, 5 Mar 2019 16:52:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0A751001E79 for ; Tue, 5 Mar 2019 16:52:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B79551133040; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:34 +0100 Message-Id: <20190305165236.8389-6-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Mar 2019 16:52:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/7] tests: Rename UserDefNativeListUnion to UserDefListUnion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The lists in UserDefNativeListUnion aren't "native", they're lists of built-in types. The next commit will add a list of a user-defined type. Drop "Native", and adjust the tests using the type. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-6-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/qapi-schema/qapi-schema-test.json | 6 +- tests/qapi-schema/qapi-schema-test.out | 8 +- tests/test-clone-visitor.c | 16 +- tests/test-qmp-cmds.c | 2 +- tests/test-qobject-input-visitor.c | 196 ++++++++++++------------ tests/test-qobject-output-visitor.c | 190 +++++++++++------------ 6 files changed, 209 insertions(+), 209 deletions(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index 1f130a0491..908f718027 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -113,8 +113,8 @@ # for testing use of 'str' within alternates { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } } -# for testing native lists -{ 'union': 'UserDefNativeListUnion', +# for testing lists +{ 'union': 'UserDefListUnion', 'data': { 'integer': ['int'], 's8': ['int8'], 's16': ['int16'], @@ -147,7 +147,7 @@ 'returns': 'int' } { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } -{ 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': true } +{ 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true } # Smoke test on out-of-band and allow-preconfig-test { 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index baba4c8384..cecf270ec3 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -144,7 +144,7 @@ object q_obj_sizeList-wrapper member data: sizeList optional=False object q_obj_anyList-wrapper member data: anyList optional=False -enum UserDefNativeListUnionKind +enum UserDefListUnionKind member integer member s8 member s16 @@ -159,8 +159,8 @@ enum UserDefNativeListUnionKind member string member sizes member any -object UserDefNativeListUnion - member type: UserDefNativeListUnionKind optional=False +object UserDefListUnion + member type: UserDefListUnionKind optional=False tag type case integer: q_obj_intList-wrapper case s8: q_obj_int8List-wrapper @@ -209,7 +209,7 @@ command guest-sync q_obj_guest-sync-arg -> any gen=True success_response=True boxed=False oob=False preconfig=False command boxed-struct UserDefZero -> None gen=True success_response=True boxed=True oob=False preconfig=False -command boxed-union UserDefNativeListUnion -> None +command boxed-union UserDefListUnion -> None gen=True success_response=True boxed=True oob=False preconfig=False command test-flags-command None -> None gen=True success_response=True boxed=False oob=True preconfig=True diff --git a/tests/test-clone-visitor.c b/tests/test-clone-visitor.c index 9aeaf86a07..5e1e8b2f5e 100644 --- a/tests/test-clone-visitor.c +++ b/tests/test-clone-visitor.c @@ -63,7 +63,7 @@ static void test_clone_alternate(void) qapi_free_AltEnumBool(s_dst); } -static void test_clone_native_list(void) +static void test_clone_list_union(void) { uint8List *src, *dst; uint8List *tmp = NULL; @@ -102,18 +102,18 @@ static void test_clone_empty(void) static void test_clone_complex1(void) { - UserDefNativeListUnion *src, *dst; + UserDefListUnion *src, *dst; - src = g_new0(UserDefNativeListUnion, 1); - src->type = USER_DEF_NATIVE_LIST_UNION_KIND_STRING; + src = g_new0(UserDefListUnion, 1); + src->type = USER_DEF_LIST_UNION_KIND_STRING; - dst = QAPI_CLONE(UserDefNativeListUnion, src); + dst = QAPI_CLONE(UserDefListUnion, src); g_assert(dst); g_assert_cmpint(dst->type, ==, src->type); g_assert(!dst->u.string.data); - qapi_free_UserDefNativeListUnion(src); - qapi_free_UserDefNativeListUnion(dst); + qapi_free_UserDefListUnion(src); + qapi_free_UserDefListUnion(dst); } static void test_clone_complex2(void) @@ -192,7 +192,7 @@ int main(int argc, char **argv) g_test_add_func("/visitor/clone/struct", test_clone_struct); g_test_add_func("/visitor/clone/alternate", test_clone_alternate); - g_test_add_func("/visitor/clone/native_list", test_clone_native_list); + g_test_add_func("/visitor/clone/list_union", test_clone_list_union); g_test_add_func("/visitor/clone/empty", test_clone_empty); g_test_add_func("/visitor/clone/complex1", test_clone_complex1); g_test_add_func("/visitor/clone/complex2", test_clone_complex2); diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 481cb069ca..630b1b9bac 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -87,7 +87,7 @@ void qmp_boxed_struct(UserDefZero *arg, Error **errp) { } -void qmp_boxed_union(UserDefNativeListUnion *arg, Error **errp) +void qmp_boxed_union(UserDefListUnion *arg, Error **errp) { } diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index 609334adf6..6bacabf063 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -686,11 +686,11 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, qapi_free_AltEnumInt(asi); } -static void test_native_list_integer_helper(TestInputVisitorData *data, - const void *unused, - UserDefNativeListUnionKind kind) +static void test_list_union_integer_helper(TestInputVisitorData *data, + const void *unused, + UserDefListUnionKind kind) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; Visitor *v; GString *gstr_list = g_string_new(""); GString *gstr_union = g_string_new(""); @@ -703,16 +703,16 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, } } g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }", - UserDefNativeListUnionKind_str(kind), + UserDefListUnionKind_str(kind), gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); g_assert_cmpint(cvalue->type, ==, kind); switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { + case USER_DEF_LIST_UNION_KIND_INTEGER: { intList *elem = NULL; for (i = 0, elem = cvalue->u.integer.data; elem; elem = elem->next, i++) { @@ -720,56 +720,56 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: { + case USER_DEF_LIST_UNION_KIND_S8: { int8List *elem = NULL; for (i = 0, elem = cvalue->u.s8.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: { + case USER_DEF_LIST_UNION_KIND_S16: { int16List *elem = NULL; for (i = 0, elem = cvalue->u.s16.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: { + case USER_DEF_LIST_UNION_KIND_S32: { int32List *elem = NULL; for (i = 0, elem = cvalue->u.s32.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: { + case USER_DEF_LIST_UNION_KIND_S64: { int64List *elem = NULL; for (i = 0, elem = cvalue->u.s64.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: { + case USER_DEF_LIST_UNION_KIND_U8: { uint8List *elem = NULL; for (i = 0, elem = cvalue->u.u8.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: { + case USER_DEF_LIST_UNION_KIND_U16: { uint16List *elem = NULL; for (i = 0, elem = cvalue->u.u16.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: { + case USER_DEF_LIST_UNION_KIND_U32: { uint32List *elem = NULL; for (i = 0, elem = cvalue->u.u32.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: { + case USER_DEF_LIST_UNION_KIND_U64: { uint64List *elem = NULL; for (i = 0, elem = cvalue->u.u64.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); @@ -782,76 +782,76 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } -static void test_visitor_in_native_list_int(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_INTEGER); } -static void test_visitor_in_native_list_int8(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int8(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S8); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S8); } -static void test_visitor_in_native_list_int16(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int16(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S16); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S16); } -static void test_visitor_in_native_list_int32(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int32(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S32); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S32); } -static void test_visitor_in_native_list_int64(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int64(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S64); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S64); } -static void test_visitor_in_native_list_uint8(TestInputVisitorData *data, +static void test_visitor_in_list_union_uint8(TestInputVisitorData *data, const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U8); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U8); } -static void test_visitor_in_native_list_uint16(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_uint16(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U16); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U16); } -static void test_visitor_in_native_list_uint32(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_uint32(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U32); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U32); } -static void test_visitor_in_native_list_uint64(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_uint64(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U64); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U64); } -static void test_visitor_in_native_list_bool(TestInputVisitorData *data, +static void test_visitor_in_list_union_bool(TestInputVisitorData *data, const void *unused) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; boolList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); @@ -869,9 +869,9 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + g_assert_cmpint(cvalue->type, ==, USER_DEF_LIST_UNION_KIND_BOOLEAN); for (i = 0, elem = cvalue->u.boolean.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); @@ -879,13 +879,13 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } -static void test_visitor_in_native_list_string(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_string(TestInputVisitorData *data, + const void *unused) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; strList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); @@ -902,9 +902,9 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + g_assert_cmpint(cvalue->type, ==, USER_DEF_LIST_UNION_KIND_STRING); for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) { gchar str[8]; @@ -914,15 +914,15 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } #define DOUBLE_STR_MAX 16 -static void test_visitor_in_native_list_number(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_number(TestInputVisitorData *data, + const void *unused) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; numberList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); @@ -939,9 +939,9 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + g_assert_cmpint(cvalue->type, ==, USER_DEF_LIST_UNION_KIND_NUMBER); for (i = 0, elem = cvalue->u.number.data; elem; elem = elem->next, i++) { GString *double_expected = g_string_new(""); @@ -957,7 +957,7 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } static void input_visitor_test_add(const char *testpath, @@ -1192,17 +1192,17 @@ static void test_visitor_in_fail_list_nested(TestInputVisitorData *data, visit_end_list(v, NULL); } -static void test_visitor_in_fail_union_native_list(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_fail_union_list(TestInputVisitorData *data, + const void *unused) { - UserDefNativeListUnion *tmp = NULL; + UserDefListUnion *tmp = NULL; Error *err = NULL; Visitor *v; v = visitor_input_test_init(data, "{ 'type': 'integer', 'data' : [ 'string' ] }"); - visit_type_UserDefNativeListUnion(v, NULL, &tmp, &err); + visit_type_UserDefListUnion(v, NULL, &tmp, &err); error_free_or_abort(&err); g_assert(!tmp); } @@ -1335,30 +1335,30 @@ int main(int argc, char **argv) NULL, test_visitor_in_wrong_type); input_visitor_test_add("/visitor/input/alternate-number", NULL, test_visitor_in_alternate_number); - input_visitor_test_add("/visitor/input/native_list/int", - NULL, test_visitor_in_native_list_int); - input_visitor_test_add("/visitor/input/native_list/int8", - NULL, test_visitor_in_native_list_int8); - input_visitor_test_add("/visitor/input/native_list/int16", - NULL, test_visitor_in_native_list_int16); - input_visitor_test_add("/visitor/input/native_list/int32", - NULL, test_visitor_in_native_list_int32); - input_visitor_test_add("/visitor/input/native_list/int64", - NULL, test_visitor_in_native_list_int64); - input_visitor_test_add("/visitor/input/native_list/uint8", - NULL, test_visitor_in_native_list_uint8); - input_visitor_test_add("/visitor/input/native_list/uint16", - NULL, test_visitor_in_native_list_uint16); - input_visitor_test_add("/visitor/input/native_list/uint32", - NULL, test_visitor_in_native_list_uint32); - input_visitor_test_add("/visitor/input/native_list/uint64", - NULL, test_visitor_in_native_list_uint64); - input_visitor_test_add("/visitor/input/native_list/bool", - NULL, test_visitor_in_native_list_bool); - input_visitor_test_add("/visitor/input/native_list/str", - NULL, test_visitor_in_native_list_string); - input_visitor_test_add("/visitor/input/native_list/number", - NULL, test_visitor_in_native_list_number); + input_visitor_test_add("/visitor/input/list_union/int", + NULL, test_visitor_in_list_union_int); + input_visitor_test_add("/visitor/input/list_union/int8", + NULL, test_visitor_in_list_union_int8); + input_visitor_test_add("/visitor/input/list_union/int16", + NULL, test_visitor_in_list_union_int16); + input_visitor_test_add("/visitor/input/list_union/int32", + NULL, test_visitor_in_list_union_int32); + input_visitor_test_add("/visitor/input/list_union/int64", + NULL, test_visitor_in_list_union_int64); + input_visitor_test_add("/visitor/input/list_union/uint8", + NULL, test_visitor_in_list_union_uint8); + input_visitor_test_add("/visitor/input/list_union/uint16", + NULL, test_visitor_in_list_union_uint16); + input_visitor_test_add("/visitor/input/list_union/uint32", + NULL, test_visitor_in_list_union_uint32); + input_visitor_test_add("/visitor/input/list_union/uint64", + NULL, test_visitor_in_list_union_uint64); + input_visitor_test_add("/visitor/input/list_union/bool", + NULL, test_visitor_in_list_union_bool); + input_visitor_test_add("/visitor/input/list_union/str", + NULL, test_visitor_in_list_union_string); + input_visitor_test_add("/visitor/input/list_union/number", + NULL, test_visitor_in_list_union_number); input_visitor_test_add("/visitor/input/fail/struct", NULL, test_visitor_in_fail_struct); input_visitor_test_add("/visitor/input/fail/struct-nested", @@ -1377,8 +1377,8 @@ int main(int argc, char **argv) NULL, test_visitor_in_fail_union_flat_no_discrim); input_visitor_test_add("/visitor/input/fail/alternate", NULL, test_visitor_in_fail_alternate); - input_visitor_test_add("/visitor/input/fail/union-native-list", - NULL, test_visitor_in_fail_union_native_list); + input_visitor_test_add("/visitor/input/fail/union-list", + NULL, test_visitor_in_fail_union_list); input_visitor_test_add("/visitor/input/qapi-introspect", NULL, test_visitor_in_qmp_introspect); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c index be635854b4..3e993e5ba8 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -474,11 +474,11 @@ static void test_visitor_out_null(TestOutputVisitorData *data, g_assert(qobject_type(nil) == QTYPE_QNULL); } -static void init_native_list(UserDefNativeListUnion *cvalue) +static void init_list_union(UserDefListUnion *cvalue) { int i; switch (cvalue->type) { - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { + case USER_DEF_LIST_UNION_KIND_INTEGER: { intList **list = &cvalue->u.integer.data; for (i = 0; i < 32; i++) { *list = g_new0(intList, 1); @@ -488,7 +488,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: { + case USER_DEF_LIST_UNION_KIND_S8: { int8List **list = &cvalue->u.s8.data; for (i = 0; i < 32; i++) { *list = g_new0(int8List, 1); @@ -498,7 +498,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: { + case USER_DEF_LIST_UNION_KIND_S16: { int16List **list = &cvalue->u.s16.data; for (i = 0; i < 32; i++) { *list = g_new0(int16List, 1); @@ -508,7 +508,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: { + case USER_DEF_LIST_UNION_KIND_S32: { int32List **list = &cvalue->u.s32.data; for (i = 0; i < 32; i++) { *list = g_new0(int32List, 1); @@ -518,7 +518,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: { + case USER_DEF_LIST_UNION_KIND_S64: { int64List **list = &cvalue->u.s64.data; for (i = 0; i < 32; i++) { *list = g_new0(int64List, 1); @@ -528,7 +528,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: { + case USER_DEF_LIST_UNION_KIND_U8: { uint8List **list = &cvalue->u.u8.data; for (i = 0; i < 32; i++) { *list = g_new0(uint8List, 1); @@ -538,7 +538,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: { + case USER_DEF_LIST_UNION_KIND_U16: { uint16List **list = &cvalue->u.u16.data; for (i = 0; i < 32; i++) { *list = g_new0(uint16List, 1); @@ -548,7 +548,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: { + case USER_DEF_LIST_UNION_KIND_U32: { uint32List **list = &cvalue->u.u32.data; for (i = 0; i < 32; i++) { *list = g_new0(uint32List, 1); @@ -558,7 +558,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: { + case USER_DEF_LIST_UNION_KIND_U64: { uint64List **list = &cvalue->u.u64.data; for (i = 0; i < 32; i++) { *list = g_new0(uint64List, 1); @@ -568,7 +568,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: { + case USER_DEF_LIST_UNION_KIND_BOOLEAN: { boolList **list = &cvalue->u.boolean.data; for (i = 0; i < 32; i++) { *list = g_new0(boolList, 1); @@ -578,7 +578,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: { + case USER_DEF_LIST_UNION_KIND_STRING: { strList **list = &cvalue->u.string.data; for (i = 0; i < 32; i++) { *list = g_new0(strList, 1); @@ -588,7 +588,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: { + case USER_DEF_LIST_UNION_KIND_NUMBER: { numberList **list = &cvalue->u.number.data; for (i = 0; i < 32; i++) { *list = g_new0(numberList, 1); @@ -603,8 +603,8 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } } -static void check_native_list(QObject *qobj, - UserDefNativeListUnionKind kind) +static void check_list_union(QObject *qobj, + UserDefListUnionKind kind) { QDict *qdict; QList *qlist; @@ -616,10 +616,10 @@ static void check_native_list(QObject *qobj, qlist = qlist_copy(qobject_to(QList, qdict_get(qdict, "data"))); switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: + case USER_DEF_LIST_UNION_KIND_U8: + case USER_DEF_LIST_UNION_KIND_U16: + case USER_DEF_LIST_UNION_KIND_U32: + case USER_DEF_LIST_UNION_KIND_U64: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; @@ -634,16 +634,16 @@ static void check_native_list(QObject *qobj, } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: + case USER_DEF_LIST_UNION_KIND_S8: + case USER_DEF_LIST_UNION_KIND_S16: + case USER_DEF_LIST_UNION_KIND_S32: + case USER_DEF_LIST_UNION_KIND_S64: /* * All integer elements in JSON arrays get stored into QNums * when we convert to QObjects, so we can check them all in * the same fashion, so simply fall through here. */ - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: + case USER_DEF_LIST_UNION_KIND_INTEGER: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; @@ -657,7 +657,7 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: + case USER_DEF_LIST_UNION_KIND_BOOLEAN: for (i = 0; i < 32; i++) { QObject *tmp; QBool *qvalue; @@ -668,7 +668,7 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: + case USER_DEF_LIST_UNION_KIND_STRING: for (i = 0; i < 32; i++) { QObject *tmp; QString *qvalue; @@ -681,7 +681,7 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: + case USER_DEF_LIST_UNION_KIND_NUMBER: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; @@ -706,93 +706,93 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist); } -static void test_native_list(TestOutputVisitorData *data, - const void *unused, - UserDefNativeListUnionKind kind) +static void test_list_union(TestOutputVisitorData *data, + const void *unused, + UserDefListUnionKind kind) { - UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1); + UserDefListUnion *cvalue = g_new0(UserDefListUnion, 1); QObject *obj; cvalue->type = kind; - init_native_list(cvalue); + init_list_union(cvalue); - visit_type_UserDefNativeListUnion(data->ov, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(data->ov, NULL, &cvalue, &error_abort); obj = visitor_get(data); - check_native_list(obj, cvalue->type); - qapi_free_UserDefNativeListUnion(cvalue); + check_list_union(obj, cvalue->type); + qapi_free_UserDefListUnion(cvalue); } -static void test_visitor_out_native_list_int(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_INTEGER); } -static void test_visitor_out_native_list_int8(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int8(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S8); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S8); } -static void test_visitor_out_native_list_int16(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int16(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S16); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S16); } -static void test_visitor_out_native_list_int32(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int32(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S32); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S32); } -static void test_visitor_out_native_list_int64(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int64(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S64); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S64); } -static void test_visitor_out_native_list_uint8(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint8(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U8); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U8); } -static void test_visitor_out_native_list_uint16(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint16(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U16); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U16); } -static void test_visitor_out_native_list_uint32(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint32(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U32); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U32); } -static void test_visitor_out_native_list_uint64(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint64(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U64); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U64); } -static void test_visitor_out_native_list_bool(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_bool(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_BOOLEAN); } -static void test_visitor_out_native_list_str(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_str(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_STRING); } -static void test_visitor_out_native_list_number(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_number(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_NUMBER); } static void output_visitor_test_add(const char *testpath, @@ -841,42 +841,42 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_alternate); output_visitor_test_add("/visitor/output/null", &out_visitor_data, test_visitor_out_null); - output_visitor_test_add("/visitor/output/native_list/int", + output_visitor_test_add("/visitor/output/list_union/int", &out_visitor_data, - test_visitor_out_native_list_int); - output_visitor_test_add("/visitor/output/native_list/int8", + test_visitor_out_list_union_int); + output_visitor_test_add("/visitor/output/list_union/int8", &out_visitor_data, - test_visitor_out_native_list_int8); - output_visitor_test_add("/visitor/output/native_list/int16", + test_visitor_out_list_union_int8); + output_visitor_test_add("/visitor/output/list_union/int16", &out_visitor_data, - test_visitor_out_native_list_int16); - output_visitor_test_add("/visitor/output/native_list/int32", + test_visitor_out_list_union_int16); + output_visitor_test_add("/visitor/output/list_union/int32", &out_visitor_data, - test_visitor_out_native_list_int32); - output_visitor_test_add("/visitor/output/native_list/int64", + test_visitor_out_list_union_int32); + output_visitor_test_add("/visitor/output/list_union/int64", &out_visitor_data, - test_visitor_out_native_list_int64); - output_visitor_test_add("/visitor/output/native_list/uint8", + test_visitor_out_list_union_int64); + output_visitor_test_add("/visitor/output/list_union/uint8", &out_visitor_data, - test_visitor_out_native_list_uint8); - output_visitor_test_add("/visitor/output/native_list/uint16", + test_visitor_out_list_union_uint8); + output_visitor_test_add("/visitor/output/list_union/uint16", &out_visitor_data, - test_visitor_out_native_list_uint16); - output_visitor_test_add("/visitor/output/native_list/uint32", + test_visitor_out_list_union_uint16); + output_visitor_test_add("/visitor/output/list_union/uint32", &out_visitor_data, - test_visitor_out_native_list_uint32); - output_visitor_test_add("/visitor/output/native_list/uint64", + test_visitor_out_list_union_uint32); + output_visitor_test_add("/visitor/output/list_union/uint64", &out_visitor_data, - test_visitor_out_native_list_uint64); - output_visitor_test_add("/visitor/output/native_list/bool", + test_visitor_out_list_union_uint64); + output_visitor_test_add("/visitor/output/list_union/bool", &out_visitor_data, - test_visitor_out_native_list_bool); - output_visitor_test_add("/visitor/output/native_list/string", + test_visitor_out_list_union_bool); + output_visitor_test_add("/visitor/output/list_union/string", &out_visitor_data, - test_visitor_out_native_list_str); - output_visitor_test_add("/visitor/output/native_list/number", + test_visitor_out_list_union_str); + output_visitor_test_add("/visitor/output/list_union/number", &out_visitor_data, - test_visitor_out_native_list_number); + test_visitor_out_list_union_number); g_test_run(); From patchwork Tue Mar 5 16:52:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36ED4139A for ; Tue, 5 Mar 2019 17:12:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17F162C520 for ; Tue, 5 Mar 2019 17:12:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C85E2C8F0; Tue, 5 Mar 2019 17:12:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB6EE2C520 for ; Tue, 5 Mar 2019 17:12:52 +0000 (UTC) Received: from localhost ([127.0.0.1]:46107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1Dca-0002Ja-0x for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:12:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJI-00031v-Bf for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002fK-CI for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJH-0002Wp-1l for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F31E7309264D for ; Tue, 5 Mar 2019 16:52:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1BEE5D732 for ; Tue, 5 Mar 2019 16:52:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BB0B51133056; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:35 +0100 Message-Id: <20190305165236.8389-7-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 05 Mar 2019 16:52:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/7] tests/qapi-schema: Cover forward reference to sub-module X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The forward reference from the main module to the sub-module works fine, except for an issue visible in qapi-schema-test.out: the array type wrapped around the forward reference ends up in the main module, not the sub-module. The next commit will explain why that's bad, and fix it. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-7-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/qapi-schema/qapi-schema-test.json | 3 ++- tests/qapi-schema/qapi-schema-test.out | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index 908f718027..0952c68734 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -128,7 +128,8 @@ 'boolean': ['bool'], 'string': ['str'], 'sizes': ['size'], - 'any': ['any'] } } + 'any': ['any'], + 'user': ['Status'] } } # intentional forward ref. to sub-module # for testing sub-modules { 'include': 'include/sub-module.json' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index cecf270ec3..38c1de70d8 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -144,6 +144,9 @@ object q_obj_sizeList-wrapper member data: sizeList optional=False object q_obj_anyList-wrapper member data: anyList optional=False +array StatusList Status +object q_obj_StatusList-wrapper + member data: StatusList optional=False enum UserDefListUnionKind member integer member s8 @@ -159,6 +162,7 @@ enum UserDefListUnionKind member string member sizes member any + member user object UserDefListUnion member type: UserDefListUnionKind optional=False tag type @@ -176,6 +180,7 @@ object UserDefListUnion case string: q_obj_strList-wrapper case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper + case user: q_obj_StatusList-wrapper include include/sub-module.json module include/sub-module.json include sub-sub-module.json From patchwork Tue Mar 5 16:52:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10839729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CE0414DE for ; Tue, 5 Mar 2019 17:10:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 087122C53C for ; Tue, 5 Mar 2019 17:10:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF3D2C54F; Tue, 5 Mar 2019 17:10:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6FD9D2C53C for ; Tue, 5 Mar 2019 17:10:03 +0000 (UTC) Received: from localhost ([127.0.0.1]:46047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DZq-0000vF-Ar for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Mar 2019 12:10:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJJ-00032X-3T for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002fg-HQ for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJH-0002Yh-2d for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A3E0308338F for ; Tue, 5 Mar 2019 16:52:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4E8860A9A for ; Tue, 5 Mar 2019 16:52:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BE73D113305C; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:36 +0100 Message-Id: <20190305165236.8389-8-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 05 Mar 2019 16:52:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] qapi: Fix array first used in a different module X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We generally put implicitly defined types in whatever module triggered their definition. This is wrong for array types, as the included test case demonstrates. Let's have a closer look at it. Type 'Status' is defined sub-sub-module.json. Array type ['Status'] occurs in main module qapi-schema-test.json and in include/sub-module.json. The main module's use is first, so the array type gets put into the main module. The generated C headers define StatusList in qapi-types.h. But include/qapi-types-sub-module.h uses it without including qapi-types.h. Oops. To fix that, put the array type into its element type's module. Now StatusList gets generated into qapi-types-sub-module.h, which all its users include. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-8-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/common.py | 9 +++++---- tests/qapi-schema/include/sub-module.json | 2 ++ tests/qapi-schema/qapi-schema-test.out | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index f51948364c..f07869ec73 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1089,6 +1089,9 @@ class QAPISchemaEntity(object): self.ifcond = typ.ifcond else: self.ifcond = listify_cond(self._ifcond) + if self.info: + self.module = os.path.relpath(self.info['file'], + os.path.dirname(schema.fname)) def is_implicit(self): return not self.info @@ -1262,6 +1265,7 @@ class QAPISchemaArrayType(QAPISchemaType): self.element_type = schema.lookup_type(self._element_type_name) assert self.element_type self.element_type.check(schema) + self.module = self.element_type.module self.ifcond = self.element_type.ifcond def is_implicit(self): @@ -1603,7 +1607,7 @@ class QAPISchemaEvent(QAPISchemaEntity): class QAPISchema(object): def __init__(self, fname): - self._fname = fname + self.fname = fname if sys.version_info[0] >= 3: f = open(fname, 'r', encoding='utf-8') else: @@ -1626,9 +1630,6 @@ class QAPISchema(object): self._entity_list.append(ent) if ent.name is not None: self._entity_dict[ent.name] = ent - if ent.info: - ent.module = os.path.relpath(ent.info['file'], - os.path.dirname(self._fname)) def lookup_entity(self, name, typ=None): ent = self._entity_dict.get(name) diff --git a/tests/qapi-schema/include/sub-module.json b/tests/qapi-schema/include/sub-module.json index f2bdbd3990..afdb267228 100644 --- a/tests/qapi-schema/include/sub-module.json +++ b/tests/qapi-schema/include/sub-module.json @@ -3,3 +3,5 @@ # Sub-module of ../qapi-schema-test.json { 'include': '../sub-sub-module.json' } + +{ 'struct': 'SecondArrayRef', 'data': { 's': ['Status'] } } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index 38c1de70d8..77fb1e1aa9 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -144,7 +144,9 @@ object q_obj_sizeList-wrapper member data: sizeList optional=False object q_obj_anyList-wrapper member data: anyList optional=False +module sub-sub-module.json array StatusList Status +module qapi-schema-test.json object q_obj_StatusList-wrapper member data: StatusList optional=False enum UserDefListUnionKind @@ -189,6 +191,9 @@ enum Status member good member bad member ugly +module include/sub-module.json +object SecondArrayRef + member s: StatusList optional=False module qapi-schema-test.json command user_def_cmd None -> None gen=True success_response=True boxed=False oob=False preconfig=False