From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552776; cv=none; d=zohomail.com; s=zohoarc; b=UtND43xeRPQi2RSsFCTiYv2DGEuoJ8UvrGFhD10dAfZuyH0Q7UMuwyr6WxCwsxYeUr2761s0XGSGOozgrR4YTygoRyLc8hd7tkrXYP2PQyi0Dr7bh2DgubZcMCL2Rvrkl39luCVqXEFujbhNbGgNCuutF7IIY5yOnn9K8RTdBVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552776; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kQZU01g1Nn+EWz1jyCuqnV8zhyq4sTrjzvzWP5+3XHY=; b=AKXybfk0nQcJnlw0J2nNiJunE47W+5SIMulSbcbsAKNracZo82dKhQ/zuO54egQ/RuFsMp6Jw5/Z7tbKnVFEPa1QXYFaWaisLjZ5sRRPOtxdaE+VlklZEfIkfSwAFRlOo61N8Lmn3jWoECLlGLr5hjHGDTfIhdD2WCsvHQ6lwkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552776610322.17224946728186; Fri, 24 Sep 2021 23:52:56 -0700 (PDT) Received: from localhost ([::1]:57512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1YN-00036q-A3 for importer@patchew.org; Sat, 25 Sep 2021 02:52:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU18C-0007js-45 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30887) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007Lo-63 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-qRpJ4ubVM2uJxj9cOr3NLw-1; Sat, 25 Sep 2021 02:25:38 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B60B36302; Sat, 25 Sep 2021 06:25:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 843541002388; Sat, 25 Sep 2021 06:25:26 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1C07F113861E; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kQZU01g1Nn+EWz1jyCuqnV8zhyq4sTrjzvzWP5+3XHY=; b=ZZ7DAqT6Ee0I5eJ+bb1v/tjlgPPk1711GThmIU6olfjXf7hKvKqvVSa2eh4JWh82Y3UDzg WkxiXGLDYN0WAnfGxnf64lVinrU0HTbFuOXT+35Sgo13o0PQv2t+p1oT1Xsjp2Y3Qmcy7e FdfqKG7qbeDxUlppI+TqDj/BqqUJjbE= X-MC-Unique: qRpJ4ubVM2uJxj9cOr3NLw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 01/25] qapi: Tidy up unusual line breaks Date: Sat, 25 Sep 2021 08:25:01 +0200 Message-Id: <20210925062525.988405-2-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552778600100001 Break lines between members instead of within members. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210917143134.412106-2-armbru@redhat.com> --- docs/devel/qapi-code-gen.rst | 12 +++++------ tests/qapi-schema/doc-good.json | 4 ++-- tests/qapi-schema/enum-if-invalid.json | 4 ++-- tests/qapi-schema/qapi-schema-test.json | 28 ++++++++++++------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index ced7a5ffe1..b154eae82e 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -859,9 +859,9 @@ longhand form of MEMBER. Example: a struct type with unconditional member 'foo' and conditional member 'bar' :: =20 - { 'struct': 'IfStruct', 'data': - { 'foo': 'int', - 'bar': { 'type': 'int', 'if': 'IFCOND'} } } + { 'struct': 'IfStruct', + 'data': { 'foo': 'int', + 'bar': { 'type': 'int', 'if': 'IFCOND'} } } =20 A union's discriminator may not be conditional. =20 @@ -871,9 +871,9 @@ the longhand form of ENUM-VALUE_. Example: an enum type with unconditional value 'foo' and conditional value 'bar' :: =20 - { 'enum': 'IfEnum', 'data': - [ 'foo', - { 'name' : 'bar', 'if': 'IFCOND' } ] } + { 'enum': 'IfEnum', + 'data': [ 'foo', + { 'name' : 'bar', 'if': 'IFCOND' } ] } =20 Likewise, features can be conditional. This requires the longhand form of FEATURE_. diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index e0027e4cf6..cbf5c56c4b 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -60,8 +60,8 @@ # # @two is undocumented ## -{ 'enum': 'Enum', 'data': - [ { 'name': 'one', 'if': 'IFONE' }, 'two' ], +{ 'enum': 'Enum', + 'data': [ { 'name': 'one', 'if': 'IFONE' }, 'two' ], 'features': [ 'enum-feat' ], 'if': 'IFCOND' } =20 diff --git a/tests/qapi-schema/enum-if-invalid.json b/tests/qapi-schema/enu= m-if-invalid.json index 60bd0ef1d7..6bd20041f3 100644 --- a/tests/qapi-schema/enum-if-invalid.json +++ b/tests/qapi-schema/enum-if-invalid.json @@ -1,3 +1,3 @@ # check invalid 'if' type -{ 'enum': 'TestIfEnum', 'data': - [ 'foo', { 'name' : 'bar', 'if': { 'val': 'foo' } } ] } +{ 'enum': 'TestIfEnum', + 'data': [ 'foo', { 'name' : 'bar', 'if': { 'val': 'foo' } } ] } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index b6c36a9eee..3c43e14e22 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -220,27 +220,27 @@ =20 # test 'if' condition handling =20 -{ 'struct': 'TestIfStruct', 'data': - { 'foo': 'int', - 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_BAR'} }, +{ 'struct': 'TestIfStruct', + 'data': { 'foo': 'int', + 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_BAR'} }, 'if': 'TEST_IF_STRUCT' } =20 -{ 'enum': 'TestIfEnum', 'data': - [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ], +{ 'enum': 'TestIfEnum', + 'data': [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ], 'if': 'TEST_IF_ENUM' } =20 -{ 'union': 'TestIfUnion', 'data': - { 'foo': 'TestStruct', - 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} }, +{ 'union': 'TestIfUnion', + 'data': { 'foo': 'TestStruct', + 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} }, 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-union-cmd', 'data': { 'union-cmd-arg': 'TestIfUnion' }, 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } } =20 -{ 'alternate': 'TestIfAlternate', 'data': - { 'foo': 'int', - 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_BAR'} }, +{ 'alternate': 'TestIfAlternate', + 'data': { 'foo': 'int', + 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_BAR'} }, 'if': { 'all': ['TEST_IF_ALT', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-alternate-cmd', @@ -256,9 +256,9 @@ =20 { 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' } =20 -{ 'event': 'TEST_IF_EVENT', 'data': - { 'foo': 'TestIfStruct', - 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } }, +{ 'event': 'TEST_IF_EVENT', + 'data': { 'foo': 'TestIfStruct', + 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } }, 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } } =20 { 'event': 'TEST_IF_EVENT2', 'data': {}, --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552294; cv=none; d=zohomail.com; s=zohoarc; b=fjgqu5kSpvmfWFxI7wqIhLlww0Dr/usK3ANk8lkaPvMsY2ism0sFdYKvD8BgU381hjiakCa/QoonsVpirhmx9mkZngJCzYpDijvucESUGXGHBDjdSkBl5XU20THKSjL1pzeKkP66bqcvR3CYx3VJ3BXM9Zmw5vS3comBUEEepuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552294; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rqTyOIb6ZBMcr8rJ+oxf7EFtgNWL6mFR1HQtd3y3BEE=; b=MtTfi/ME47ZyABopoqy3+ZstThPdlbx2cU0vIYbn8yGjzKVitfAmi1VDsCD7UdbNbS7IgLHl3NcqgG0n++0MNZZNT0j1spHCCA6Esv2cSXQ0rxyo2Bgn7ZQAHJoxVvbJj+EPa1C0eVY0hpuAa8aklhpiTrostfOLczQiaD2jvS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552294117385.244127460624; Fri, 24 Sep 2021 23:44:54 -0700 (PDT) Received: from localhost ([::1]:40258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Qb-00086p-0A for importer@patchew.org; Sat, 25 Sep 2021 02:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU184-0007af-FE for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17v-0007CW-IG for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-fj7P0cIeNTOgZ_lPGaw8ZQ-1; Sat, 25 Sep 2021 02:25:31 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 007A7362FD; Sat, 25 Sep 2021 06:25:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 841306091B; Sat, 25 Sep 2021 06:25:26 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1FBD411385C1; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rqTyOIb6ZBMcr8rJ+oxf7EFtgNWL6mFR1HQtd3y3BEE=; b=a/R81GR5Gc6aCS39BSp9JRykqdjNmqhCbpeRs7G1ZtbD/6GColUMkKE+qYkQeihzzVgff1 HES9cZY30PMJk76PtGDOuEfrmol2BZfwTZ6hPE6KaHAhQUFYHM63QOmOAVSE+Cf+qzmrDy Kp3I4lBuoiSPGNm38FxxWgic4dGBQJc= X-MC-Unique: fj7P0cIeNTOgZ_lPGaw8ZQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 02/25] qapi: Stop enforcing "type name should not end in 'Kind' Date: Sat, 25 Sep 2021 08:25:02 +0200 Message-Id: <20210925062525.988405-3-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552294576100001 Content-Type: text/plain; charset="utf-8" I'm about to convert simple unions to flat unions, then drop simple union support. The conversion involves making the implict enum types explicit. To reduce churn, I'd like to name them exactly like the implicit types they replace. However, these names are reserved for the generator's use. They won't be once simple unions are gone. Stop enforcing this naming rule now rather than then. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-3-armbru@redhat.com> --- scripts/qapi/expr.py | 6 +++--- tests/qapi-schema/meson.build | 1 - tests/qapi-schema/reserved-type-kind.err | 2 -- tests/qapi-schema/reserved-type-kind.json | 2 -- tests/qapi-schema/reserved-type-kind.out | 0 5 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 tests/qapi-schema/reserved-type-kind.err delete mode 100644 tests/qapi-schema/reserved-type-kind.json delete mode 100644 tests/qapi-schema/reserved-type-kind.out diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 90bde501b0..91959ee79a 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -171,7 +171,7 @@ def check_defn_name_str(name: str, info: QAPISourceInfo= , meta: str) -> None: - 'event' names adhere to `check_name_upper()`. - 'command' names adhere to `check_name_lower()`. - Else, meta is a type, and must pass `check_name_camel()`. - These names must not end with ``Kind`` nor ``List``. + These names must not end with ``List``. =20 :param name: Name to check. :param info: QAPI schema source file information. @@ -187,9 +187,9 @@ def check_defn_name_str(name: str, info: QAPISourceInfo= , meta: str) -> None: permit_underscore=3Dname in info.pragma.command_name_exception= s) else: check_name_camel(name, info, meta) - if name.endswith('Kind') or name.endswith('List'): + if name.endswith('List'): raise QAPISemError( - info, "%s name should not end in '%s'" % (meta, name[-4:])) + info, "%s name should not end in 'List'" % meta) =20 =20 def check_keys(value: _JSONObject, diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 6b2a4ce41a..0798e94042 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -168,7 +168,6 @@ schemas =3D [ 'reserved-member-q.json', 'reserved-member-u.json', 'reserved-member-underscore.json', - 'reserved-type-kind.json', 'reserved-type-list.json', 'returns-alternate.json', 'returns-array-bad.json', diff --git a/tests/qapi-schema/reserved-type-kind.err b/tests/qapi-schema/r= eserved-type-kind.err deleted file mode 100644 index d8fb769f9d..0000000000 --- a/tests/qapi-schema/reserved-type-kind.err +++ /dev/null @@ -1,2 +0,0 @@ -reserved-type-kind.json: In enum 'UnionKind': -reserved-type-kind.json:2: enum name should not end in 'Kind' diff --git a/tests/qapi-schema/reserved-type-kind.json b/tests/qapi-schema/= reserved-type-kind.json deleted file mode 100644 index 9ecaba12bc..0000000000 --- a/tests/qapi-schema/reserved-type-kind.json +++ /dev/null @@ -1,2 +0,0 @@ -# we reject types that would conflict with implicit union enum -{ 'enum': 'UnionKind', 'data': [ 'oops' ] } diff --git a/tests/qapi-schema/reserved-type-kind.out b/tests/qapi-schema/r= eserved-type-kind.out deleted file mode 100644 index e69de29bb2..0000000000 --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551320962728.0971271136594; Fri, 24 Sep 2021 23:28:40 -0700 (PDT) Received: from localhost ([::1]:35270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Au-0002Dc-0r for importer@patchew.org; Sat, 25 Sep 2021 02:28:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007Xl-Be for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17v-0007Cq-Ie for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-vNy_bUUJODqlSweWfxx-Jw-1; Sat, 25 Sep 2021 02:25:32 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 830AC802B9F; Sat, 25 Sep 2021 06:25:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 844CB1972D; Sat, 25 Sep 2021 06:25:26 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2334111385C3; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OaPlubjUPivI4g6A43fBnlp/WT3WccLBLtosSOiRF3s=; b=gGRWVqFWvFYNh52EZhOp2SAawM9qMgbWzi5rnKH7kFTuPhz9J18cUdPG5CY2E/ibXcdTyz MOxFOwp7o9If6vqhbkKSOsor8s9O/W2UfVaIGnFRamYpsMrUWNd8sYv4LjsU0QKOODvEar xNkRUxoSxa/pjMUe1eFDFj32z9JyKVo= X-MC-Unique: vNy_bUUJODqlSweWfxx-Jw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 03/25] qapi: Convert simple union KeyValue to flat one Date: Sat, 25 Sep 2021 08:25:03 +0200 Message-Id: <20210925062525.988405-4-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632551322696100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union KeyValue to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-4-armbru@redhat.com> --- qapi/ui.json | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index b2cf7a6759..9e04f9d65d 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -824,6 +824,30 @@ 'ac_home', 'ac_back', 'ac_forward', 'ac_refresh', 'ac_bookmark= s', 'lang1', 'lang2' ] } =20 +## +# @KeyValueKind: +# +# Since: 1.3 +## +{ 'enum': 'KeyValueKind', + 'data': [ 'number', 'qcode' ] } + +## +# @IntWrapper: +# +# Since: 1.3 +## +{ 'struct': 'IntWrapper', + 'data': { 'data': 'int' } } + +## +# @QKeyCodeWrapper: +# +# Since: 1.3 +## +{ 'struct': 'QKeyCodeWrapper', + 'data': { 'data': 'QKeyCode' } } + ## # @KeyValue: # @@ -832,9 +856,11 @@ # Since: 1.3 ## { 'union': 'KeyValue', + 'base': { 'type': 'KeyValueKind' }, + 'discriminator': 'type', 'data': { - 'number': 'int', - 'qcode': 'QKeyCode' } } + 'number': 'IntWrapper', + 'qcode': 'QKeyCodeWrapper' } } =20 ## # @send-key: --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552004264769.9865152563866; Fri, 24 Sep 2021 23:40:04 -0700 (PDT) Received: from localhost ([::1]:60398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Lv-0002RA-7n for importer@patchew.org; Sat, 25 Sep 2021 02:40:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007a4-Dy for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17x-0007FX-EV for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-wXGZUdRaO_u_baBXhi82dg-1; Sat, 25 Sep 2021 02:25:35 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 400F3802947; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 840F95D740; Sat, 25 Sep 2021 06:25:26 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 267CE1138526; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cF+o07LRAGRRT9QN314PSLKg6YT3QVgoYN4lEKrSRHg=; b=iwVm2V5N8S1qbohjougyC4soTO2Ox3C9filpXiwkURYvpuUEM4kTWoXACeB06LDdWfnS5w x5o9gDxDRlQoRDnK3ZY3fdgDs6U2hXMy0Nx/jbLYQeSYgh244IZBarU8lQ10MGenX5sqM2 0QBhnL6Dy8CWtG/cX0APMtJomJ6P59M= X-MC-Unique: wXGZUdRaO_u_baBXhi82dg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 04/25] qapi: Convert simple union InputEvent to flat one Date: Sat, 25 Sep 2021 08:25:04 +0200 Message-Id: <20210925062525.988405-5-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632552004713100002 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union InputEvent to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-5-armbru@redhat.com> --- qapi/ui.json | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index 9e04f9d65d..d7567ac866 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -960,6 +960,38 @@ 'data' : { 'axis' : 'InputAxis', 'value' : 'int' } } =20 +## +# @InputEventKind: +# +# Since: 2.0 +## +{ 'enum': 'InputEventKind', + 'data': [ 'key', 'btn', 'rel', 'abs' ] } + +## +# @InputKeyEventWrapper: +# +# Since: 2.0 +## +{ 'struct': 'InputKeyEventWrapper', + 'data': { 'data': 'InputKeyEvent' } } + +## +# @InputBtnEventWrapper: +# +# Since: 2.0 +## +{ 'struct': 'InputBtnEventWrapper', + 'data': { 'data': 'InputBtnEvent' } } + +## +# @InputMoveEventWrapper: +# +# Since: 2.0 +## +{ 'struct': 'InputMoveEventWrapper', + 'data': { 'data': 'InputMoveEvent' } } + ## # @InputEvent: # @@ -975,10 +1007,12 @@ # Since: 2.0 ## { 'union' : 'InputEvent', - 'data' : { 'key' : 'InputKeyEvent', - 'btn' : 'InputBtnEvent', - 'rel' : 'InputMoveEvent', - 'abs' : 'InputMoveEvent' } } + 'base': { 'type': 'InputEventKind' }, + 'discriminator': 'type', + 'data' : { 'key' : 'InputKeyEventWrapper', + 'btn' : 'InputBtnEventWrapper', + 'rel' : 'InputMoveEventWrapper', + 'abs' : 'InputMoveEventWrapper' } } =20 ## # @input-send-event: --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551314270227.59413420311148; Fri, 24 Sep 2021 23:28:34 -0700 (PDT) Received: from localhost ([::1]:35126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Am-00027b-QR for importer@patchew.org; Sat, 25 Sep 2021 02:28:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007Xn-Ba for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38126) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17v-0007EA-IF for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-ZFmTcWdHMlWc6IsRT2d5Qg-1; Sat, 25 Sep 2021 02:25:29 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5552362F8; Sat, 25 Sep 2021 06:25:28 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4D8BC19736; Sat, 25 Sep 2021 06:25:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 29A7B1138529; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zdwAhkvfRONsexIP4bgALgZQYwT7coGtPCPFkQJFoKs=; b=QTV546e1EDCVciqjyXj1EWsyD5kQUG49Z43evNeBRU52QIJEDs+kJ+gG4m+3TkNbuRLkC/ FMr1VsmiiZJYlT797QuNAyFHijoDx2o8HCvWd+UpEijOwnbjpMFtF4a+Q+9ykrcdSYYT9H GVX2PcNRqkv7fB3WPwz58kr5909V32c= X-MC-Unique: ZFmTcWdHMlWc6IsRT2d5Qg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 05/25] qapi: Convert simple union TpmTypeOptions to flat one Date: Sat, 25 Sep 2021 08:25:05 +0200 Message-Id: <20210925062525.988405-6-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Stefan Berger , Eric Blake , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632551316611100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union TpmTypeOptions to an equivalent flat one, with existing enum TpmType replacing implicit enum TpmTypeOptionsKind. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Stefan Berger Signed-off-by: Markus Armbruster Acked-by: Stefan Berger Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-6-armbru@redhat.com> --- qapi/tpm.json | 24 ++++++++++++++++++++++-- backends/tpm/tpm_emulator.c | 2 +- backends/tpm/tpm_passthrough.c | 2 +- monitor/hmp-cmds.c | 8 ++++---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/qapi/tpm.json b/qapi/tpm.json index f4dde2f646..3e7669facf 100644 --- a/qapi/tpm.json +++ b/qapi/tpm.json @@ -99,6 +99,24 @@ { 'struct': 'TPMEmulatorOptions', 'data': { 'chardev' : 'str' }, 'if': 'CONFIG_TPM' } =20 +## +# @TPMPassthroughOptionsWrapper: +# +# Since: 1.5 +## +{ 'struct': 'TPMPassthroughOptionsWrapper', + 'data': { 'data': 'TPMPassthroughOptions' }, + 'if': 'CONFIG_TPM' } + +## +# @TPMEmulatorOptionsWrapper: +# +# Since: 2.11 +## +{ 'struct': 'TPMEmulatorOptionsWrapper', + 'data': { 'data': 'TPMEmulatorOptions' }, + 'if': 'CONFIG_TPM' } + ## # @TpmTypeOptions: # @@ -110,8 +128,10 @@ # Since: 1.5 ## { 'union': 'TpmTypeOptions', - 'data': { 'passthrough' : 'TPMPassthroughOptions', - 'emulator': 'TPMEmulatorOptions' }, + 'base': { 'type': 'TpmType' }, + 'discriminator': 'type', + 'data': { 'passthrough' : 'TPMPassthroughOptionsWrapper', + 'emulator': 'TPMEmulatorOptionsWrapper' }, 'if': 'CONFIG_TPM' } =20 ## diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index f8095d23d5..87d061e9bb 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -623,7 +623,7 @@ static TpmTypeOptions *tpm_emulator_get_tpm_options(TPM= Backend *tb) TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); TpmTypeOptions *options =3D g_new0(TpmTypeOptions, 1); =20 - options->type =3D TPM_TYPE_OPTIONS_KIND_EMULATOR; + options->type =3D TPM_TYPE_EMULATOR; options->u.emulator.data =3D QAPI_CLONE(TPMEmulatorOptions, tpm_emu->o= ptions); =20 return options; diff --git a/backends/tpm/tpm_passthrough.c b/backends/tpm/tpm_passthrough.c index 21b7459183..d5558fae6c 100644 --- a/backends/tpm/tpm_passthrough.c +++ b/backends/tpm/tpm_passthrough.c @@ -321,7 +321,7 @@ static TpmTypeOptions *tpm_passthrough_get_tpm_options(= TPMBackend *tb) { TpmTypeOptions *options =3D g_new0(TpmTypeOptions, 1); =20 - options->type =3D TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; + options->type =3D TPM_TYPE_PASSTHROUGH; options->u.passthrough.data =3D QAPI_CLONE(TPMPassthroughOptions, TPM_PASSTHROUGH(tb)->options); =20 diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e00255f7ee..d6858407ad 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -925,10 +925,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) c, TpmModel_str(ti->model)); =20 monitor_printf(mon, " \\ %s: type=3D%s", - ti->id, TpmTypeOptionsKind_str(ti->options->type)); + ti->id, TpmType_str(ti->options->type)); =20 switch (ti->options->type) { - case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: + case TPM_TYPE_PASSTHROUGH: tpo =3D ti->options->u.passthrough.data; monitor_printf(mon, "%s%s%s%s", tpo->has_path ? ",path=3D" : "", @@ -936,11 +936,11 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) tpo->has_cancel_path ? ",cancel-path=3D" : "", tpo->has_cancel_path ? tpo->cancel_path : ""); break; - case TPM_TYPE_OPTIONS_KIND_EMULATOR: + case TPM_TYPE_EMULATOR: teo =3D ti->options->u.emulator.data; monitor_printf(mon, ",chardev=3D%s", teo->chardev); break; - case TPM_TYPE_OPTIONS_KIND__MAX: + case TPM_TYPE__MAX: break; } monitor_printf(mon, "\n"); --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551602615624.0298032623282; Fri, 24 Sep 2021 23:33:22 -0700 (PDT) Received: from localhost ([::1]:43606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1FR-0007kX-GF for importer@patchew.org; Sat, 25 Sep 2021 02:33:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007YQ-Ld for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17t-0007Bs-Ol for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-PlwUAdLANaWC1rVlnxvy9w-1; Sat, 25 Sep 2021 02:25:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF8D81006AA2; Sat, 25 Sep 2021 06:25:29 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E72260657; Sat, 25 Sep 2021 06:25:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2CF0A113853B; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rl/76egBchC0z6HYvLrR58HS0uTp9+lCDtH+lGvK4/Y=; b=UgyiuOeMnhjaV7UZ3pTR+qTeBldrIjbSQbXR++7P+Cm4RtLpDDjNdrvlBSfnOejzZlxpC7 8074yIKix/Wqvdo5/Ss1v44N7eLeNeJ01ffaBcuo0jF4JydAOtCncEZqXGa8dPhEKxUvcI 0vrpFc1/qxdKO1+gWlHF5Tj+hsniA6M= X-MC-Unique: PlwUAdLANaWC1rVlnxvy9w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 06/25] qapi: Convert simple union MemoryDeviceInfo to flat one Date: Sat, 25 Sep 2021 08:25:06 +0200 Message-Id: <20210925062525.988405-7-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632551604248100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union MemoryDeviceInfo to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Eduardo Habkost Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-7-armbru@redhat.com> --- qapi/machine.json | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 157712f006..32d47f4e35 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1194,6 +1194,38 @@ } } =20 +## +# @MemoryDeviceInfoKind: +# +# Since: 2.1 +## +{ 'enum': 'MemoryDeviceInfoKind', + 'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem' ] } + +## +# @PCDIMMDeviceInfoWrapper: +# +# Since: 2.1 +## +{ 'struct': 'PCDIMMDeviceInfoWrapper', + 'data': { 'data': 'PCDIMMDeviceInfo' } } + +## +# @VirtioPMEMDeviceInfoWrapper: +# +# Since: 2.1 +## +{ 'struct': 'VirtioPMEMDeviceInfoWrapper', + 'data': { 'data': 'VirtioPMEMDeviceInfo' } } + +## +# @VirtioMEMDeviceInfoWrapper: +# +# Since: 2.1 +## +{ 'struct': 'VirtioMEMDeviceInfoWrapper', + 'data': { 'data': 'VirtioMEMDeviceInfo' } } + ## # @MemoryDeviceInfo: # @@ -1205,10 +1237,12 @@ # Since: 2.1 ## { 'union': 'MemoryDeviceInfo', - 'data': { 'dimm': 'PCDIMMDeviceInfo', - 'nvdimm': 'PCDIMMDeviceInfo', - 'virtio-pmem': 'VirtioPMEMDeviceInfo', - 'virtio-mem': 'VirtioMEMDeviceInfo' + 'base': { 'type': 'MemoryDeviceInfoKind' }, + 'discriminator': 'type', + 'data': { 'dimm': 'PCDIMMDeviceInfoWrapper', + 'nvdimm': 'PCDIMMDeviceInfoWrapper', + 'virtio-pmem': 'VirtioPMEMDeviceInfoWrapper', + 'virtio-mem': 'VirtioMEMDeviceInfoWrapper' } } =20 --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552709192148.92214343980152; Fri, 24 Sep 2021 23:51:49 -0700 (PDT) Received: from localhost ([::1]:55068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1XI-0001Va-73 for importer@patchew.org; Sat, 25 Sep 2021 02:51:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU188-0007fW-O8 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU182-0007Lw-0O for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-srE97mr-PiOqm8doAQowGg-1; Sat, 25 Sep 2021 02:25:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B98D11006AA7; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5A355F707; Sat, 25 Sep 2021 06:25:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3077C11384A2; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XHCqOhMLCvCUmTvKzARuDyLc8b2BjtV0FGFGAEaLVMo=; b=Ty3cdJuBgFwqetRd2atXwUyAmpPouUydNhNcWBi2bdwCuhONEV2/8C0ChLp4no2RkhQQQ1 VhwRkIEcvH2YdPm+DI02McQ9OgXIyA2XsK5FIbvlHpiEvvzovpNwxTG8kyGcn8cMpXk74j 6Msj8HIF9h3f6etSLVn6uQC4een4ISk= X-MC-Unique: srE97mr-PiOqm8doAQowGg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 07/25] qapi: Convert simple union ChardevBackend to flat one Date: Sat, 25 Sep 2021 08:25:07 +0200 Message-Id: <20210925062525.988405-8-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Paolo Bonzini , Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632552710392100002 Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union ChardevBackend to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-8-armbru@redhat.com> --- qapi/char.json | 187 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 165 insertions(+), 22 deletions(-) diff --git a/qapi/char.json b/qapi/char.json index 9b18ee3305..cc1e455c87 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -407,39 +407,182 @@ 'base': 'ChardevCommon', 'if': 'CONFIG_SPICE_PROTOCOL' } =20 +## +# @ChardevBackendKind: +# +# @pipe: Since 1.5 +# @udp: Since 1.5 +# @mux: Since 1.5 +# @msmouse: Since 1.5 +# @wctablet: Since 2.9 +# @braille: Since 1.5 +# @testdev: Since 2.2 +# @stdio: Since 1.5 +# @console: Since 1.5 +# @spicevmc: Since 1.5 +# @spiceport: Since 1.5 +# @qemu-vdagent: Since 6.1 +# @vc: v1.5 +# @ringbuf: Since 1.6 +# @memory: Since 1.5 +# +# Since: 1.4 +## +{ 'enum': 'ChardevBackendKind', + 'data': [ 'file', + 'serial', + 'parallel', + 'pipe', + 'socket', + 'udp', + 'pty', + 'null', + 'mux', + 'msmouse', + 'wctablet', + 'braille', + 'testdev', + 'stdio', + 'console', + { 'name': 'spicevmc', 'if': 'CONFIG_SPICE' }, + { 'name': 'spiceport', 'if': 'CONFIG_SPICE' }, + { 'name': 'qemu-vdagent', 'if': 'CONFIG_SPICE_PROTOCOL' }, + 'vc', + 'ringbuf', + # next one is just for compatibility + 'memory' ] } + +## +# @ChardevFileWrapper: +# +# Since: 1.4 +## +{ 'struct': 'ChardevFileWrapper', + 'data': { 'data': 'ChardevFile' } } + +## +# @ChardevHostdevWrapper: +# +# Since: 1.4 +## +{ 'struct': 'ChardevHostdevWrapper', + 'data': { 'data': 'ChardevHostdev' } } + +## +# @ChardevSocketWrapper: +# +# Since: 1.4 +## +{ 'struct': 'ChardevSocketWrapper', + 'data': { 'data': 'ChardevSocket' } } + +## +# @ChardevUdpWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevUdpWrapper', + 'data': { 'data': 'ChardevUdp' } } + +## +# @ChardevCommonWrapper: +# +# Since: 2.6 +## +{ 'struct': 'ChardevCommonWrapper', + 'data': { 'data': 'ChardevCommon' } } + +## +# @ChardevMuxWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevMuxWrapper', + 'data': { 'data': 'ChardevMux' } } + +## +# @ChardevStdioWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevStdioWrapper', + 'data': { 'data': 'ChardevStdio' } } + +## +# @ChardevSpiceChannelWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevSpiceChannelWrapper', + 'data': { 'data': 'ChardevSpiceChannel' } } + +## +# @ChardevSpicePortWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevSpicePortWrapper', + 'data': { 'data': 'ChardevSpicePort' } } + +## +# @ChardevQemuVDAgentWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevQemuVDAgentWrapper', + 'data': { 'data': 'ChardevQemuVDAgent' } } + +## +# @ChardevVCWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevVCWrapper', + 'data': { 'data': 'ChardevVC' } } + +## +# @ChardevRingbufWrapper: +# +# Since: 1.5 +## +{ 'struct': 'ChardevRingbufWrapper', + 'data': { 'data': 'ChardevRingbuf' } } + ## # @ChardevBackend: # # Configuration info for the new chardev backend. # -# Since: 1.4 (testdev since 2.2, wctablet since 2.9, vdagent since 6.1) +# Since: 1.4 ## { 'union': 'ChardevBackend', - 'data': { 'file': 'ChardevFile', - 'serial': 'ChardevHostdev', - 'parallel': 'ChardevHostdev', - 'pipe': 'ChardevHostdev', - 'socket': 'ChardevSocket', - 'udp': 'ChardevUdp', - 'pty': 'ChardevCommon', - 'null': 'ChardevCommon', - 'mux': 'ChardevMux', - 'msmouse': 'ChardevCommon', - 'wctablet': 'ChardevCommon', - 'braille': 'ChardevCommon', - 'testdev': 'ChardevCommon', - 'stdio': 'ChardevStdio', - 'console': 'ChardevCommon', - 'spicevmc': { 'type': 'ChardevSpiceChannel', + 'base': { 'type': 'ChardevBackendKind' }, + 'discriminator': 'type', + 'data': { 'file': 'ChardevFileWrapper', + 'serial': 'ChardevHostdevWrapper', + 'parallel': 'ChardevHostdevWrapper', + 'pipe': 'ChardevHostdevWrapper', + 'socket': 'ChardevSocketWrapper', + 'udp': 'ChardevUdpWrapper', + 'pty': 'ChardevCommonWrapper', + 'null': 'ChardevCommonWrapper', + 'mux': 'ChardevMuxWrapper', + 'msmouse': 'ChardevCommonWrapper', + 'wctablet': 'ChardevCommonWrapper', + 'braille': 'ChardevCommonWrapper', + 'testdev': 'ChardevCommonWrapper', + 'stdio': 'ChardevStdioWrapper', + 'console': 'ChardevCommonWrapper', + 'spicevmc': { 'type': 'ChardevSpiceChannelWrapper', 'if': 'CONFIG_SPICE' }, - 'spiceport': { 'type': 'ChardevSpicePort', + 'spiceport': { 'type': 'ChardevSpicePortWrapper', 'if': 'CONFIG_SPICE' }, - 'qemu-vdagent': { 'type': 'ChardevQemuVDAgent', + 'qemu-vdagent': { 'type': 'ChardevQemuVDAgentWrapper', 'if': 'CONFIG_SPICE_PROTOCOL' }, - 'vc': 'ChardevVC', - 'ringbuf': 'ChardevRingbuf', + 'vc': 'ChardevVCWrapper', + 'ringbuf': 'ChardevRingbufWrapper', # next one is just for compatibility - 'memory': 'ChardevRingbuf' } } + 'memory': 'ChardevRingbufWrapper' } } =20 ## # @ChardevReturn: --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552586; cv=none; d=zohomail.com; s=zohoarc; b=Fx5t/zVmkUiqGukh/ZYPnbYedthpH39NOLKJtT8r9OWYiWYRxvCIcV+bNBAV++W75C1RwHCR4lXei72f4bfr9uZYRHIAKdeYePWpRzwAMTtP78P8e8xkud2ad3SQjxzI5g9BOSiIJOWu/SUo8g8SZrxtRqtu+Vh8h+quOZaLSBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552586; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y7cdoSv6tGTyXCNJ6AeziPVZDaTBw1HZcjMAUwlF9bY=; b=fU77LhBJFU6hSA/d7XAcPY3gc9OfCbjtS7jN8VdI5I6D3hNCr1ym3bM8nSEnoUMTwIAS/62jy/LfmNpITBTWkvUAuX8jjWmIsygyaoYLU4V365Fut5MAXbOyQOg2T1iD1vrH5VK8cJe825c4OI4ZuECrC6gO8BLw/HJBoiHEcVk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552586170330.0499046820262; Fri, 24 Sep 2021 23:49:46 -0700 (PDT) Received: from localhost ([::1]:51020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1VJ-000757-4w for importer@patchew.org; Sat, 25 Sep 2021 02:49:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU18C-0007jv-9D for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007ME-64 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-600-h6994Q4pOjCkBl1VOzxQog-1; Sat, 25 Sep 2021 02:25:37 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D1DC1084687; Sat, 25 Sep 2021 06:25:36 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DECFE6A904; Sat, 25 Sep 2021 06:25:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 33E5E11384A9; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y7cdoSv6tGTyXCNJ6AeziPVZDaTBw1HZcjMAUwlF9bY=; b=KZb5A1WHOt26ZpJ9FJ1mVxvcweEvsfptFkBWjbs9NG0qhXwjhO0vUMO84NMwQmkGzBgHmL HyhOcxI8QR9vzgswMN1WRJlJ/2GxWRygZyQf/wyD2cBWG9VUBSElJQZCB8S2HYHG63imcx OhypubypilBsxOiwbw6nFvy4oCU9rgc= X-MC-Unique: h6994Q4pOjCkBl1VOzxQog-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 08/25] qapi: Convert simple union SocketAddressLegacy to flat one Date: Sat, 25 Sep 2021 08:25:08 +0200 Message-Id: <20210925062525.988405-9-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552587965100001 Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union SocketAddressLegacy to an equivalent flat one, with existing enum SocketAddressType replacing implicit enum type SocketAddressLegacyKind. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: "Daniel P. Berrang=C3=A9" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-9-armbru@redhat.com> --- qapi/sockets.json | 46 +++++++++++++++++++++++++++++++++++------- chardev/char-socket.c | 6 +++--- chardev/char-udp.c | 4 ++-- tests/unit/test-yank.c | 6 +++--- util/qemu-sockets.c | 8 ++++---- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/qapi/sockets.json b/qapi/sockets.json index 7866dc27d6..ef4b16d6f2 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -110,6 +110,38 @@ 'cid': 'str', 'port': 'str' } } =20 +## +# @InetSocketAddressWrapper: +# +# Since: 1.3 +## +{ 'struct': 'InetSocketAddressWrapper', + 'data': { 'data': 'InetSocketAddress' } } + +## +# @UnixSocketAddressWrapper: +# +# Since: 1.3 +## +{ 'struct': 'UnixSocketAddressWrapper', + 'data': { 'data': 'UnixSocketAddress' } } + +## +# @VsockSocketAddressWrapper: +# +# Since: 2.8 +## +{ 'struct': 'VsockSocketAddressWrapper', + 'data': { 'data': 'VsockSocketAddress' } } + +## +# @StringWrapper: +# +# Since: 1.3 +## +{ 'struct': 'StringWrapper', + 'data': { 'data': 'String' } } + ## # @SocketAddressLegacy: # @@ -117,18 +149,18 @@ # # Note: This type is deprecated in favor of SocketAddress. The # difference between SocketAddressLegacy and SocketAddress is that t= he -# latter is a flat union rather than a simple union. Flat is nicer -# because it avoids nesting on the wire, i.e. that form has fewer {}. - +# latter is has fewer {} on the wire. # # Since: 1.3 ## { 'union': 'SocketAddressLegacy', + 'base': { 'type': 'SocketAddressType' }, + 'discriminator': 'type', 'data': { - 'inet': 'InetSocketAddress', - 'unix': 'UnixSocketAddress', - 'vsock': 'VsockSocketAddress', - 'fd': 'String' } } + 'inet': 'InetSocketAddressWrapper', + 'unix': 'UnixSocketAddressWrapper', + 'vsock': 'VsockSocketAddressWrapper', + 'fd': 'StringWrapper' } } =20 ## # @SocketAddressType: diff --git a/chardev/char-socket.c b/chardev/char-socket.c index c43668cc15..836cfa0bc2 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1520,7 +1520,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, addr =3D g_new0(SocketAddressLegacy, 1); if (path) { UnixSocketAddress *q_unix; - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX; + addr->type =3D SOCKET_ADDRESS_TYPE_UNIX; q_unix =3D addr->u.q_unix.data =3D g_new0(UnixSocketAddress, 1); q_unix->path =3D g_strdup(path); #ifdef CONFIG_LINUX @@ -1530,7 +1530,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, q_unix->abstract =3D abstract; #endif } else if (host) { - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; + addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); *addr->u.inet.data =3D (InetSocketAddress) { .host =3D g_strdup(host), @@ -1543,7 +1543,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, .ipv6 =3D qemu_opt_get_bool(opts, "ipv6", 0), }; } else if (fd) { - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_FD; + addr->type =3D SOCKET_ADDRESS_TYPE_FD; addr->u.fd.data =3D g_new(String, 1); addr->u.fd.data->str =3D g_strdup(fd); } else { diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 16b5dbce58..6756e69924 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -165,7 +165,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevB= ackend *backend, qemu_chr_parse_common(opts, qapi_ChardevUdp_base(udp)); =20 addr =3D g_new0(SocketAddressLegacy, 1); - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; + addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); *addr->u.inet.data =3D (InetSocketAddress) { .host =3D g_strdup(host), @@ -180,7 +180,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevB= ackend *backend, if (has_local) { udp->has_local =3D true; addr =3D g_new0(SocketAddressLegacy, 1); - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; + addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); *addr->u.inet.data =3D (InetSocketAddress) { .host =3D g_strdup(localaddr), diff --git a/tests/unit/test-yank.c b/tests/unit/test-yank.c index 2383d2908c..e6c036a64d 100644 --- a/tests/unit/test-yank.c +++ b/tests/unit/test-yank.c @@ -88,7 +88,7 @@ static void char_change_test(gconstpointer opaque) .type =3D CHARDEV_BACKEND_KIND_SOCKET, .u.socket.data =3D &(ChardevSocket) { .addr =3D &(SocketAddressLegacy) { - .type =3D SOCKET_ADDRESS_LEGACY_KIND_INET, + .type =3D SOCKET_ADDRESS_TYPE_INET, .u.inet.data =3D &addr->u.inet }, .has_server =3D true, @@ -102,7 +102,7 @@ static void char_change_test(gconstpointer opaque) .type =3D CHARDEV_BACKEND_KIND_UDP, .u.udp.data =3D &(ChardevUdp) { .remote =3D &(SocketAddressLegacy) { - .type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX, + .type =3D SOCKET_ADDRESS_TYPE_UNIX, .u.q_unix.data =3D &(UnixSocketAddress) { .path =3D (char *)"" } @@ -114,7 +114,7 @@ static void char_change_test(gconstpointer opaque) .type =3D CHARDEV_BACKEND_KIND_SOCKET, .u.socket.data =3D &(ChardevSocket) { .addr =3D &(SocketAddressLegacy) { - .type =3D SOCKET_ADDRESS_LEGACY_KIND_INET, + .type =3D SOCKET_ADDRESS_TYPE_INET, .u.inet.data =3D &(InetSocketAddress) { .host =3D (char *)"127.0.0.1", .port =3D (char *)"0" diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index c5043999e9..72216ef980 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1455,22 +1455,22 @@ SocketAddress *socket_address_flatten(SocketAddress= Legacy *addr_legacy) addr =3D g_new(SocketAddress, 1); =20 switch (addr_legacy->type) { - case SOCKET_ADDRESS_LEGACY_KIND_INET: + case SOCKET_ADDRESS_TYPE_INET: addr->type =3D SOCKET_ADDRESS_TYPE_INET; QAPI_CLONE_MEMBERS(InetSocketAddress, &addr->u.inet, addr_legacy->u.inet.data); break; - case SOCKET_ADDRESS_LEGACY_KIND_UNIX: + case SOCKET_ADDRESS_TYPE_UNIX: addr->type =3D SOCKET_ADDRESS_TYPE_UNIX; QAPI_CLONE_MEMBERS(UnixSocketAddress, &addr->u.q_unix, addr_legacy->u.q_unix.data); break; - case SOCKET_ADDRESS_LEGACY_KIND_VSOCK: + case SOCKET_ADDRESS_TYPE_VSOCK: addr->type =3D SOCKET_ADDRESS_TYPE_VSOCK; QAPI_CLONE_MEMBERS(VsockSocketAddress, &addr->u.vsock, addr_legacy->u.vsock.data); break; - case SOCKET_ADDRESS_LEGACY_KIND_FD: + case SOCKET_ADDRESS_TYPE_FD: addr->type =3D SOCKET_ADDRESS_TYPE_FD; QAPI_CLONE_MEMBERS(String, &addr->u.fd, addr_legacy->u.fd.data); break; --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552288386355.1621597391478; Fri, 24 Sep 2021 23:44:48 -0700 (PDT) Received: from localhost ([::1]:40140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1QV-00081y-5S for importer@patchew.org; Sat, 25 Sep 2021 02:44:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU188-0007fS-IW for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU181-0007LU-GX for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-Vo4FpYb5ObOLGVu2qqABZA-1; Sat, 25 Sep 2021 02:25:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5D26802947; Sat, 25 Sep 2021 06:25:36 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F08E060BF4; Sat, 25 Sep 2021 06:25:30 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 376791138461; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=apm8qE1ZnC1jfJixNsUjrXUi/YcW2qK5M+S67X2Nsqo=; b=DXNy39j7RgdphQvOlJp9hAWJrzu9HWvoN2zCPg6QCVDPAIPgUSgneYiysSaMt02OnWpywI sY1hmN1xrZ34BFGL2rMqJgdpi4w2gL4VmUp+6/cHiv+zGk/Ay/kIKGhhfUETZoSNS3YvBQ Pa7yMmFhitrBnQJeHGdTWxoCFsZqx44= X-MC-Unique: Vo4FpYb5ObOLGVu2qqABZA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 09/25] qapi: Convert simple union ImageInfoSpecific to flat one Date: Sat, 25 Sep 2021 08:25:09 +0200 Message-Id: <20210925062525.988405-10-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , peter.maydell@linaro.org, Hanna Reitz , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632552290436100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union ImageInfoSpecific to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Implicit enum ImageInfoSpecificKind becomes explicit. It duplicates part of enum BlockdevDriver. We could reuse BlockdevDriver instead. Cc: Kevin Wolf Cc: Hanna Reitz Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Acked-by: Hanna Reitz Message-Id: <20210917143134.412106-10-armbru@redhat.com> --- qapi/block-core.json | 59 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c8ce1d9d5d..623a4f4a3f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -139,6 +139,52 @@ '*encryption-format': 'RbdImageEncryptionFormat' } } =20 +## +# @ImageInfoSpecificKind: +# +# @luks: Since 2.7 +# @rbd: Since 6.1 +# +# Since: 1.7 +## +{ 'enum': 'ImageInfoSpecificKind', + 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd' ] } + +## +# @ImageInfoSpecificQCow2Wrapper: +# +# Since: 1.7 +## +{ 'struct': 'ImageInfoSpecificQCow2Wrapper', + 'data': { 'data': 'ImageInfoSpecificQCow2' } } + +## +# @ImageInfoSpecificVmdkWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ImageInfoSpecificVmdkWrapper', + 'data': { 'data': 'ImageInfoSpecificVmdk' } } + +## +# @ImageInfoSpecificLUKSWrapper: +# +# Since: 2.7 +## +{ 'struct': 'ImageInfoSpecificLUKSWrapper', + 'data': { 'data': 'QCryptoBlockInfoLUKS' } } +# If we need to add block driver specific parameters for +# LUKS in future, then we'll subclass QCryptoBlockInfoLUKS +# to define a ImageInfoSpecificLUKS + +## +# @ImageInfoSpecificRbdWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ImageInfoSpecificRbdWrapper', + 'data': { 'data': 'ImageInfoSpecificRbd' } } + ## # @ImageInfoSpecific: # @@ -147,14 +193,13 @@ # Since: 1.7 ## { 'union': 'ImageInfoSpecific', + 'base': { 'type': 'ImageInfoSpecificKind' }, + 'discriminator': 'type', 'data': { - 'qcow2': 'ImageInfoSpecificQCow2', - 'vmdk': 'ImageInfoSpecificVmdk', - # If we need to add block driver specific parameters for - # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS - # to define a ImageInfoSpecificLUKS - 'luks': 'QCryptoBlockInfoLUKS', - 'rbd': 'ImageInfoSpecificRbd' + 'qcow2': 'ImageInfoSpecificQCow2Wrapper', + 'vmdk': 'ImageInfoSpecificVmdkWrapper', + 'luks': 'ImageInfoSpecificLUKSWrapper', + 'rbd': 'ImageInfoSpecificRbdWrapper' } } =20 ## --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163255161463337.45487878480537; Fri, 24 Sep 2021 23:33:34 -0700 (PDT) Received: from localhost ([::1]:43780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1FY-0007rO-Qh for importer@patchew.org; Sat, 25 Sep 2021 02:33:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007ac-O5 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17y-0007G3-L8 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-554-z2jW-xt4Of6W13Pmq2AVmA-1; Sat, 25 Sep 2021 02:25:35 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFAEB180830E; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06922100763C; Sat, 25 Sep 2021 06:25:31 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3AAFD1138467; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nH2PT1yKeJg+fJFFcmXZqwNh8bl3WMfEN+zyuo2foWM=; b=XxGdBvGmRkd2sfWmwiWpqbk1ZQWPL3AiaNeReFE/LA53nIMMaGgsMddAxTyIkzhGjEACgd 8HwMGWznQt1AWspQas924UNEgwt5jb7SGJ4kkktaDb2ki22DyDl5zf6dCZatecQg5C1/gZ corfFQ00tCzomf95O+ONsRa7P/8keCI= X-MC-Unique: z2jW-xt4Of6W13Pmq2AVmA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 10/25] qapi: Convert simple union TransactionAction to flat one Date: Sat, 25 Sep 2021 08:25:10 +0200 Message-Id: <20210925062525.988405-11-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , peter.maydell@linaro.org, Hanna Reitz , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632551614880100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union TransactionAction to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Kevin Wolf Cc: Hanna Reitz Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Acked-by: Hanna Reitz Message-Id: <20210917143134.412106-11-armbru@redhat.com> --- qapi/transaction.json | 139 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 113 insertions(+), 26 deletions(-) diff --git a/qapi/transaction.json b/qapi/transaction.json index 894258d9e2..d175b5f863 100644 --- a/qapi/transaction.json +++ b/qapi/transaction.json @@ -38,41 +38,128 @@ { 'enum': 'ActionCompletionMode', 'data': [ 'individual', 'grouped' ] } =20 +## +# @TransactionActionKind: +# +# @abort: Since 1.6 +# @block-dirty-bitmap-add: Since 2.5 +# @block-dirty-bitmap-remove: Since 4.2 +# @block-dirty-bitmap-clear: Since 2.5 +# @block-dirty-bitmap-enable: Since 4.0 +# @block-dirty-bitmap-disable: Since 4.0 +# @block-dirty-bitmap-merge: Since 4.0 +# @blockdev-backup: Since 2.3 +# @blockdev-snapshot: Since 2.5 +# @blockdev-snapshot-internal-sync: Since 1.7 +# @blockdev-snapshot-sync: since 1.1 +# @drive-backup: Since 1.6 +# +# Since: 1.1 +## +{ 'enum': 'TransactionActionKind', + 'data': [ 'abort', 'block-dirty-bitmap-add', 'block-dirty-bitmap-remove', + 'block-dirty-bitmap-clear', 'block-dirty-bitmap-enable', + 'block-dirty-bitmap-disable', 'block-dirty-bitmap-merge', + 'blockdev-backup', 'blockdev-snapshot', + 'blockdev-snapshot-internal-sync', 'blockdev-snapshot-sync', + 'drive-backup' ] } + +## +# @AbortWrapper: +# +# Since: 1.6 +## +{ 'struct': 'AbortWrapper', + 'data': { 'data': 'Abort' } } + +## +# @BlockDirtyBitmapAddWrapper: +# +# Since: 2.5 +## +{ 'struct': 'BlockDirtyBitmapAddWrapper', + 'data': { 'data': 'BlockDirtyBitmapAdd' } } + +## +# @BlockDirtyBitmapWrapper: +# +# Since: 2.5 +## +{ 'struct': 'BlockDirtyBitmapWrapper', + 'data': { 'data': 'BlockDirtyBitmap' } } + +## +# @BlockDirtyBitmapMergeWrapper: +# +# Since: 4.0 +## +{ 'struct': 'BlockDirtyBitmapMergeWrapper', + 'data': { 'data': 'BlockDirtyBitmapMerge' } } + +## +# @BlockdevBackupWrapper: +# +# Since: 2.3 +## +{ 'struct': 'BlockdevBackupWrapper', + 'data': { 'data': 'BlockdevBackup' } } + +## +# @BlockdevSnapshotWrapper: +# +# Since: 2.5 +## +{ 'struct': 'BlockdevSnapshotWrapper', + 'data': { 'data': 'BlockdevSnapshot' } } + +## +# @BlockdevSnapshotInternalWrapper: +# +# Since: 1.7 +## +{ 'struct': 'BlockdevSnapshotInternalWrapper', + 'data': { 'data': 'BlockdevSnapshotInternal' } } + +## +# @BlockdevSnapshotSyncWrapper: +# +# Since: 1.1 +## +{ 'struct': 'BlockdevSnapshotSyncWrapper', + 'data': { 'data': 'BlockdevSnapshotSync' } } + +## +# @DriveBackupWrapper: +# +# Since: 1.6 +## +{ 'struct': 'DriveBackupWrapper', + 'data': { 'data': 'DriveBackup' } } + ## # @TransactionAction: # # A discriminated record of operations that can be performed with -# @transaction. Action @type can be: -# -# - @abort: since 1.6 -# - @block-dirty-bitmap-add: since 2.5 -# - @block-dirty-bitmap-remove: since 4.2 -# - @block-dirty-bitmap-clear: since 2.5 -# - @block-dirty-bitmap-enable: since 4.0 -# - @block-dirty-bitmap-disable: since 4.0 -# - @block-dirty-bitmap-merge: since 4.0 -# - @blockdev-backup: since 2.3 -# - @blockdev-snapshot: since 2.5 -# - @blockdev-snapshot-internal-sync: since 1.7 -# - @blockdev-snapshot-sync: since 1.1 -# - @drive-backup: since 1.6 +# @transaction. # # Since: 1.1 ## { 'union': 'TransactionAction', + 'base': { 'type': 'TransactionActionKind' }, + 'discriminator': 'type', 'data': { - 'abort': 'Abort', - 'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd', - 'block-dirty-bitmap-remove': 'BlockDirtyBitmap', - 'block-dirty-bitmap-clear': 'BlockDirtyBitmap', - 'block-dirty-bitmap-enable': 'BlockDirtyBitmap', - 'block-dirty-bitmap-disable': 'BlockDirtyBitmap', - 'block-dirty-bitmap-merge': 'BlockDirtyBitmapMerge', - 'blockdev-backup': 'BlockdevBackup', - 'blockdev-snapshot': 'BlockdevSnapshot', - 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', - 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', - 'drive-backup': 'DriveBackup' + 'abort': 'AbortWrapper', + 'block-dirty-bitmap-add': 'BlockDirtyBitmapAddWrapper', + 'block-dirty-bitmap-remove': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-clear': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-enable': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-disable': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-merge': 'BlockDirtyBitmapMergeWrapper', + 'blockdev-backup': 'BlockdevBackupWrapper', + 'blockdev-snapshot': 'BlockdevSnapshotWrapper', + 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternalWrapper= ', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSyncWrapper', + 'drive-backup': 'DriveBackupWrapper' } } =20 ## --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551321; cv=none; d=zohomail.com; s=zohoarc; b=UkfLzp3XecxIEcn4Y9Vq6SxMSIdT/zf71+DMOs/rlo7eag/I0K+KoIW4iASAxVqVWF3BlanRDMSqs4Ubxp2sgkVUA7dSSBZzjmyF9d9Q1pibMHtKv7BK4eor1U9Wu6KCVoBZhZgWqgX6Xysitwn5VJ8yxqxeI0o0q/zqRFBO22s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551321; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cgt/qx5DHAI+iBFfRYjAmQ/+wVvk1NDCMGKDj1ImZDk=; b=fAhWxbhn5iSL0p2LJJcl5ZrxZz4YqRsnoEd9ciUjfBObDiQNyIO6LZkMFjF7BgkXAbNdCj2QpTZbIzDYHNGgPQSuLEXkoHx9OJt92u3DRVDdEWO/nc9Ub8hHoX7nKZ4gF6jwhwYoeQ0tBXHtBUUJQ31g5Nl/HWVhWQFx2nYeP0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551321797364.88417837401846; Fri, 24 Sep 2021 23:28:41 -0700 (PDT) Received: from localhost ([::1]:35292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Au-0002EQ-MW for importer@patchew.org; Sat, 25 Sep 2021 02:28:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007YR-Si for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17v-0007E8-J2 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-hfctazaONg-_qZYTnFobtg-1; Sat, 25 Sep 2021 02:25:33 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80B5F1084683; Sat, 25 Sep 2021 06:25:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55A3A60936; Sat, 25 Sep 2021 06:25:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3DF561138468; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cgt/qx5DHAI+iBFfRYjAmQ/+wVvk1NDCMGKDj1ImZDk=; b=S8ZgDgnnPk4vU2Q1c5+bVMQlWez0pzdSkXGLpJr7YWA5HKyl3LlV5Axpc+OV08K+uSio9w iaFezNXf+VHbJ/ER0DOASfA+WBJVGFOFCmI77mOzCDNoR0e0F/lDQe4VqojodCXRqYkG14 JWX0Acwqf0N/ec6U7AED+iVaZhnH65E= X-MC-Unique: hfctazaONg-_qZYTnFobtg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 11/25] tests/qapi-schema: Prepare for simple union UserDefListUnion removal Date: Sat, 25 Sep 2021 08:25:11 +0200 Message-Id: <20210925062525.988405-12-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551322701100002 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, simple union UserDefListUnion has to go. It is used to cover arrays. The next few commits will eliminate its uses, and then it gets deleted. As a first step, provide struct ArrayStruct for the tests to be rewritten. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-12-armbru@redhat.com> --- tests/qapi-schema/qapi-schema-test.json | 16 ++++++++++++++++ tests/qapi-schema/qapi-schema-test.out | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 3c43e14e22..b2d795cb19 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -140,6 +140,22 @@ 'sizes': ['size'], 'any': ['any'], 'user': ['Status'] } } # intentional forward ref. to sub-module +{ 'struct': 'ArrayStruct', + 'data': { 'integer': ['int'], + 's8': ['int8'], + 's16': ['int16'], + 's32': ['int32'], + 's64': ['int64'], + 'u8': ['uint8'], + 'u16': ['uint16'], + 'u32': ['uint32'], + 'u64': ['uint64'], + 'number': ['number'], + 'boolean': ['bool'], + 'string': ['str'], + '*sz': ['size'], + '*any': ['any'], + '*user': ['Status'] } } # intentional forward ref. to sub-modu= le =20 # for testing sub-modules { 'include': 'include/sub-module.json' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index d557fe2d89..7a488c1d06 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -189,6 +189,22 @@ object UserDefListUnion case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper case user: q_obj_StatusList-wrapper +object ArrayStruct + member integer: intList optional=3DFalse + member s8: int8List optional=3DFalse + member s16: int16List optional=3DFalse + member s32: int32List optional=3DFalse + member s64: int64List optional=3DFalse + member u8: uint8List optional=3DFalse + member u16: uint16List optional=3DFalse + member u32: uint32List optional=3DFalse + member u64: uint64List optional=3DFalse + member number: numberList optional=3DFalse + member boolean: boolList optional=3DFalse + member string: strList optional=3DFalse + member sz: sizeList optional=3DTrue + member any: anyList optional=3DTrue + member user: StatusList optional=3DTrue include include/sub-module.json command user-def-cmd None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551835; cv=none; d=zohomail.com; s=zohoarc; b=gGjiOcqLhGQ1zUjhp09ebFlVYzR2wd0nA9rAYNcgHRFwulqOOntA/k0nI2sV5P69iXuayG2eU5TgGBhRZIt8PZSD/QsEjBQTK+lktgCYUdY4kNcljm8dvbH8qXPdJyNKeUaRgMt/ByHp+LiV3i7LLfBhueOI1Pq1yZGNL+mbOz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551835; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OFRunMcyi2K5J9JE4ZAWMIfADLHQTkisdY/dbvpg+1M=; b=KdYibEwxBEE4gQq7lU1ZHPGbRwMcdj5Q6qjrRa1zD48ZcJ6siW+riYp+46SqF3XVU/5Bt8VZrgSASXN8keRTwcLBTZ5PfiV+c3KAsKgxi5X+CLoLov8/t5hXT2MtseTqBhZBL8ofHQuOuOfRNfI/Vvd0FBfdVSjW0/0xYtA1csE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551835232607.9637000850369; Fri, 24 Sep 2021 23:37:15 -0700 (PDT) Received: from localhost ([::1]:52246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1JC-0005I2-4L for importer@patchew.org; Sat, 25 Sep 2021 02:37:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007aR-K3 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17x-0007Eu-EP for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-538--9ymLtN7MVOle7RDJ9zCRA-1; Sat, 25 Sep 2021 02:25:33 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB7888145E7; Sat, 25 Sep 2021 06:25:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55E5B6060F; Sat, 25 Sep 2021 06:25:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 417F41138469; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OFRunMcyi2K5J9JE4ZAWMIfADLHQTkisdY/dbvpg+1M=; b=CMeQrXhfGlPrtiFYkgILuxCHenHfVt/TRgpqozAuc59t/U/EIodl0wXLVN0PgBfHA8Ra+T l36hanD1jXAki5LeE4qFcEYypycOFWtHcgxT6woL3Ntr7kK5p+Idtnpy9+ZobCfWQqI7fk hFU5my1/zSdaZWsDhXV13IvbW+3XdYg= X-MC-Unique: -9ymLtN7MVOle7RDJ9zCRA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 12/25] test-qobject-input-visitor: Wean off UserDefListUnion Date: Sat, 25 Sep 2021 08:25:12 +0200 Message-Id: <20210925062525.988405-13-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551837245100002 Content-Type: text/plain; charset="utf-8" The test_visitor_in_list_union_FOO() use simple union UserDefListUnion to cover lists of builtin types. Rewrite as test_visitor_in_list_struct(), using struct ArrayStruct and a lot less code. test_visitor_in_fail_union_list() uses UserDefListUnion to cover "variant members don't match the discriminator value". Cover that in test_visitor_in_fail_union_flat() instead, and drop test_visitor_in_fail_union_list(). Appropriating the former for this purpose is okay, because it actually failed due to missing discriminator, which is still covered by test_visitor_in_fail_union_flat_no_discrim(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-13-armbru@redhat.com> --- tests/unit/test-qobject-input-visitor.c | 460 ++++++++---------------- 1 file changed, 148 insertions(+), 312 deletions(-) diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobj= ect-input-visitor.c index e41b91a2a6..6f59a7f432 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -464,6 +464,151 @@ static void test_visitor_in_list(TestInputVisitorData= *data, g_assert(!head); } =20 +static void test_visitor_in_list_struct(TestInputVisitorData *data, + const void *unused) +{ + const char *int_member[] =3D { + "integer", "s8", "s16", "s32", "s64", "u8", "u16", "u32", "u64" }; + g_autoptr(GString) json =3D g_string_new(""); + int i, j; + const char *sep; + g_autoptr(ArrayStruct) arrs =3D NULL; + Visitor *v; + intList *int_list; + int8List *s8_list; + int16List *s16_list; + int32List *s32_list; + int64List *s64_list; + uint8List *u8_list; + uint16List *u16_list; + uint32List *u32_list; + uint64List *u64_list; + numberList *num_list; + boolList *bool_list; + strList *str_list; + + g_string_append_printf(json, "{"); + + for (i =3D 0; i < G_N_ELEMENTS(int_member); i++) { + g_string_append_printf(json, "'%s': [", int_member[i]); + sep =3D ""; + for (j =3D 0; j < 32; j++) { + g_string_append_printf(json, "%s%d", sep, j); + sep =3D ", "; + } + g_string_append_printf(json, "], "); + } + + g_string_append_printf(json, "'number': ["); + sep =3D ""; + for (i =3D 0; i < 32; i++) { + g_string_append_printf(json, "%s%f", sep, (double)i / 3); + sep =3D ", "; + } + g_string_append_printf(json, "], "); + + g_string_append_printf(json, "'boolean': ["); + sep =3D ""; + for (i =3D 0; i < 32; i++) { + g_string_append_printf(json, "%s%s", + sep, i % 3 =3D=3D 0 ? "true" : "false"); + sep =3D ", "; + } + g_string_append_printf(json, "], "); + + g_string_append_printf(json, "'string': ["); + sep =3D ""; + for (i =3D 0; i < 32; i++) { + g_string_append_printf(json, "%s'%d'", sep, i); + sep =3D ", "; + } + g_string_append_printf(json, "]"); + + g_string_append_printf(json, "}"); + + v =3D visitor_input_test_init_raw(data, json->str); + visit_type_ArrayStruct(v, NULL, &arrs, &error_abort); + + i =3D 0; + for (int_list =3D arrs->integer; int_list; int_list =3D int_list->next= ) { + g_assert_cmpint(int_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s8_list =3D arrs->s8; s8_list; s8_list =3D s8_list->next) { + g_assert_cmpint(s8_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s16_list =3D arrs->s16; s16_list; s16_list =3D s16_list->next) { + g_assert_cmpint(s16_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s32_list =3D arrs->s32; s32_list; s32_list =3D s32_list->next) { + g_assert_cmpint(s32_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s64_list =3D arrs->s64; s64_list; s64_list =3D s64_list->next) { + g_assert_cmpint(s64_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u8_list =3D arrs->u8; u8_list; u8_list =3D u8_list->next) { + g_assert_cmpint(u8_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u16_list =3D arrs->u16; u16_list; u16_list =3D u16_list->next) { + g_assert_cmpint(u16_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u32_list =3D arrs->u32; u32_list; u32_list =3D u32_list->next) { + g_assert_cmpint(u32_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u64_list =3D arrs->u64; u64_list; u64_list =3D u64_list->next) { + g_assert_cmpint(u64_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (num_list =3D arrs->number; num_list; num_list =3D num_list->next)= { + char expected[32], actual[32]; + + sprintf(expected, "%.6f", (double)i / 3); + sprintf(actual, "%.6f", num_list->value); + g_assert_cmpstr(expected, =3D=3D, actual); + i++; + } + + i =3D 0; + for (bool_list =3D arrs->boolean; bool_list; bool_list =3D bool_list->= next) { + g_assert_cmpint(bool_list->value, =3D=3D, i % 3 =3D=3D 0); + i++; + } + + i =3D 0; + for (str_list =3D arrs->string; str_list; str_list =3D str_list->next)= { + char expected[32]; + + sprintf(expected, "%d", i); + g_assert_cmpstr(str_list->value, =3D=3D, expected); + i++; + } +} + static void test_visitor_in_any(TestInputVisitorData *data, const void *unused) { @@ -682,276 +827,6 @@ static void test_visitor_in_alternate_number(TestInpu= tVisitorData *data, qapi_free_AltEnumInt(asi); } =20 -static void test_list_union_integer_helper(TestInputVisitorData *data, - const void *unused, - UserDefListUnionKind kind) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "%d", i); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }", - UserDefListUnionKind_str(kind), - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, kind); - - switch (kind) { - case USER_DEF_LIST_UNION_KIND_INTEGER: { - intList *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.integer.data; - elem; elem =3D elem->next, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S8: { - int8List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s8.data; elem; elem =3D elem->nex= t, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S16: { - int16List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s16.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S32: { - int32List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s32.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S64: { - int64List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s64.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U8: { - uint8List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u8.data; elem; elem =3D elem->nex= t, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U16: { - uint16List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u16.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U32: { - uint32List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u32.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U64: { - uint64List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u64.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - default: - g_assert_not_reached(); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - -static void test_visitor_in_list_union_int(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_INTEGER); -} - -static void test_visitor_in_list_union_int8(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S8); -} - -static void test_visitor_in_list_union_int16(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S16); -} - -static void test_visitor_in_list_union_int32(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S32); -} - -static void test_visitor_in_list_union_int64(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S64); -} - -static void test_visitor_in_list_union_uint8(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U8); -} - -static void test_visitor_in_list_union_uint16(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U16); -} - -static void test_visitor_in_list_union_uint32(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U32); -} - -static void test_visitor_in_list_union_uint64(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U64); -} - -static void test_visitor_in_list_union_bool(TestInputVisitorData *data, - const void *unused) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - boolList *elem =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "%s", - (i % 3 =3D=3D 0) ? "true" : "false"); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': 'boolean', 'data': [ %s= ] }", - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, USER_DEF_LIST_UNION_KIND_BOOLEAN= ); - - for (i =3D 0, elem =3D cvalue->u.boolean.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, (i % 3 =3D=3D 0) ? 1 : 0); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - -static void test_visitor_in_list_union_string(TestInputVisitorData *data, - const void *unused) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - strList *elem =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "'%d'", i); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s = ] }", - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, USER_DEF_LIST_UNION_KIND_STRING); - - for (i =3D 0, elem =3D cvalue->u.string.data; elem; elem =3D elem->nex= t, i++) { - gchar str[8]; - sprintf(str, "%d", i); - g_assert_cmpstr(elem->value, =3D=3D, str); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - -#define DOUBLE_STR_MAX 16 - -static void test_visitor_in_list_union_number(TestInputVisitorData *data, - const void *unused) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - numberList *elem =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "%f", (double)i / 3); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': 'number', 'data': [ %s = ] }", - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, USER_DEF_LIST_UNION_KIND_NUMBER); - - for (i =3D 0, elem =3D cvalue->u.number.data; elem; elem =3D elem->nex= t, i++) { - GString *double_expected =3D g_string_new(""); - GString *double_actual =3D g_string_new(""); - - g_string_printf(double_expected, "%.6f", (double)i / 3); - g_string_printf(double_actual, "%.6f", elem->value); - g_assert_cmpstr(double_expected->str, =3D=3D, double_actual->str); - - g_string_free(double_expected, true); - g_string_free(double_actual, true); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - static void input_visitor_test_add(const char *testpath, const void *user_data, void (*test_func)(TestInputVisitorData = *data, @@ -1184,21 +1059,6 @@ static void test_visitor_in_fail_list_nested(TestInp= utVisitorData *data, visit_end_list(v, NULL); } =20 -static void test_visitor_in_fail_union_list(TestInputVisitorData *data, - const void *unused) -{ - UserDefListUnion *tmp =3D NULL; - Error *err =3D NULL; - Visitor *v; - - v =3D visitor_input_test_init(data, - "{ 'type': 'integer', 'data' : [ 'string' = ] }"); - - visit_type_UserDefListUnion(v, NULL, &tmp, &err); - error_free_or_abort(&err); - g_assert(!tmp); -} - static void test_visitor_in_fail_union_flat(TestInputVisitorData *data, const void *unused) { @@ -1206,7 +1066,7 @@ static void test_visitor_in_fail_union_flat(TestInput= VisitorData *data, Error *err =3D NULL; Visitor *v; =20 - v =3D visitor_input_test_init(data, "{ 'string': 'c', 'integer': 41, '= boolean': true }"); + v =3D visitor_input_test_init(data, "{ 'enum1': 'value2', 'string': 'c= ', 'integer': 41, 'boolean': true }"); =20 visit_type_UserDefFlatUnion(v, NULL, &tmp, &err); error_free_or_abort(&err); @@ -1310,6 +1170,8 @@ int main(int argc, char **argv) NULL, test_visitor_in_struct); input_visitor_test_add("/visitor/input/struct-nested", NULL, test_visitor_in_struct_nested); + input_visitor_test_add("/visitor/input/list2", + NULL, test_visitor_in_list_struct); input_visitor_test_add("/visitor/input/list", NULL, test_visitor_in_list); input_visitor_test_add("/visitor/input/any", @@ -1326,30 +1188,6 @@ 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/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", @@ -1368,8 +1206,6 @@ int main(int argc, char **argv) NULL, test_visitor_in_fail_union_flat_no_discri= m); input_visitor_test_add("/visitor/input/fail/alternate", NULL, test_visitor_in_fail_alternate); - 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); =20 --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551476; cv=none; d=zohomail.com; s=zohoarc; b=H+fFW+0g6r1tUwx3AZjPF12paXAQYWygAhGB4PLXYrdDVBynFaL432ghaEoNpRR8S2+iU6LA9OpCrIP6dQI8ShT4JqydcNp7ZWhMSu9XsEanTP1CIQGIFwiZNG67I/StXPvhZDBd993Vcuf+8oWdx8fXvphmMwFwlKGJ/0KWU+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bm8FCCJ/3mzzVePMFmbnmX3RycLnrNCdK/g5hIJIKxA=; b=Oennhey5Qzxi8hTZzo2gIrSJp3HMRn4pIgBbGDnvONwfzt3HrKQX5+ZTG6161u2L/8s27gIxx1CQfFW9EFIOXgUdZeRwqV9DU6j7VXQOTv5gJJouA8PcSvt7/CFDG5Uiwh3KqDRmqM7q5rM2MKh9jD9lubHfuyTi05gOAxOE8jw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551476179726.327186656827; Fri, 24 Sep 2021 23:31:16 -0700 (PDT) Received: from localhost ([::1]:41344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1DO-0006D8-Kw for importer@patchew.org; Sat, 25 Sep 2021 02:31:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU187-0007eR-Kh for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17y-0007He-Lx for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-4YOYpL1zNLa3O_5zf2fxlA-1; Sat, 25 Sep 2021 02:25:36 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4FB5B1808310; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B208A1010424; Sat, 25 Sep 2021 06:25:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 452EC11380A9; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bm8FCCJ/3mzzVePMFmbnmX3RycLnrNCdK/g5hIJIKxA=; b=OHS1M4YOSYiuy4pL486p5WX0MM9LymkcZ8xghC+IekQdpVDMp4cfigb4i8I5fXExOZbipE dKICBG/Yg8UnsFugqaOeTPJO4VfsNQMZ1/dAGLgwCDma1wbyRtSulD2GFH7lVXH7saXcYp qj+exECnwEiKv892UcU3hJNtRXEfQuA= X-MC-Unique: 4YOYpL1zNLa3O_5zf2fxlA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 13/25] test-qobject-output-visitor: Wean off UserDefListUnion Date: Sat, 25 Sep 2021 08:25:13 +0200 Message-Id: <20210925062525.988405-14-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551477825100001 Content-Type: text/plain; charset="utf-8" The test_visitor_out_list_union_FOO() use simple union UserDefListUnion to cover lists of builtin types. Rewrite as test_visitor_out_list_struct(), using struct ArrayStruct and a lot less code. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-14-armbru@redhat.com> --- tests/unit/test-qobject-output-visitor.c | 391 ++++++----------------- 1 file changed, 93 insertions(+), 298 deletions(-) diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qob= ject-output-visitor.c index 9dc1e075e7..34d67a439a 100644 --- a/tests/unit/test-qobject-output-visitor.c +++ b/tests/unit/test-qobject-output-visitor.c @@ -437,289 +437,118 @@ static void test_visitor_out_null(TestOutputVisitor= Data *data, g_assert(qobject_type(nil) =3D=3D QTYPE_QNULL); } =20 -static void init_list_union(UserDefListUnion *cvalue) -{ - int i; - switch (cvalue->type) { - case USER_DEF_LIST_UNION_KIND_INTEGER: { - intList **tail =3D &cvalue->u.integer.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S8: { - int8List **tail =3D &cvalue->u.s8.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S16: { - int16List **tail =3D &cvalue->u.s16.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S32: { - int32List **tail =3D &cvalue->u.s32.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S64: { - int64List **tail =3D &cvalue->u.s64.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U8: { - uint8List **tail =3D &cvalue->u.u8.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U16: { - uint16List **tail =3D &cvalue->u.u16.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U32: { - uint32List **tail =3D &cvalue->u.u32.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U64: { - uint64List **tail =3D &cvalue->u.u64.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_BOOLEAN: { - boolList **tail =3D &cvalue->u.boolean.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, QEMU_IS_ALIGNED(i, 3)); - } - break; - } - case USER_DEF_LIST_UNION_KIND_STRING: { - strList **tail =3D &cvalue->u.string.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, g_strdup_printf("%d", i)); - } - break; - } - case USER_DEF_LIST_UNION_KIND_NUMBER: { - numberList **tail =3D &cvalue->u.number.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, (double)i / 3); - } - break; - } - default: - g_assert_not_reached(); - } -} - -static void check_list_union(QObject *qobj, - UserDefListUnionKind kind) +static void test_visitor_out_list_struct(TestOutputVisitorData *data, + const void *unused) { + const char *int_member[] =3D { + "integer", "s8", "s16", "s32", "s64", "u8", "u16", "u32", "u64" }; + g_autoptr(ArrayStruct) arrs =3D g_new0(ArrayStruct, 1); + int i, j; QDict *qdict; QList *qlist; - int i; + QListEntry *e; =20 - qdict =3D qobject_to(QDict, qobj); - g_assert(qdict); - g_assert(qdict_haskey(qdict, "data")); - qlist =3D qlist_copy(qobject_to(QList, qdict_get(qdict, "data"))); - - switch (kind) { - 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 =3D 0; i < 32; i++) { - QObject *tmp; - QNum *qvalue; - uint64_t val; - - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QNum, tmp); - g_assert(qnum_get_try_uint(qvalue, &val)); - g_assert_cmpint(val, =3D=3D, i); - qobject_unref(qlist_pop(qlist)); - } - break; - - 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_LIST_UNION_KIND_INTEGER: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QNum *qvalue; - int64_t val; - - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QNum, tmp); - g_assert(qnum_get_try_int(qvalue, &val)); - g_assert_cmpint(val, =3D=3D, i); - qobject_unref(qlist_pop(qlist)); - } - break; - case USER_DEF_LIST_UNION_KIND_BOOLEAN: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QBool *qvalue; - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QBool, tmp); - g_assert_cmpint(qbool_get_bool(qvalue), =3D=3D, i % 3 =3D=3D 0= ); - qobject_unref(qlist_pop(qlist)); - } - break; - case USER_DEF_LIST_UNION_KIND_STRING: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QString *qvalue; - gchar str[8]; - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QString, tmp); - sprintf(str, "%d", i); - g_assert_cmpstr(qstring_get_str(qvalue), =3D=3D, str); - qobject_unref(qlist_pop(qlist)); - } - break; - case USER_DEF_LIST_UNION_KIND_NUMBER: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QNum *qvalue; - GString *double_expected =3D g_string_new(""); - GString *double_actual =3D g_string_new(""); - - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QNum, tmp); - g_string_printf(double_expected, "%.6f", (double)i / 3); - g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue)= ); - g_assert_cmpstr(double_actual->str, =3D=3D, double_expected->s= tr); - - qobject_unref(qlist_pop(qlist)); - g_string_free(double_expected, true); - g_string_free(double_actual, true); - } - break; - default: - g_assert_not_reached(); + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->integer, i); } - qobject_unref(qlist); -} =20 -static void test_list_union(TestOutputVisitorData *data, - const void *unused, - UserDefListUnionKind kind) -{ - UserDefListUnion *cvalue =3D g_new0(UserDefListUnion, 1); - QObject *obj; + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s8, i); + } =20 - cvalue->type =3D kind; - init_list_union(cvalue); + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s16, i); + } =20 - visit_type_UserDefListUnion(data->ov, NULL, &cvalue, &error_abort); + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s32, i); + } =20 - obj =3D visitor_get(data); - check_list_union(obj, cvalue->type); - qapi_free_UserDefListUnion(cvalue); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s64, i); + } =20 -static void test_visitor_out_list_union_int(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_INTEGER); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u8, i); + } =20 -static void test_visitor_out_list_union_int8(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S8); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u16, i); + } =20 -static void test_visitor_out_list_union_int16(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S16); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u32, i); + } =20 -static void test_visitor_out_list_union_int32(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S32); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u64, i); + } =20 -static void test_visitor_out_list_union_int64(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S64); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->number, (double)i / 3); + } =20 -static void test_visitor_out_list_union_uint8(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U8); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->boolean, QEMU_IS_ALIGNED(i, 3)); + } =20 -static void test_visitor_out_list_union_uint16(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U16); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->string, g_strdup_printf("%d", i)); + } =20 -static void test_visitor_out_list_union_uint32(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U32); -} + visit_type_ArrayStruct(data->ov, NULL, &arrs, &error_abort); =20 -static void test_visitor_out_list_union_uint64(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U64); -} + qdict =3D qobject_to(QDict, visitor_get(data)); + g_assert(qdict); =20 -static void test_visitor_out_list_union_bool(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_BOOLEAN); -} + for (i =3D 0; i < G_N_ELEMENTS(int_member); i++) { + qlist =3D qdict_get_qlist(qdict, int_member[i]); + g_assert(qlist); + j =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QNum *qvalue =3D qobject_to(QNum, qlist_entry_obj(e)); + g_assert(qvalue); + g_assert_cmpint(qnum_get_int(qvalue), =3D=3D, j); + j++; + } + } =20 -static void test_visitor_out_list_union_str(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_STRING); -} + qlist =3D qdict_get_qlist(qdict, "number"); + g_assert(qlist); + i =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QNum *qvalue =3D qobject_to(QNum, qlist_entry_obj(e)); + char expected[32], actual[32]; =20 -static void test_visitor_out_list_union_number(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_NUMBER); + g_assert(qvalue); + sprintf(expected, "%.6f", (double)i / 3); + sprintf(actual, "%.6f", qnum_get_double(qvalue)); + g_assert_cmpstr(actual, =3D=3D, expected); + i++; + } + + qlist =3D qdict_get_qlist(qdict, "boolean"); + g_assert(qlist); + i =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QBool *qvalue =3D qobject_to(QBool, qlist_entry_obj(e)); + g_assert(qvalue); + g_assert_cmpint(qbool_get_bool(qvalue), =3D=3D, i % 3 =3D=3D 0); + i++; + } + + qlist =3D qdict_get_qlist(qdict, "string"); + g_assert(qlist); + i =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QString *qvalue =3D qobject_to(QString, qlist_entry_obj(e)); + char expected[32]; + + g_assert(qvalue); + sprintf(expected, "%d", i); + g_assert_cmpstr(qstring_get_str(qvalue), =3D=3D, expected); + i++; + } } =20 static void output_visitor_test_add(const char *testpath, @@ -764,42 +593,8 @@ 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/list_union/int", - &out_visitor_data, - test_visitor_out_list_union_int); - output_visitor_test_add("/visitor/output/list_union/int8", - &out_visitor_data, - test_visitor_out_list_union_int8); - output_visitor_test_add("/visitor/output/list_union/int16", - &out_visitor_data, - test_visitor_out_list_union_int16); - output_visitor_test_add("/visitor/output/list_union/int32", - &out_visitor_data, - test_visitor_out_list_union_int32); - output_visitor_test_add("/visitor/output/list_union/int64", - &out_visitor_data, - test_visitor_out_list_union_int64); - output_visitor_test_add("/visitor/output/list_union/uint8", - &out_visitor_data, - test_visitor_out_list_union_uint8); - output_visitor_test_add("/visitor/output/list_union/uint16", - &out_visitor_data, - test_visitor_out_list_union_uint16); - output_visitor_test_add("/visitor/output/list_union/uint32", - &out_visitor_data, - test_visitor_out_list_union_uint32); - output_visitor_test_add("/visitor/output/list_union/uint64", - &out_visitor_data, - test_visitor_out_list_union_uint64); - output_visitor_test_add("/visitor/output/list_union/bool", - &out_visitor_data, - test_visitor_out_list_union_bool); - output_visitor_test_add("/visitor/output/list_union/string", - &out_visitor_data, - test_visitor_out_list_union_str); - output_visitor_test_add("/visitor/output/list_union/number", - &out_visitor_data, - test_visitor_out_list_union_number); + output_visitor_test_add("/visitor/output/list_struct", + &out_visitor_data, test_visitor_out_list_struc= t); =20 g_test_run(); =20 --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551832; cv=none; d=zohomail.com; s=zohoarc; b=jo9p93ashSXunYxQZpQlD7ZVVTmM/dcNv1slgN4LPIWZJ7jDz+XFPeEKDgPU6F/ExLXn4QwFVIdzN2ej1N7KtuM4zz+djT2cGsnoKzRWQRcz2nETp3TGne39uEdfYPvid3mSC/GvwOvb3KdljOabFGt0SdZLGJT06Q1NFuHd3MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551832; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dg9yRNADRqqdZyNvNH4gX7/9UOsvgHheSdqMHBN7N7M=; b=WN0frOD9lD0InamYNDfGnTlcYkqAuPmz0C/H3AWuoZE4j2qf8ffnYipD/Cxy7GecD4m9ioyMVbH/0akfBc773FnpID2T5qoLHopEixfCVHfDVpXhpuokSre/tX1aC4cv47PgWoUQv+Im7CR6v1yECSR5SqH9BuYU7ekMmZ/C82g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551832841524.1626661119406; Fri, 24 Sep 2021 23:37:12 -0700 (PDT) Received: from localhost ([::1]:52198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1J9-0005G7-Rj for importer@patchew.org; Sat, 25 Sep 2021 02:37:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU185-0007cb-N1 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007IO-8A for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-_ye4DYkxM9m26524m2dvdQ-1; Sat, 25 Sep 2021 02:25:35 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A76301084683; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B59381017CE7; Sat, 25 Sep 2021 06:25:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4870C11380AB; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dg9yRNADRqqdZyNvNH4gX7/9UOsvgHheSdqMHBN7N7M=; b=O/hXUB8g5OFwFCiqmtuPttkzDHQgm967IHhAO8+DIYIcUk8zaY3I9Tkpob2w3gVC7bQxBf izT+lzXxTLa/SAzFRfRKr3XiVWaTyqXyIM2/AY9Xmb4S/c99hLx0DlzQPbGPOP/3DCh9xb krvpgudLVxJmf7bKitxVKpT1P0IlxUo= X-MC-Unique: _ye4DYkxM9m26524m2dvdQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 14/25] test-clone-visitor: Wean off UserDefListUnion Date: Sat, 25 Sep 2021 08:25:14 +0200 Message-Id: <20210925062525.988405-15-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551833125100001 Content-Type: text/plain; charset="utf-8" test_clone_complex1() uses simple union UserDefListUnion to cover unions. Use UserDefFlatUnion instead. Arrays are still covered by test_clone_complex3(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-15-armbru@redhat.com> --- tests/unit/test-clone-visitor.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/unit/test-clone-visitor.c b/tests/unit/test-clone-visito= r.c index 4944b3d857..8357a90e60 100644 --- a/tests/unit/test-clone-visitor.c +++ b/tests/unit/test-clone-visitor.c @@ -99,18 +99,26 @@ static void test_clone_empty(void) =20 static void test_clone_complex1(void) { - UserDefListUnion *src, *dst; + UserDefFlatUnion *src, *dst; =20 - src =3D g_new0(UserDefListUnion, 1); - src->type =3D USER_DEF_LIST_UNION_KIND_STRING; + src =3D g_new0(UserDefFlatUnion, 1); + src->integer =3D 123; + src->string =3D g_strdup("abc"); + src->enum1 =3D ENUM_ONE_VALUE1; + src->u.value1.boolean =3D true; =20 - dst =3D QAPI_CLONE(UserDefListUnion, src); + dst =3D QAPI_CLONE(UserDefFlatUnion, src); g_assert(dst); - g_assert_cmpint(dst->type, =3D=3D, src->type); - g_assert(!dst->u.string.data); =20 - qapi_free_UserDefListUnion(src); - qapi_free_UserDefListUnion(dst); + g_assert_cmpint(dst->integer, =3D=3D, 123); + g_assert_cmpstr(dst->string, =3D=3D, "abc"); + g_assert_cmpint(dst->enum1, =3D=3D, ENUM_ONE_VALUE1); + g_assert(dst->u.value1.boolean); + g_assert(!dst->u.value1.has_a_b); + g_assert_cmpint(dst->u.value1.a_b, =3D=3D, 0); + + qapi_free_UserDefFlatUnion(src); + qapi_free_UserDefFlatUnion(dst); } =20 static void test_clone_complex2(void) --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552542; cv=none; d=zohomail.com; s=zohoarc; b=U3gwbwC5u2RYEirF2oKoYN2Ql80IBg1yIeXjXf0zGuTQG80kyeMiK17ehUiyh0eRpekv3ctXVZ/cHw7yYmeHmYBEkxerGJ0bQqpvSyEmoG4W7BA8tIKJcH6YxgKIezVoUDK2M+Csb9H9/Zs5X6nD5HG5ntl7I84VGmxh621pPf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552542; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JiaFssF/uVu0RqB0XoXhPcX1IsaomE6B83n6l8GCUgI=; b=dNhmuFSVK4GjRksy/Vb36FEBmNhXTWM02foVd75TJ/vStwDTmuhXbg938MpMcWEIDDm8eMY995/X8YGsl1L82N3LwC79fkiHV4L/o1DmxJj9LhEOtCneFLK6yJLc+/HV99qXu16yrbR5PXVAXdtcBcOdgL3L1wcbKnRkspCEPnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552542928564.4008522761575; Fri, 24 Sep 2021 23:49:02 -0700 (PDT) Received: from localhost ([::1]:48722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Ub-0005Y9-SN for importer@patchew.org; Sat, 25 Sep 2021 02:49:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU185-0007be-AO for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54093) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007JJ-7a for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-bIzv8XgKPtmmySTMmE73Nw-1; Sat, 25 Sep 2021 02:25:36 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BB35362FC; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B238A5D9DE; Sat, 25 Sep 2021 06:25:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4BC4D11380B0; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiaFssF/uVu0RqB0XoXhPcX1IsaomE6B83n6l8GCUgI=; b=gUAMXOSv/ddpQ8MX/l9YRizUEmhMlqCP9Uzw+hfxIxhtFclmnWFDK2zRIdSXjVgiVrmrF9 rLeEcFpcozZcY4nke/djQuJmdIChoSZ2B+QIZRgnmF/rwB9C53mZjOXn4qJY/90FKduqzY u0SiHYu6vwu5+QtqUQjTIlFkVkgSSII= X-MC-Unique: bIzv8XgKPtmmySTMmE73Nw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 15/25] tests/qapi-schema: Wean off UserDefListUnion Date: Sat, 25 Sep 2021 08:25:15 +0200 Message-Id: <20210925062525.988405-16-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552543353100001 Content-Type: text/plain; charset="utf-8" Command boxed-union uses simple union UserDefListUnion to cover unions. Use UserDefFlatUnion instead. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-16-armbru@redhat.com> --- tests/unit/test-qmp-cmds.c | 2 +- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/qapi-schema-test.out | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 83efa39720..83c9ef5b7c 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -119,7 +119,7 @@ void qmp_boxed_struct(UserDefZero *arg, Error **errp) { } =20 -void qmp_boxed_union(UserDefListUnion *arg, Error **errp) +void qmp_boxed_union(UserDefFlatUnion *arg, Error **errp) { } =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index b2d795cb19..a4b4405f94 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -175,7 +175,7 @@ 'returns': 'int' } { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } -{ 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true } +{ 'command': 'boxed-union', 'data': 'UserDefFlatUnion', 'boxed': true } { 'command': 'boxed-empty', 'boxed': true, 'data': 'Empty1' } =20 # Smoke test on out-of-band and allow-preconfig-test diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 7a488c1d06..f120f10616 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -232,7 +232,7 @@ command guest-sync q_obj_guest-sync-arg -> any gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command boxed-struct UserDefZero -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse -command boxed-union UserDefListUnion -> None +command boxed-union UserDefFlatUnion -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse command boxed-empty Empty1 -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551835; cv=none; d=zohomail.com; s=zohoarc; b=ixFPaI0QF1pDU7qcwMlihp6pSD5tp/4SuCkQ6S0u7Cc34Y/idIgY3A+wpe3zGsA/3k9gKcVt/wGaKl/2HGIJN6coErrsetMvlU9Ysh3Vzdo/1ffbW9hFI0DZ0inYkNqjVv08+Q/OC21u2Z+o5+7uZsdGnvCjVBCMPA7qE3QpB9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551835; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lp4u7r2A7P3yT/jiFyYPL7YraajVC9ADbzPQ7do3JKE=; b=YBC8qzngk3lzWDQ39fI/88+ZzJ3n83NJhq68JuOyaf6CnugnDk5pIyYTiN/cd0ZZjgJbksY0i9yay+eimhcN+djfFpp4lrgHjCaolbLTYuSxfto9ae1itFo+K3hcSl4lAQkjiFMMma2kbFJ9h5oQD/wJgVGYG6FNvKwCUD5HYtg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551835063218.97064979536538; Fri, 24 Sep 2021 23:37:15 -0700 (PDT) Received: from localhost ([::1]:52258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1JB-0005IP-WA for importer@patchew.org; Sat, 25 Sep 2021 02:37:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007a3-DY for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17x-0007FZ-Ei for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-RsqexnbiORCZyEEQ3MXlJA-1; Sat, 25 Sep 2021 02:25:35 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF6441006AA3; Sat, 25 Sep 2021 06:25:33 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4C7312D4A; Sat, 25 Sep 2021 06:25:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4F15511380B7; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lp4u7r2A7P3yT/jiFyYPL7YraajVC9ADbzPQ7do3JKE=; b=NSs6ah2VjzdjrLSTWdZwTTpiLuED7FPBY/YlboxbFpmec02p40eTcODYxNdDOugKiPtWNJ 428OAIdIjaOdaiwuHkV30ojd3IvbkyYH2lV8+JcZJdihVDCIV0WuUyTuG6eK+a874JUdqO z1QLV19neM7InlhgKFx81bNvHZ2L1Zg= X-MC-Unique: RsqexnbiORCZyEEQ3MXlJA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 16/25] tests/qapi-schema: Simple union UserDefListUnion is now unused, drop Date: Sat, 25 Sep 2021 08:25:16 +0200 Message-Id: <20210925062525.988405-17-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551837239100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-17-armbru@redhat.com> --- tests/qapi-schema/qapi-schema-test.json | 17 ------- tests/qapi-schema/qapi-schema-test.out | 64 ------------------------- 2 files changed, 81 deletions(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index a4b4405f94..eae43f41c4 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -123,23 +123,6 @@ # for testing use of 'str' within alternates { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } } =20 -# for testing lists -{ 'union': 'UserDefListUnion', - 'data': { 'integer': ['int'], - 's8': ['int8'], - 's16': ['int16'], - 's32': ['int32'], - 's64': ['int64'], - 'u8': ['uint8'], - 'u16': ['uint16'], - 'u32': ['uint32'], - 'u64': ['uint64'], - 'number': ['number'], - 'boolean': ['bool'], - 'string': ['str'], - 'sizes': ['size'], - 'any': ['any'], - 'user': ['Status'] } } # intentional forward ref. to sub-module { 'struct': 'ArrayStruct', 'data': { 'integer': ['int'], 's8': ['int8'], diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index f120f10616..e43073d795 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -125,70 +125,6 @@ alternate AltStrObj tag type case s: str case o: TestStruct -object q_obj_intList-wrapper - member data: intList optional=3DFalse -object q_obj_int8List-wrapper - member data: int8List optional=3DFalse -object q_obj_int16List-wrapper - member data: int16List optional=3DFalse -object q_obj_int32List-wrapper - member data: int32List optional=3DFalse -object q_obj_int64List-wrapper - member data: int64List optional=3DFalse -object q_obj_uint8List-wrapper - member data: uint8List optional=3DFalse -object q_obj_uint16List-wrapper - member data: uint16List optional=3DFalse -object q_obj_uint32List-wrapper - member data: uint32List optional=3DFalse -object q_obj_uint64List-wrapper - member data: uint64List optional=3DFalse -object q_obj_numberList-wrapper - member data: numberList optional=3DFalse -object q_obj_boolList-wrapper - member data: boolList optional=3DFalse -object q_obj_strList-wrapper - member data: strList optional=3DFalse -object q_obj_sizeList-wrapper - member data: sizeList optional=3DFalse -object q_obj_anyList-wrapper - member data: anyList optional=3DFalse -object q_obj_StatusList-wrapper - member data: StatusList optional=3DFalse -enum UserDefListUnionKind - member integer - member s8 - member s16 - member s32 - member s64 - member u8 - member u16 - member u32 - member u64 - member number - member boolean - member string - member sizes - member any - member user -object UserDefListUnion - member type: UserDefListUnionKind optional=3DFalse - tag type - case integer: q_obj_intList-wrapper - case s8: q_obj_int8List-wrapper - case s16: q_obj_int16List-wrapper - case s32: q_obj_int32List-wrapper - case s64: q_obj_int64List-wrapper - case u8: q_obj_uint8List-wrapper - case u16: q_obj_uint16List-wrapper - case u32: q_obj_uint32List-wrapper - case u64: q_obj_uint64List-wrapper - case number: q_obj_numberList-wrapper - case boolean: q_obj_boolList-wrapper - case string: q_obj_strList-wrapper - case sizes: q_obj_sizeList-wrapper - case any: q_obj_anyList-wrapper - case user: q_obj_StatusList-wrapper object ArrayStruct member integer: intList optional=3DFalse member s8: int8List optional=3DFalse --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552003; cv=none; d=zohomail.com; s=zohoarc; b=MLbt/+OHbsCW2RMH65vsSvq7wq96GAw+74I2zZyNMyx1ANR3IPtqTZV1F4RdbzGIDE+XvSXhHimxfePbbswUoP6dVNLSpR4U02ZVPjIbcfc1rRjqG5HaQzRagUIE10kRV8/ABN/YEwgB3f45FhwPJtVhi0vHT4eEP8M8BRgQsNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552003; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GZRFRPs1pCmXQnNIp0HFzrbastWDL2VvEBNYCb7oCdA=; b=WKI8rIYMmDCYsUqXALPRBaQE6Ft4sSi3x6MHBQJzc+fTNc0rTkChUEdY+qELNQzTMiSrVs8LwRAscy8d9/fW8fzfK8BRXfIvatDmB7B3cpIBDwjbJiaVUaDqqTYumTSogLkKmoqVeFYg/J06P8Dg545iYfhLC3H9W06duOfib4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552003910413.10747115188246; Fri, 24 Sep 2021 23:40:03 -0700 (PDT) Received: from localhost ([::1]:60324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Lu-0002OJ-Ov for importer@patchew.org; Sat, 25 Sep 2021 02:40:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU187-0007eY-LN for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007K8-Db for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-yARBepesOqq873RThloXOQ-1; Sat, 25 Sep 2021 02:25:35 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32D451084681; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07B086091B; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5245E11380B9; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GZRFRPs1pCmXQnNIp0HFzrbastWDL2VvEBNYCb7oCdA=; b=EysqNoAhLH8W4hiC10se7jBsUk9rpDYBjtjZiW36f0iOhtzC8Xi0hy61b1al0865giZjf3 5ETzAhLKlacnuycGpiib7qQszAPIbdQSG1cF2samoMX/dp2pAGmzgR9DmgUdcf6Zf9DI5g 6qKADyA4y3RHBfkAsEXnFZxCqp7lmG4= X-MC-Unique: yARBepesOqq873RThloXOQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 17/25] tests/qapi-schema: Rewrite simple union TestIfUnion to be flat Date: Sat, 25 Sep 2021 08:25:17 +0200 Message-Id: <20210925062525.988405-18-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552004708100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, rewrite TestIfUnion to be flat. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-18-armbru@redhat.com> --- tests/qapi-schema/qapi-schema-test.json | 4 +++- tests/qapi-schema/qapi-schema-test.out | 16 ++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index eae43f41c4..ef17ab1aae 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -229,8 +229,10 @@ 'if': 'TEST_IF_ENUM' } =20 { 'union': 'TestIfUnion', + 'base': { 'type': 'TestIfEnum' }, + 'discriminator': 'type', 'data': { 'foo': 'TestStruct', - 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} }, + 'bar': { 'type': 'UserDefZero', 'if': 'TEST_IF_ENUM_BAR'} }, 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-union-cmd', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e43073d795..07e4161331 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -257,19 +257,15 @@ enum TestIfEnum member bar if TEST_IF_ENUM_BAR if TEST_IF_ENUM -object q_obj_TestStruct-wrapper - member data: TestStruct optional=3DFalse -enum TestIfUnionKind - member foo - member bar - if TEST_IF_UNION_BAR +object q_obj_TestIfUnion-base + member type: TestIfEnum optional=3DFalse if {'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT']} object TestIfUnion - member type: TestIfUnionKind optional=3DFalse + base q_obj_TestIfUnion-base tag type - case foo: q_obj_TestStruct-wrapper - case bar: q_obj_str-wrapper - if TEST_IF_UNION_BAR + case foo: TestStruct + case bar: UserDefZero + if TEST_IF_ENUM_BAR if {'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT']} object q_obj_test-if-union-cmd-arg member union-cmd-arg: TestIfUnion optional=3DFalse --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552709; cv=none; d=zohomail.com; s=zohoarc; b=Msob+kv4Hp/6pJJdxovGn/Mvpi7Qv9umBF46fpik0Qa9HJN11I2+rQ8uVVcmGzkidXOUeZacCLpPPlPVTXRSXqZPt2YSezNKskZaFqayZx7g0vl8ROwKqGuiKCVp7xZX38PNdLv5pq0AMWviCCUTdtEsONy1ecN1t/iKRgIpOcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552709; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ups1L4r4vr298+cwSmkUAYzRSDFIKAmpPsWktfvFTj8=; b=lyf4Ey8AXj+JUypZh1BxsAuvljAAuOdTE8RWAxn+Nk7x8DrmHW+QVI2c4DzsXWHkpva9C08K4u8mS+FfQr6QCn1gQaAAQmNXdNLGd2+OH6LJ5by1lCQ19XSb8xThGfo+UQgHwdcxIHtrdW8XM1hs/UQGDLqyBHrax0KvydxKyjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552709658820.2903658844765; Fri, 24 Sep 2021 23:51:49 -0700 (PDT) Received: from localhost ([::1]:55062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1XI-0001VA-FT for importer@patchew.org; Sat, 25 Sep 2021 02:51:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU187-0007eB-J1 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17y-0007Fm-Lb for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-lzCJ0_jtPU6--mf9ls4-FA-1; Sat, 25 Sep 2021 02:25:35 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37268362F9; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0BCE960936; Sat, 25 Sep 2021 06:25:34 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 559F711380BC; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ups1L4r4vr298+cwSmkUAYzRSDFIKAmpPsWktfvFTj8=; b=g6pLuHTJWgYwI6r+VN8iItpjWUPk2tQBSJjDy30R2SXBw17myzrMalPxozokMlxtv8reix s40ZMh32uaMP9aF5Zl/6/UPKn+FdhYiw1jPXrXu0mhk5hDdNeg+xRbxbB+fQRNGuamdRnG vWZSluZ7YmxYCuDFTKg+vk3YekWqCf0= X-MC-Unique: lzCJ0_jtPU6--mf9ls4-FA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 18/25] test-clone-visitor: Wean off __org.qemu_x-Union1 Date: Sat, 25 Sep 2021 08:25:18 +0200 Message-Id: <20210925062525.988405-19-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552710372100001 Content-Type: text/plain; charset="utf-8" test_clone_complex3() uses simple union __org.qemu_x-Union1 to cover arrays. Use UserDefOneList instead. Unions are still covered by test_clone_complex1(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-19-armbru@redhat.com> --- tests/unit/test-clone-visitor.c | 70 ++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/tests/unit/test-clone-visitor.c b/tests/unit/test-clone-visito= r.c index 8357a90e60..4048018607 100644 --- a/tests/unit/test-clone-visitor.c +++ b/tests/unit/test-clone-visitor.c @@ -153,42 +153,48 @@ static void test_clone_complex2(void) =20 static void test_clone_complex3(void) { - __org_qemu_x_Struct2 *src, *dst; - __org_qemu_x_Union1List *tmp; + UserDefOneList *src, *dst, *tail; + UserDefOne *elt; =20 - src =3D g_new0(__org_qemu_x_Struct2, 1); - tmp =3D src->array =3D g_new0(__org_qemu_x_Union1List, 1); - tmp->value =3D g_new0(__org_qemu_x_Union1, 1); - tmp->value->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - tmp->value->u.__org_qemu_x_branch.data =3D g_strdup("one"); - tmp =3D tmp->next =3D g_new0(__org_qemu_x_Union1List, 1); - tmp->value =3D g_new0(__org_qemu_x_Union1, 1); - tmp->value->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - tmp->value->u.__org_qemu_x_branch.data =3D g_strdup("two"); - tmp =3D tmp->next =3D g_new0(__org_qemu_x_Union1List, 1); - tmp->value =3D g_new0(__org_qemu_x_Union1, 1); - tmp->value->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - tmp->value->u.__org_qemu_x_branch.data =3D g_strdup("three"); + src =3D NULL; + elt =3D g_new0(UserDefOne, 1); + elt->integer =3D 3; + elt->string =3D g_strdup("three"); + elt->has_enum1 =3D true; + elt->enum1 =3D ENUM_ONE_VALUE3; + QAPI_LIST_PREPEND(src, elt); + elt =3D g_new0(UserDefOne, 1); + elt->integer =3D 2; + elt->string =3D g_strdup("two"); + QAPI_LIST_PREPEND(src, elt); + elt =3D g_new0(UserDefOne, 1); + elt->integer =3D 1; + elt->string =3D g_strdup("one"); + QAPI_LIST_PREPEND(src, elt); + + dst =3D QAPI_CLONE(UserDefOneList, src); =20 - dst =3D QAPI_CLONE(__org_qemu_x_Struct2, src); g_assert(dst); - tmp =3D dst->array; - g_assert(tmp); - g_assert(tmp->value); - g_assert_cmpstr(tmp->value->u.__org_qemu_x_branch.data, =3D=3D, "one"); - tmp =3D tmp->next; - g_assert(tmp); - g_assert(tmp->value); - g_assert_cmpstr(tmp->value->u.__org_qemu_x_branch.data, =3D=3D, "two"); - tmp =3D tmp->next; - g_assert(tmp); - g_assert(tmp->value); - g_assert_cmpstr(tmp->value->u.__org_qemu_x_branch.data, =3D=3D, "three= "); - tmp =3D tmp->next; - g_assert(!tmp); + tail =3D dst; + elt =3D tail->value; + g_assert_cmpint(elt->integer, =3D=3D, 1); + g_assert_cmpstr(elt->string, =3D=3D, "one"); + g_assert(!elt->has_enum1); + tail =3D tail->next; + elt =3D tail->value; + g_assert_cmpint(elt->integer, =3D=3D, 2); + g_assert_cmpstr(elt->string, =3D=3D, "two"); + g_assert(!elt->has_enum1); + tail =3D tail->next; + elt =3D tail->value; + g_assert_cmpint(elt->integer, =3D=3D, 3); + g_assert_cmpstr(elt->string, =3D=3D, "three"); + g_assert(elt->has_enum1); + g_assert_cmpint(elt->enum1, =3D=3D, ENUM_ONE_VALUE3); + g_assert(!tail->next); =20 - qapi_free___org_qemu_x_Struct2(src); - qapi_free___org_qemu_x_Struct2(dst); + qapi_free_UserDefOneList(src); + qapi_free_UserDefOneList(dst); } =20 int main(int argc, char **argv) --=20 2.31.1 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552994; cv=none; d=zohomail.com; s=zohoarc; b=TkdmfjpMgoYas3VvLofdhYG1HA4WXuaUHEyjed3EOgnNG/KxSBxKkD25xfaVExcwa1QYGw08UcxPJGbnJQ6b2mQfQwcYVk+8gVIBWGFlJmhO9681VIkLBHMv/kBvmESf/Fz2HjunHw+KVywxkMO/z/p3fpaX/oUKv9iQwAhKdPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552994; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=weyYZfucGiF64O4W9klgiTmYJQUzYM1zB2uRvK+hDwc=; b=ivb8SzPy7YMc9OgEcBtBjaGWh8FDDcE1/AzI9jOjY3Su938zMbVHNo3Da6ylDoD74KYl2cY0O+jDYSg8h6DeC19j5anEO4JpxYuoYLk4Um1JexY5Z19IKFIktmCet2tyAohd59iXnwKE0Yd7+h0tqzvyE4IvYtnNnZ7/bzWIwX0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552994656376.8828175310107; Fri, 24 Sep 2021 23:56:34 -0700 (PDT) Received: from localhost ([::1]:36034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1bt-0007gW-JF for importer@patchew.org; Sat, 25 Sep 2021 02:56:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU18C-0007k0-KR for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007Lq-77 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-_WzeMmRvMK-pTTYke80spQ-1; Sat, 25 Sep 2021 02:25:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C60E362FD; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C2DB5FC25; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5914311380CC; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=weyYZfucGiF64O4W9klgiTmYJQUzYM1zB2uRvK+hDwc=; b=hRN5h9ulywzjgSjCVoCpv0iDMUy1VX6VPHgsUw2ZZRUDkAC7ihjXt1Y7SF0jdB0K9C+Yfo xJ5gozlvE+o2Vugnys34mTKP2vm/7422KJgi+J/MszRNRof/jaKbxF9QWrCvAHpwYmv1Le ltgzVxJoQCT9gnTDNL8wra7hed1hnZM= X-MC-Unique: _WzeMmRvMK-pTTYke80spQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 19/25] tests/qapi-schema: Drop simple union __org.qemu_x-Union1 Date: Sat, 25 Sep 2021 08:25:19 +0200 Message-Id: <20210925062525.988405-20-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552995869100001 Content-Type: text/plain; charset="utf-8" Replace simple union __org.qemu_x-Union1 with flat union __org.qemu_x-Union2, except drop it from __org.qemu_x-command, because there it's only used to pull it into QMP. Now drop the unused -Union1, and rename -Union2 to -Union. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-20-armbru@redhat.com> --- tests/unit/test-qmp-cmds.c | 16 +++++----------- tests/qapi-schema/qapi-schema-test.json | 8 +++----- tests/qapi-schema/qapi-schema-test.out | 18 +++++------------- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 83c9ef5b7c..faa858624a 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -127,22 +127,16 @@ void qmp_boxed_empty(Empty1 *arg, Error **errp) { } =20 -__org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, - __org_qemu_x_StructList *b, - __org_qemu_x_Union2 *c, - __org_qemu_x_Alt *d, - Error **errp) +void qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, + __org_qemu_x_StructList *b, + __org_qemu_x_Union *c, + __org_qemu_x_Alt *d, + Error **errp) { - __org_qemu_x_Union1 *ret =3D g_new0(__org_qemu_x_Union1, 1); - - ret->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - ret->u.__org_qemu_x_branch.data =3D strdup("blah1"); - /* Also test that 'wchar-t' was munged to 'q_wchar_t' */ if (b && b->value && !b->value->has_q_wchar_t) { b->value->q_wchar_t =3D 1; } - return ret; } =20 =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index ef17ab1aae..20f4cc0cfa 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -202,11 +202,10 @@ 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } } { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base', 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } } -{ 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' }= } { 'alternate': '__org.qemu_x-Alt1', 'data': { '__org.qemu_x-branch': 'str'= } } { 'struct': '__org.qemu_x-Struct2', - 'data': { 'array': ['__org.qemu_x-Union1'] } } -{ 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base', + 'data': { 'array': ['__org.qemu_x-Union'] } } +{ 'union': '__org.qemu_x-Union', 'base': '__org.qemu_x-Base', 'discriminator': '__org.qemu_x-member1', 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } } { 'alternate': '__org.qemu_x-Alt', @@ -214,8 +213,7 @@ { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' } { 'command': '__org.qemu_x-command', 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'], - 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' }, - 'returns': '__org.qemu_x-Union1' } + 'c': '__org.qemu_x-Union', 'd': '__org.qemu_x-Alt' } } =20 # test 'if' condition handling =20 diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 07e4161331..9337adc9ea 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -215,21 +215,13 @@ object __org.qemu_x-Struct base __org.qemu_x-Base member __org.qemu_x-member2: str optional=3DFalse member wchar-t: int optional=3DTrue -object q_obj_str-wrapper - member data: str optional=3DFalse -enum __org.qemu_x-Union1Kind - member __org.qemu_x-branch -object __org.qemu_x-Union1 - member type: __org.qemu_x-Union1Kind optional=3DFalse - tag type - case __org.qemu_x-branch: q_obj_str-wrapper alternate __org.qemu_x-Alt1 tag type case __org.qemu_x-branch: str -array __org.qemu_x-Union1List __org.qemu_x-Union1 +array __org.qemu_x-UnionList __org.qemu_x-Union object __org.qemu_x-Struct2 - member array: __org.qemu_x-Union1List optional=3DFalse -object __org.qemu_x-Union2 + member array: __org.qemu_x-UnionList optional=3DFalse +object __org.qemu_x-Union base __org.qemu_x-Base tag __org.qemu_x-member1 case __org.qemu_x-value: __org.qemu_x-Struct2 @@ -243,9 +235,9 @@ array __org.qemu_x-StructList __org.qemu_x-Struct object q_obj___org.qemu_x-command-arg member a: __org.qemu_x-EnumList optional=3DFalse member b: __org.qemu_x-StructList optional=3DFalse - member c: __org.qemu_x-Union2 optional=3DFalse + member c: __org.qemu_x-Union optional=3DFalse member d: __org.qemu_x-Alt optional=3DFalse -command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 +command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse object TestIfStruct member foo: int optional=3DFalse --=20 2.31.1 From nobody Fri May 17 11:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552542; cv=none; d=zohomail.com; s=zohoarc; b=cemlvagiuvIXYK4pmMcAc5ReqHvJnFS1WTHZDR2Mw2FoRkNxMvkmLujbV4Ty4FD+edPWMFtR1eBLqtdLSrt73hRZpTO1tY9bLii3ODRJFrBpfQMO/EB5djwGtBc9vhCuWXCnz54oiVEWOiwtpeqrxe3pU/gG+mm0nxT3dce2Urs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552542; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qlInneeaEwdG37m6yDyKp8P6gintWIkwEbVZ7il2UiI=; b=JRtPnofPA8zYnrIRumfJAnLNrUxVNCg59akiTaqshQc4QyQqX6wxV890Cw4eRDjLFRqsSkC/5xAcUEhbD2ytQddBUQtngu7A0nDIrbzDrFpyFteyMyAt4M+qa3cJm8PtmGpywKGPiqfhU6812PN0CDdEHrlZeW9gvTDiweCbb7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552542325683.652934810836; Fri, 24 Sep 2021 23:49:02 -0700 (PDT) Received: from localhost ([::1]:48622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Ub-0005UF-59 for importer@patchew.org; Sat, 25 Sep 2021 02:49:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU188-0007fT-Jf for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU17z-0007K4-DS for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-O29CO0CgNRatHuInyYbt4g-1; Sat, 25 Sep 2021 02:25:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B3A6362FE; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26C9E12D4A; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5D57A11380D0; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qlInneeaEwdG37m6yDyKp8P6gintWIkwEbVZ7il2UiI=; b=W5qrwOQxzu4/6gLuTXYpbTha9fo3+gDadMT16sBPMoAp1Kp1ost0EqpG6qzTUCZ0e4401p x1fTfyUEiFBjEoQXsKCl+quMj5OY/Y508oCSK7OEVMHnVN6qqzp6xuRx3UywZa00biuhHQ rm6BlZsZzvv51JQZAxySpebPjm9myek= X-MC-Unique: O29CO0CgNRatHuInyYbt4g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 20/25] tests/qapi-schema: Purge simple unions from tests Date: Sat, 25 Sep 2021 08:25:20 +0200 Message-Id: <20210925062525.988405-21-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, WEIRD_QUOTING=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552543356100002 Content-Type: text/plain; charset="utf-8" Drop tests that are specifically about simple unions: * SugaredUnion in doc-good: flat unions are covered by @Object. * union-branch-case and union-clash-branches: branch naming for flat unions is enforced for the tag enum instead, which is covered by enum-member-case and enum-clash-member. * union-empty: empty flat unions are covered by flat-union-empty. Rewrite the remainder to use flat unions: args-union, bad-base, flat-union-base-union, union-branch-invalid-dict, union-unknown. Except drop union-optional-branch. because converting this one is not worth the trouble; we don't explicitly check names beginning with '*' in other places, either. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-21-armbru@redhat.com> --- tests/qapi-schema/args-union.err | 2 +- tests/qapi-schema/args-union.json | 8 ++++++- tests/qapi-schema/bad-base.err | 2 +- tests/qapi-schema/bad-base.json | 8 ++++++- tests/qapi-schema/doc-good.json | 9 -------- tests/qapi-schema/doc-good.out | 22 ------------------- tests/qapi-schema/doc-good.txt | 20 ----------------- tests/qapi-schema/flat-union-base-union.err | 2 +- tests/qapi-schema/flat-union-base-union.json | 3 +++ tests/qapi-schema/meson.build | 4 ---- tests/qapi-schema/union-branch-case.err | 2 -- tests/qapi-schema/union-branch-case.json | 2 -- tests/qapi-schema/union-branch-case.out | 0 .../qapi-schema/union-branch-invalid-dict.err | 2 +- .../union-branch-invalid-dict.json | 4 ++++ tests/qapi-schema/union-clash-branches.err | 2 -- tests/qapi-schema/union-clash-branches.json | 7 ------ tests/qapi-schema/union-clash-branches.out | 0 tests/qapi-schema/union-empty.err | 2 -- tests/qapi-schema/union-empty.json | 2 -- tests/qapi-schema/union-empty.out | 0 tests/qapi-schema/union-optional-branch.err | 2 -- tests/qapi-schema/union-optional-branch.json | 2 -- tests/qapi-schema/union-optional-branch.out | 0 tests/qapi-schema/union-unknown.err | 2 +- tests/qapi-schema/union-unknown.json | 5 ++++- 26 files changed, 30 insertions(+), 84 deletions(-) delete mode 100644 tests/qapi-schema/union-branch-case.err delete mode 100644 tests/qapi-schema/union-branch-case.json delete mode 100644 tests/qapi-schema/union-branch-case.out delete mode 100644 tests/qapi-schema/union-clash-branches.err delete mode 100644 tests/qapi-schema/union-clash-branches.json delete mode 100644 tests/qapi-schema/union-clash-branches.out delete mode 100644 tests/qapi-schema/union-empty.err delete mode 100644 tests/qapi-schema/union-empty.json delete mode 100644 tests/qapi-schema/union-empty.out delete mode 100644 tests/qapi-schema/union-optional-branch.err delete mode 100644 tests/qapi-schema/union-optional-branch.json delete mode 100644 tests/qapi-schema/union-optional-branch.out diff --git a/tests/qapi-schema/args-union.err b/tests/qapi-schema/args-unio= n.err index 4bf4955027..4b80a99f74 100644 --- a/tests/qapi-schema/args-union.err +++ b/tests/qapi-schema/args-union.err @@ -1,2 +1,2 @@ args-union.json: In command 'oops': -args-union.json:3: command's 'data' can take union type 'Uni' only with 'b= oxed': true +args-union.json:9: command's 'data' can take union type 'Uni' only with 'b= oxed': true diff --git a/tests/qapi-schema/args-union.json b/tests/qapi-schema/args-uni= on.json index 2fcaeaae16..aabb159063 100644 --- a/tests/qapi-schema/args-union.json +++ b/tests/qapi-schema/args-union.json @@ -1,3 +1,9 @@ # use of union arguments requires 'boxed':true -{ 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } } +{ 'enum': 'Enum', 'data': [ 'case1', 'case2' ] } +{ 'struct': 'Case1', 'data': { 'data': 'int' } } +{ 'struct': 'Case2', 'data': { 'data': 'str' } } +{ 'union': 'Uni', + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', + 'data': { 'case1': 'Case1', 'case2': 'Case2' } } { 'command': 'oops', 'data': 'Uni' } diff --git a/tests/qapi-schema/bad-base.err b/tests/qapi-schema/bad-base.err index 61a1efc2c0..1fad63e392 100644 --- a/tests/qapi-schema/bad-base.err +++ b/tests/qapi-schema/bad-base.err @@ -1,2 +1,2 @@ bad-base.json: In struct 'MyType': -bad-base.json:3: 'base' requires a struct type, union type 'Union' isn't +bad-base.json:9: 'base' requires a struct type, union type 'Union' isn't diff --git a/tests/qapi-schema/bad-base.json b/tests/qapi-schema/bad-base.j= son index a634331cdd..8c773ff544 100644 --- a/tests/qapi-schema/bad-base.json +++ b/tests/qapi-schema/bad-base.json @@ -1,3 +1,9 @@ # we reject a base that is not a struct -{ 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } } +{ 'enum': 'Enum', 'data': [ 'a', 'b' ] } +{ 'struct': 'Int', 'data': { 'data': 'int' } } +{ 'struct': 'Str', 'data': { 'data': 'str' } } +{ 'union': 'Union', + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', + 'data': { 'a': 'Int', 'b': 'Str' } } { 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } } diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index cbf5c56c4b..a20acffd8b 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -107,15 +107,6 @@ 'two': { 'type': 'Variant2', 'if': { 'any': ['IFONE', 'IFTWO'] } } } } =20 -## -# @SugaredUnion: -# Features: -# @union-feat2: a feature -## -{ 'union': 'SugaredUnion', - 'features': [ 'union-feat2' ], - 'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' = } } } - ## # @Alternate: # @i: an integer diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 478fe6f82e..5a324e2627 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -32,21 +32,6 @@ object Object case two: Variant2 if {'any': ['IFONE', 'IFTWO']} feature union-feat1 -object q_obj_Variant1-wrapper - member data: Variant1 optional=3DFalse -object q_obj_Variant2-wrapper - member data: Variant2 optional=3DFalse -enum SugaredUnionKind - member one - member two - if IFTWO -object SugaredUnion - member type: SugaredUnionKind optional=3DFalse - tag type - case one: q_obj_Variant1-wrapper - case two: q_obj_Variant2-wrapper - if IFTWO - feature union-feat2 alternate Alternate tag type case i: int @@ -149,13 +134,6 @@ doc symbol=3DObject =20 feature=3Dunion-feat1 a feature -doc symbol=3DSugaredUnion - body=3D - - arg=3Dtype - - feature=3Dunion-feat2 -a feature doc symbol=3DAlternate body=3D =20 diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 0c59d75964..701402ee5e 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -130,26 +130,6 @@ Features a feature =20 =20 -"SugaredUnion" (Object) ------------------------ - - -Members -~~~~~~~ - -"type" - One of "one", "two" - -"data": "Variant1" when "type" is ""one"" -"data": "Variant2" when "type" is ""two"" (**If: **"IFTWO") - -Features -~~~~~~~~ - -"union-feat2" - a feature - - "Alternate" (Alternate) ----------------------- =20 diff --git a/tests/qapi-schema/flat-union-base-union.err b/tests/qapi-schem= a/flat-union-base-union.err index 3b0087220e..3563e8777e 100644 --- a/tests/qapi-schema/flat-union-base-union.err +++ b/tests/qapi-schema/flat-union-base-union.err @@ -1,2 +1,2 @@ flat-union-base-union.json: In union 'TestUnion': -flat-union-base-union.json:14: 'base' requires a struct type, union type '= UnionBase' isn't +flat-union-base-union.json:17: 'base' requires a struct type, union type '= UnionBase' isn't diff --git a/tests/qapi-schema/flat-union-base-union.json b/tests/qapi-sche= ma/flat-union-base-union.json index 98b4eba181..82d4c96e57 100644 --- a/tests/qapi-schema/flat-union-base-union.json +++ b/tests/qapi-schema/flat-union-base-union.json @@ -8,7 +8,10 @@ 'data': { 'string': 'str' } } { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +{ 'enum': 'Enum', 'data': [ 'kind1', 'kind2' ] } { 'union': 'UnionBase', + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', 'data': { 'kind1': 'TestTypeA', 'kind2': 'TestTypeB' } } { 'union': 'TestUnion', diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 0798e94042..85d3de1481 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -192,14 +192,10 @@ schemas =3D [ 'unclosed-string.json', 'union-base-empty.json', 'union-base-no-discriminator.json', - 'union-branch-case.json', 'union-branch-if-invalid.json', 'union-branch-invalid-dict.json', - 'union-clash-branches.json', - 'union-empty.json', 'union-invalid-base.json', 'union-invalid-data.json', - 'union-optional-branch.json', 'union-unknown.json', 'unknown-escape.json', 'unknown-expr-key.json', diff --git a/tests/qapi-schema/union-branch-case.err b/tests/qapi-schema/un= ion-branch-case.err deleted file mode 100644 index d2d5cb8993..0000000000 --- a/tests/qapi-schema/union-branch-case.err +++ /dev/null @@ -1,2 +0,0 @@ -union-branch-case.json: In union 'Uni': -union-branch-case.json:2: name of 'data' member 'Branch' must not use uppe= rcase or '_' diff --git a/tests/qapi-schema/union-branch-case.json b/tests/qapi-schema/u= nion-branch-case.json deleted file mode 100644 index b7894b75d6..0000000000 --- a/tests/qapi-schema/union-branch-case.json +++ /dev/null @@ -1,2 +0,0 @@ -# Branch names should be 'lower-case' -{ 'union': 'Uni', 'data': { 'Branch': 'int' } } diff --git a/tests/qapi-schema/union-branch-case.out b/tests/qapi-schema/un= ion-branch-case.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-branch-invalid-dict.err b/tests/qapi-s= chema/union-branch-invalid-dict.err index 8137c5a767..001cdec069 100644 --- a/tests/qapi-schema/union-branch-invalid-dict.err +++ b/tests/qapi-schema/union-branch-invalid-dict.err @@ -1,2 +1,2 @@ union-branch-invalid-dict.json: In union 'UnionInvalidBranch': -union-branch-invalid-dict.json:2: 'data' member 'integer' misses key 'type' +union-branch-invalid-dict.json:4: 'data' member 'integer' misses key 'type' diff --git a/tests/qapi-schema/union-branch-invalid-dict.json b/tests/qapi-= schema/union-branch-invalid-dict.json index 9778598dbd..c7c81c0e00 100644 --- a/tests/qapi-schema/union-branch-invalid-dict.json +++ b/tests/qapi-schema/union-branch-invalid-dict.json @@ -1,4 +1,8 @@ # Long form of member must have a value member 'type' +{ 'enum': 'TestEnum', + 'data': [ 'integer', 's8' ] } { 'union': 'UnionInvalidBranch', + 'base': { 'type': 'TestEnum' }, + 'discriminator': 'type', 'data': { 'integer': { 'if': 'foo'}, 's8': 'int8' } } diff --git a/tests/qapi-schema/union-clash-branches.err b/tests/qapi-schema= /union-clash-branches.err deleted file mode 100644 index ef53645728..0000000000 --- a/tests/qapi-schema/union-clash-branches.err +++ /dev/null @@ -1,2 +0,0 @@ -union-clash-branches.json: In union 'TestUnion': -union-clash-branches.json:6: name of 'data' member 'a_b' must not use uppe= rcase or '_' diff --git a/tests/qapi-schema/union-clash-branches.json b/tests/qapi-schem= a/union-clash-branches.json deleted file mode 100644 index 7bdda0b0da..0000000000 --- a/tests/qapi-schema/union-clash-branches.json +++ /dev/null @@ -1,7 +0,0 @@ -# Union branch name collision -# Naming rules make collision impossible (even with the pragma). If -# that wasn't the case, then we'd get collisions in generated C: two -# union members a_b, and two enum members TEST_UNION_A_B. -{ 'pragma': { 'member-name-exceptions': [ 'TestUnion' ] } } -{ 'union': 'TestUnion', - 'data': { 'a-b': 'int', 'a_b': 'str' } } diff --git a/tests/qapi-schema/union-clash-branches.out b/tests/qapi-schema= /union-clash-branches.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-empty.err b/tests/qapi-schema/union-em= pty.err deleted file mode 100644 index 59788c94ce..0000000000 --- a/tests/qapi-schema/union-empty.err +++ /dev/null @@ -1,2 +0,0 @@ -union-empty.json: In union 'Union': -union-empty.json:2: union has no branches diff --git a/tests/qapi-schema/union-empty.json b/tests/qapi-schema/union-e= mpty.json deleted file mode 100644 index df3e5e639a..0000000000 --- a/tests/qapi-schema/union-empty.json +++ /dev/null @@ -1,2 +0,0 @@ -# simple unions cannot be empty -{ 'union': 'Union', 'data': { } } diff --git a/tests/qapi-schema/union-empty.out b/tests/qapi-schema/union-em= pty.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-optional-branch.err b/tests/qapi-schem= a/union-optional-branch.err deleted file mode 100644 index b33f111de4..0000000000 --- a/tests/qapi-schema/union-optional-branch.err +++ /dev/null @@ -1,2 +0,0 @@ -union-optional-branch.json: In union 'Union': -union-optional-branch.json:2: 'data' member '*a' has an invalid name diff --git a/tests/qapi-schema/union-optional-branch.json b/tests/qapi-sche= ma/union-optional-branch.json deleted file mode 100644 index 591615fc68..0000000000 --- a/tests/qapi-schema/union-optional-branch.json +++ /dev/null @@ -1,2 +0,0 @@ -# union branches cannot be optional -{ 'union': 'Union', 'data': { '*a': 'int', 'b': 'str' } } diff --git a/tests/qapi-schema/union-optional-branch.out b/tests/qapi-schem= a/union-optional-branch.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-unknown.err b/tests/qapi-schema/union-= unknown.err index 7aba9f94da..dad79beae0 100644 --- a/tests/qapi-schema/union-unknown.err +++ b/tests/qapi-schema/union-unknown.err @@ -1,2 +1,2 @@ union-unknown.json: In union 'Union': -union-unknown.json:2: union uses unknown type 'MissingType' +union-unknown.json:3: branch 'unknown' uses unknown type 'MissingType' diff --git a/tests/qapi-schema/union-unknown.json b/tests/qapi-schema/union= -unknown.json index 64d3666176..4736f1ab08 100644 --- a/tests/qapi-schema/union-unknown.json +++ b/tests/qapi-schema/union-unknown.json @@ -1,3 +1,6 @@ # we reject a union with unknown type in branch +{ 'enum': 'Enum', 'data': [ 'unknown' ] } { 'union': 'Union', - 'data': { 'unknown': ['MissingType'] } } + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', + 'data': { 'unknown': 'MissingType' } } --=20 2.31.1 From nobody Fri May 17 11:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551958; cv=none; d=zohomail.com; s=zohoarc; b=EIBBppTLRZYZ0Gx5qnlzNvanoJArU3/ZHYV+xW3AxXyEfboIm/v73GwgxeNGOzdIRfqvBKTmh2qr7JCulNHF+zZ4uS3GfgAKPhrcy2yDTGFmXqn4mDwmx/ECQRnt1hBV+50SfFAB7sgHvyycLZZld1gRMHKz7rmuYAp8apLIQ/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551958; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I6BMwo9SZ8lwwKx4B+3dxIkoseSUSDVt6RtYDrNb7Dw=; b=M3imas+YPJmET+s+cjZ5nvSZw1yeHRlTKrdB3XrKq9uUemo6Ijy6gmHwb4Src7PJDYGHf2PoDHpkTG8q+sST4i4tub1wpFKGxYh2jX10ogQLZnd3sZ7kogAnTosc2Ot1HlVqSrsAv12beePEBy04Nhd9fjhybcYzlFvDg/o3STc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551958587789.8011790742406; Fri, 24 Sep 2021 23:39:18 -0700 (PDT) Received: from localhost ([::1]:58394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1LB-00014t-7u for importer@patchew.org; Sat, 25 Sep 2021 02:39:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU18D-0007lf-VY for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU185-0007RE-24 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406-K1pmZNYrMUiCuVd0m6Ihaw-1; Sat, 25 Sep 2021 02:25:36 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC5678145E6; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63EAE19D9F; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6117C11380D5; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I6BMwo9SZ8lwwKx4B+3dxIkoseSUSDVt6RtYDrNb7Dw=; b=MQrmlmbr6sBJgkoTUbXJwUV6pISfgfDTcLMkV5jY7OWMo+pTQ0vRi7xu0i/hfMkzkELLuy 3R/zC2f3GW/m2pUmuSa+NHWzjhbOrSQY2oFtqSQZjqPxdTGxjwK0Fmrjsvn+T0YiffWOs+ GAuYbBwG5PQsof7gC0qU7KsRuWytlA0= X-MC-Unique: K1pmZNYrMUiCuVd0m6Ihaw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 21/25] qapi: Drop simple unions Date: Sat, 25 Sep 2021 08:25:21 +0200 Message-Id: <20210925062525.988405-22-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551960649100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. The previous commits eliminated simple union from the tree. Now drop them from the QAPI schema language entirely, and update mentions of "flat union" to just "union". Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-22-armbru@redhat.com> --- docs/devel/qapi-code-gen.rst | 125 ++++-------------- scripts/qapi/expr.py | 21 +-- scripts/qapi/schema.py | 101 +++----------- .../qapi-schema/flat-union-array-branch.json | 2 +- tests/qapi-schema/flat-union-empty.json | 2 +- tests/qapi-schema/flat-union-int-branch.json | 2 +- tests/qapi-schema/flat-union-no-base.err | 2 +- tests/qapi-schema/flat-union-no-base.json | 2 +- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/reserved-member-u.json | 2 +- tests/qapi-schema/union-base-empty.json | 2 +- .../union-base-no-discriminator.err | 2 +- .../union-base-no-discriminator.json | 2 +- 13 files changed, 62 insertions(+), 205 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index b154eae82e..b2569de486 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -319,13 +319,9 @@ Union types Syntax:: =20 UNION =3D { 'union': STRING, - 'data': BRANCHES, - '*if': COND, - '*features': FEATURES } - | { 'union': STRING, - 'data': BRANCHES, 'base': ( MEMBERS | STRING ), 'discriminator': STRING, + 'data': BRANCHES, '*if': COND, '*features': FEATURES } BRANCHES =3D { BRANCH, ... } @@ -334,63 +330,30 @@ Syntax:: =20 Member 'union' names the union type. =20 -There are two flavors of union types: simple (no discriminator or -base), and flat (both discriminator and base). - -Each BRANCH of the 'data' object defines a branch of the union. A -union must have at least one branch. - -The BRANCH's STRING name is the branch name. - -The BRANCH's value defines the branch's properties, in particular its -type. The form TYPE-REF_ is shorthand for :code:`{ 'type': TYPE-REF }`. - -A simple union type defines a mapping from automatic discriminator -values to data types like in this example:: - - { 'struct': 'BlockdevOptionsFile', 'data': { 'filename': 'str' } } - { 'struct': 'BlockdevOptionsQcow2', - 'data': { 'backing': 'str', '*lazy-refcounts': 'bool' } } - - { 'union': 'BlockdevOptionsSimple', - 'data': { 'file': 'BlockdevOptionsFile', - 'qcow2': 'BlockdevOptionsQcow2' } } - -In the Client JSON Protocol, a simple union is represented by an -object that contains the 'type' member as a discriminator, and a -'data' member that is of the specified data type corresponding to the -discriminator value, as in these examples:: - - { "type": "file", "data": { "filename": "/some/place/my-image" } } - { "type": "qcow2", "data": { "backing": "/some/place/my-image", - "lazy-refcounts": true } } - -The generated C code uses a struct containing a union. Additionally, -an implicit C enum 'NameKind' is created, corresponding to the union -'Name', for accessing the various branches of the union. The value -for each branch can be of any type. - -Flat unions permit arbitrary common members that occur in all variants -of the union, not just a discriminator. Their discriminators need not -be named 'type'. They also avoid nesting on the wire. - The 'base' member defines the common members. If it is a MEMBERS_ object, it defines common members just like a struct type's 'data' member defines struct type members. If it is a STRING, it names a struct type whose members are the common members. =20 -All flat union branches must be `Struct types`_. +Member 'discriminator' must name a non-optional enum-typed member of +the base struct. That member's value selects a branch by its name. +If no such branch exists, an empty branch is assumed. =20 -In the Client JSON Protocol, a flat union is represented by an object -with the common members (from the base type) and the selected branch's -members. The two sets of member names must be disjoint. Member -'discriminator' must name a non-optional enum-typed member of the base -struct. +Each BRANCH of the 'data' object defines a branch of the union. A +union must have at least one branch. =20 -The following example enhances the above simple union example by -adding an optional common member 'read-only', renaming the -discriminator to something more applicable than the simple union's -default of 'type', and reducing the number of ``{}`` required on the wire:: +The BRANCH's STRING name is the branch name. It must be a value of +the discriminator enum type. + +The BRANCH's value defines the branch's properties, in particular its +type. The type must a struct type. The form TYPE-REF_ is shorthand +for :code:`{ 'type': TYPE-REF }`. + +In the Client JSON Protocol, a union is represented by an object with +the common members (from the base type) and the selected branch's +members. The two sets of member names must be disjoint. + +Example:: =20 { 'enum': 'BlockdevDriver', 'data': [ 'file', 'qcow2' ] } { 'union': 'BlockdevOptions', @@ -406,30 +369,11 @@ Resulting in these JSON objects:: { "driver": "qcow2", "read-only": false, "backing": "/some/place/my-image", "lazy-refcounts": true } =20 -Notice that in a flat union, the discriminator name is controlled by -the user, but because it must map to a base member with enum type, the -code generator ensures that branches match the existing values of the -enum. The order of branches need not match the order of the enum -values. The branches need not cover all possible enum values. -Omitted enum values are still valid branches that add no additional -members to the data type. In the resulting generated C data types, a -flat union is represented as a struct with the base members in QAPI -schema order, and then a union of structures for each branch of the -struct. - -A simple union can always be re-written as a flat union where the base -class has a single member named 'type', and where each branch of the -union has a struct with a single member named 'data'. That is, :: - - { 'union': 'Simple', 'data': { 'one': 'str', 'two': 'int' } } - -is identical on the wire to:: - - { 'enum': 'Enum', 'data': ['one', 'two'] } - { 'struct': 'Branch1', 'data': { 'data': 'str' } } - { 'struct': 'Branch2', 'data': { 'data': 'int' } } - { 'union': 'Flat', 'base': { 'type': 'Enum' }, 'discriminator': 'type', - 'data': { 'one': 'Branch1', 'two': 'Branch2' } } +The order of branches need not match the order of the enum values. +The branches need not cover all possible enum values. In the +resulting generated C data types, a union is represented as a struct +with the base members in QAPI schema order, and then a union of +structures for each branch of the struct. =20 The optional 'if' member specifies a conditional. See `Configuring the schema`_ below for more on this. @@ -1246,7 +1190,7 @@ that provides the variant members for this type tag v= alue). The "variants" array is in no particular order, and is not guaranteed to list cases in the same order as the corresponding "tag" enum type. =20 -Example: the SchemaInfo for flat union BlockdevOptions from section +Example: the SchemaInfo for union BlockdevOptions from section `Union types`_ :: =20 { "name": "BlockdevOptions", "meta-type": "object", @@ -1261,27 +1205,6 @@ Example: the SchemaInfo for flat union BlockdevOptio= ns from section Note that base types are "flattened": its members are included in the "members" array. =20 -A simple union implicitly defines an enumeration type for its implicit -discriminator (called "type" on the wire, see section `Union types`_). - -A simple union implicitly defines an object type for each of its -variants. - -Example: the SchemaInfo for simple union BlockdevOptionsSimple from section -`Union types`_ :: - - { "name": "BlockdevOptionsSimple", "meta-type": "object", - "members": [ - { "name": "type", "type": "BlockdevOptionsSimpleKind" } ], - "tag": "type", - "variants": [ - { "case": "file", "type": "q_obj-BlockdevOptionsFile-wrapper" }, - { "case": "qcow2", "type": "q_obj-BlockdevOptionsQcow2-wrapper" = } ] } - - Enumeration type "BlockdevOptionsSimpleKind" and the object types - "q_obj-BlockdevOptionsFile-wrapper", "q_obj-BlockdevOptionsQcow2-wrapp= er" - are implicitly defined. - The SchemaInfo for an alternate type has meta-type "alternate", and variant member "members". "members" is a JSON array. Each element is a JSON object with member "type", which names a type. Values of the diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 91959ee79a..819ea6ad97 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -513,27 +513,18 @@ def check_union(expr: _JSONObject, info: QAPISourceIn= fo) -> None: :return: None, ``expr`` is normalized in-place as needed. """ name =3D cast(str, expr['union']) # Checked in check_exprs - base =3D expr.get('base') - discriminator =3D expr.get('discriminator') + base =3D expr['base'] + discriminator =3D expr['discriminator'] members =3D expr['data'] =20 - if discriminator is None: # simple union - if base is not None: - raise QAPISemError(info, "'base' requires 'discriminator'") - else: # flat union - check_type(base, info, "'base'", allow_dict=3Dname) - if not base: - raise QAPISemError(info, "'discriminator' requires 'base'") - check_name_is_str(discriminator, info, "'discriminator'") + check_type(base, info, "'base'", allow_dict=3Dname) + check_name_is_str(discriminator, info, "'discriminator'") =20 if not isinstance(members, dict): raise QAPISemError(info, "'data' must be an object") =20 for (key, value) in members.items(): source =3D "'data' member '%s'" % key - if discriminator is None: - check_name_lower(key, info, source) - # else: name is in discriminator enum, which gets checked check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) check_type(value['type'], info, source, allow_array=3Dnot base) @@ -664,8 +655,8 @@ def check_exprs(exprs: List[_JSONObject]) -> List[_JSON= Object]: check_enum(expr, info) elif meta =3D=3D 'union': check_keys(expr, info, meta, - ['union', 'data'], - ['base', 'discriminator', 'if', 'features']) + ['union', 'base', 'discriminator', 'data'], + ['if', 'features']) normalize_members(expr.get('base')) normalize_members(expr['data']) check_union(expr, info) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3d72c7dfc9..004d7095ff 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -321,8 +321,8 @@ def connect_doc(self, doc=3DNone): m.connect_doc(doc) =20 def is_implicit(self): - # See QAPISchema._make_implicit_enum_type() and ._def_predefineds() - return self.name.endswith('Kind') or self.name =3D=3D 'QType' + # See QAPISchema._def_predefineds() + return self.name =3D=3D 'QType' =20 def c_type(self): return c_name(self.name) @@ -393,8 +393,7 @@ class QAPISchemaObjectType(QAPISchemaType): def __init__(self, name, info, doc, ifcond, features, base, local_members, variants): # struct has local_members, optional base, and no variants - # flat union has base, variants, and no local_members - # simple union has local_members, variants, and no base + # union has base, variants, and no local_members super().__init__(name, info, doc, ifcond, features) self.meta =3D 'union' if variants else 'struct' assert base is None or isinstance(base, str) @@ -465,15 +464,6 @@ def connect_doc(self, doc=3DNone): for m in self.local_members: m.connect_doc(doc) =20 - @property - def ifcond(self): - assert self._checked - if isinstance(self._ifcond, QAPISchemaType): - # Simple union wrapper type inherits from wrapped type; - # see _make_implicit_object_type() - return self._ifcond.ifcond - return self._ifcond - def is_implicit(self): # See QAPISchema._make_implicit_object_type(), as well as # _def_predefineds() @@ -576,10 +566,9 @@ def visit(self, visitor): =20 class QAPISchemaVariants: def __init__(self, tag_name, info, tag_member, variants): - # Flat unions pass tag_name but not tag_member. - # Simple unions and alternates pass tag_member but not tag_name. - # After check(), tag_member is always set, and tag_name remains - # a reliable witness of being used by a flat union. + # Unions pass tag_name but not tag_member. + # Alternates pass tag_member but not tag_name. + # After check(), tag_member is always set. assert bool(tag_member) !=3D bool(tag_name) assert (isinstance(tag_name, str) or isinstance(tag_member, QAPISchemaObjectTypeMember)) @@ -595,7 +584,7 @@ def set_defined_in(self, name): v.set_defined_in(name) =20 def check(self, schema, seen): - if not self.tag_member: # flat union + if self._tag_name: # union self.tag_member =3D seen.get(c_name(self._tag_name)) base =3D "'base'" # Pointing to the base type when not implicit would be @@ -625,11 +614,11 @@ def check(self, schema, seen): self.info, "discriminator member '%s' of %s must not be condition= al" % (self._tag_name, base)) - else: # simple union + else: # alternate assert isinstance(self.tag_member.type, QAPISchemaEnumType) assert not self.tag_member.optional assert not self.tag_member.ifcond.is_present() - if self._tag_name: # flat union + if self._tag_name: # union # branches that are not explicitly covered get an empty type cases =3D {v.name for v in self.variants} for m in self.tag_member.type.members: @@ -707,18 +696,10 @@ def describe(self, info): assert role =3D=3D 'member' role =3D 'parameter' elif defined_in.endswith('-base'): - # Implicit type created for a flat union's dict 'base' + # Implicit type created for a union's dict 'base' role =3D 'base ' + role else: - # Implicit type created for a simple union's branch - assert defined_in.endswith('-wrapper') - # Unreachable and not implemented assert False - elif defined_in.endswith('Kind'): - # See QAPISchema._make_implicit_enum_type() - # Implicit enum created for simple union's branches - assert role =3D=3D 'value' - role =3D 'branch' elif defined_in !=3D info.defn_name: return "%s '%s' of type '%s'" % (role, self.name, defined_in) return "%s '%s'" % (role, self.name) @@ -1004,15 +985,6 @@ def _make_enum_members(self, values, info): QAPISchemaIfCond(v.get('if'))) for v in values] =20 - def _make_implicit_enum_type(self, name, info, ifcond, values): - # See also QAPISchemaObjectTypeMember.describe() - name =3D name + 'Kind' # reserved by check_defn_name_str() - self._def_entity(QAPISchemaEnumType( - name, info, None, ifcond, None, - self._make_enum_members(values, info), - None)) - return name - def _make_array_type(self, element_type, info): name =3D element_type + 'List' # reserved by check_defn_name_st= r() if not self.lookup_type(name): @@ -1026,17 +998,9 @@ def _make_implicit_object_type(self, name, info, ifco= nd, role, members): name =3D 'q_obj_%s-%s' % (name, role) typ =3D self.lookup_entity(name, QAPISchemaObjectType) if typ: - # The implicit object type has multiple users. This is - # either a duplicate definition (which will be flagged - # later), or an implicit wrapper type used for multiple - # simple unions. In the latter case, ifcond should be the - # disjunction of its user's ifconds. Not implemented. - # Instead, we always pass the wrapped type's ifcond, which - # is trivially the same for all users. It's also - # necessary for the wrapper to compile. But it's not - # tight: the disjunction need not imply it. We may end up - # compiling useless wrapper types. - # TODO kill simple unions or implement the disjunction + # The implicit object type has multiple users. This can + # only be a duplicate definition, which will be flagged + # later. pass else: self._def_entity(QAPISchemaObjectType( @@ -1084,49 +1048,28 @@ def _def_struct_type(self, expr, info, doc): def _make_variant(self, case, typ, ifcond, info): return QAPISchemaVariant(case, info, typ, ifcond) =20 - def _make_simple_variant(self, case, typ, ifcond, info): - if isinstance(typ, list): - assert len(typ) =3D=3D 1 - typ =3D self._make_array_type(typ[0], info) - typ =3D self._make_implicit_object_type( - typ, info, self.lookup_type(typ), - 'wrapper', [self._make_member('data', typ, None, None, info)]) - return QAPISchemaVariant(case, info, typ, ifcond) - def _def_union_type(self, expr, info, doc): name =3D expr['union'] + base =3D expr['base'] + tag_name =3D expr['discriminator'] data =3D expr['data'] - base =3D expr.get('base') ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) - tag_name =3D expr.get('discriminator') - tag_member =3D None if isinstance(base, dict): base =3D self._make_implicit_object_type( name, info, ifcond, 'base', self._make_members(base, info)) - if tag_name: - variants =3D [ - self._make_variant(key, value['type'], - QAPISchemaIfCond(value.get('if')), - info) - for (key, value) in data.items()] - members =3D [] - else: - variants =3D [ - self._make_simple_variant(key, value['type'], - QAPISchemaIfCond(value.get('if')= ), - info) - for (key, value) in data.items()] - enum =3D [{'name': v.name, 'if': v.ifcond.ifcond} for v in var= iants] - typ =3D self._make_implicit_enum_type(name, info, ifcond, enum) - tag_member =3D QAPISchemaObjectTypeMember('type', info, typ, F= alse) - members =3D [tag_member] + variants =3D [ + self._make_variant(key, value['type'], + QAPISchemaIfCond(value.get('if')), + info) + for (key, value) in data.items()] + members =3D [] self._def_entity( QAPISchemaObjectType(name, info, doc, ifcond, features, base, members, QAPISchemaVariants( - tag_name, info, tag_member, variants)= )) + tag_name, info, None, variants))) =20 def _def_alternate_type(self, expr, info, doc): name =3D expr['alternate'] diff --git a/tests/qapi-schema/flat-union-array-branch.json b/tests/qapi-sc= hema/flat-union-array-branch.json index 0b98820a8f..6dda7ec379 100644 --- a/tests/qapi-schema/flat-union-array-branch.json +++ b/tests/qapi-schema/flat-union-array-branch.json @@ -1,4 +1,4 @@ -# we require flat union branches to be a struct +# we require union branches to be a struct { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'struct': 'Base', diff --git a/tests/qapi-schema/flat-union-empty.json b/tests/qapi-schema/fl= at-union-empty.json index 83e1cc7b96..584ed6098c 100644 --- a/tests/qapi-schema/flat-union-empty.json +++ b/tests/qapi-schema/flat-union-empty.json @@ -1,4 +1,4 @@ -# flat union discriminator cannot be empty +# union discriminator enum cannot be empty { 'enum': 'Empty', 'data': [ ] } { 'struct': 'Base', 'data': { 'type': 'Empty' } } { 'union': 'Union', 'base': 'Base', 'discriminator': 'type', 'data': { } } diff --git a/tests/qapi-schema/flat-union-int-branch.json b/tests/qapi-sche= ma/flat-union-int-branch.json index 9370c349e8..567043d9d2 100644 --- a/tests/qapi-schema/flat-union-int-branch.json +++ b/tests/qapi-schema/flat-union-int-branch.json @@ -1,4 +1,4 @@ -# we require flat union branches to be a struct +# we require union branches to be a struct { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'struct': 'Base', diff --git a/tests/qapi-schema/flat-union-no-base.err b/tests/qapi-schema/f= lat-union-no-base.err index 5167565b00..c60482f96b 100644 --- a/tests/qapi-schema/flat-union-no-base.err +++ b/tests/qapi-schema/flat-union-no-base.err @@ -1,2 +1,2 @@ flat-union-no-base.json: In union 'TestUnion': -flat-union-no-base.json:8: 'discriminator' requires 'base' +flat-union-no-base.json:8: union misses key 'base' diff --git a/tests/qapi-schema/flat-union-no-base.json b/tests/qapi-schema/= flat-union-no-base.json index 327877b563..f6fe12da3b 100644 --- a/tests/qapi-schema/flat-union-no-base.json +++ b/tests/qapi-schema/flat-union-no-base.json @@ -1,4 +1,4 @@ -# flat unions require a base +# unions require a base { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } { 'struct': 'TestTypeB', diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 20f4cc0cfa..2ec50109cb 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -30,7 +30,7 @@ { 'struct': 'Empty1', 'data': { } } { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } } =20 -# Likewise for an empty flat union +# Likewise for an empty union { 'union': 'Union', 'base': { 'type': 'EnumOne' }, 'discriminator': 'type', 'data': { } } diff --git a/tests/qapi-schema/reserved-member-u.json b/tests/qapi-schema/r= eserved-member-u.json index 2bfb8f59b6..d982ab5e0c 100644 --- a/tests/qapi-schema/reserved-member-u.json +++ b/tests/qapi-schema/reserved-member-u.json @@ -2,6 +2,6 @@ # We reject use of 'u' as a member name, to allow it for internal use in # putting union branch members in a separate namespace from QMP members. # This is true even for non-unions, because it is possible to convert a -# struct to flat union while remaining backwards compatible in QMP. +# struct to union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision { 'struct': 'Oops', 'data': { '*u': 'str' } } diff --git a/tests/qapi-schema/union-base-empty.json b/tests/qapi-schema/un= ion-base-empty.json index d1843d33b4..6f8ef000db 100644 --- a/tests/qapi-schema/union-base-empty.json +++ b/tests/qapi-schema/union-base-empty.json @@ -1,4 +1,4 @@ -# Flat union with empty base and therefore without discriminator +# Union with empty base and therefore without discriminator =20 { 'struct': 'Empty', 'data': { } } =20 diff --git a/tests/qapi-schema/union-base-no-discriminator.err b/tests/qapi= -schema/union-base-no-discriminator.err index 9cd5d11b0b..a730b7fd3c 100644 --- a/tests/qapi-schema/union-base-no-discriminator.err +++ b/tests/qapi-schema/union-base-no-discriminator.err @@ -1,2 +1,2 @@ union-base-no-discriminator.json: In union 'TestUnion': -union-base-no-discriminator.json:11: 'base' requires 'discriminator' +union-base-no-discriminator.json:11: union misses key 'discriminator' diff --git a/tests/qapi-schema/union-base-no-discriminator.json b/tests/qap= i-schema/union-base-no-discriminator.json index 1409cf5c9e..2e7cae9b22 100644 --- a/tests/qapi-schema/union-base-no-discriminator.json +++ b/tests/qapi-schema/union-base-no-discriminator.json @@ -1,4 +1,4 @@ -# we reject simple unions with a base (or flat unions without discriminato= r) +# we reject unions without discriminator { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } =20 --=20 2.31.1 From nobody Fri May 17 11:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552855; cv=none; d=zohomail.com; s=zohoarc; b=PPyo/N0tnvBVHlXdh49j3ZGNVGo8jbXf7a4giOv+mw2IFlRe3kkBawjLTmqiY/pJk4t+yzCuJd3eqzuyOj81FvFvEY12vn8b5UAsb/Qia51OcOVwmJlGi30f6WcugQjOsHDYWFbXftAuJ8DNvcqQyDPtnS86ui78AXjdhV/9J2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552855; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=crdpMqgq/xumj2wSo6tDv4gzNZ7NmdAh+0MIrIKtpPg=; b=T9FWsRgpLlKaqjxRizQCY9/b7unTO1Rtc5N8pA2gc9A2mFsyx7w1Ebmt9CcE0g+3yjAxC9R0SOm6FRofKvHwGOpIVy1zJ2toDL1traASv0WQ02TVypX3F2IRzeeyIS4Lk7df14Dla3LuMtoHTSIQ3EtgrQzp66ZjM9Y8IumJOAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552854996787.5160498269257; Fri, 24 Sep 2021 23:54:14 -0700 (PDT) Received: from localhost ([::1]:33160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Zd-0005i2-OV for importer@patchew.org; Sat, 25 Sep 2021 02:54:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU18B-0007hN-1t for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU180-0007LJ-Of for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-556-MJrxAZgKNjayySoSWMOQxw-1; Sat, 25 Sep 2021 02:25:36 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D0021006AA2; Sat, 25 Sep 2021 06:25:36 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66E351972D; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 650871136421; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=crdpMqgq/xumj2wSo6tDv4gzNZ7NmdAh+0MIrIKtpPg=; b=efgr41kNE2aGA9pwalYdW2m6zqedkyfCh6rIpv7ooBQedkB58fE1bdPwONbGJv/wALhvy/ UKE1NKpdjowse1er/mA9yiOn3dvadTXxUUt09Mfhnun9n3sYCb9WpT/Hr3OPZ/1gsh5gJe KmWkFCNd6xJMDOC3wzQI8+tQXQBkyWc= X-MC-Unique: MJrxAZgKNjayySoSWMOQxw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 22/25] tests/qapi-schema: Rename flat-union-* test cases to union-* Date: Sat, 25 Sep 2021 08:25:22 +0200 Message-Id: <20210925062525.988405-23-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552855487100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Message-Id: <20210917143134.412106-23-armbru@redhat.com> Reviewed-by: Eric Blake union-array-branch.json} | 0 ...rray-branch.out =3D> union-array-branch.out} | 0 tests/qapi-schema/union-bad-base.err | 2 ++ ...nion-bad-base.json =3D> union-bad-base.json} | 0 ...-union-bad-base.out =3D> union-bad-base.out} | 0 tests/qapi-schema/union-bad-discriminator.err | 2 ++ ...ator.json =3D> union-bad-discriminator.json} | 0 ...inator.out =3D> union-bad-discriminator.out} | 0 tests/qapi-schema/union-base-any.err | 2 ++ ...nion-base-any.json =3D> union-base-any.json} | 0 ...-union-base-any.out =3D> union-base-any.out} | 0 tests/qapi-schema/union-base-union.err | 2 ++ ...-base-union.json =3D> union-base-union.json} | 0 ...on-base-union.out =3D> union-base-union.out} | 0 tests/qapi-schema/union-clash-member.err | 2 ++ ...sh-member.json =3D> union-clash-member.json} | 0 ...lash-member.out =3D> union-clash-member.out} | 0 .../union-discriminator-bad-name.err | 2 ++ ...json =3D> union-discriminator-bad-name.json} | 0 ...e.out =3D> union-discriminator-bad-name.out} | 0 tests/qapi-schema/union-empty.err | 2 ++ ...flat-union-empty.json =3D> union-empty.json} | 0 .../{flat-union-empty.out =3D> union-empty.out} | 0 .../qapi-schema/union-inline-invalid-dict.err | 2 ++ ...ct.json =3D> union-inline-invalid-dict.json} | 0 ...dict.out =3D> union-inline-invalid-dict.out} | 0 tests/qapi-schema/union-int-branch.err | 2 ++ ...-int-branch.json =3D> union-int-branch.json} | 0 ...on-int-branch.out =3D> union-int-branch.out} | 0 .../qapi-schema/union-invalid-branch-key.err | 2 ++ ...key.json =3D> union-invalid-branch-key.json} | 0 ...h-key.out =3D> union-invalid-branch-key.out} | 0 .../union-invalid-discriminator.err | 2 ++ ....json =3D> union-invalid-discriminator.json} | 0 ...or.out =3D> union-invalid-discriminator.out} | 0 .../union-invalid-if-discriminator.err | 2 ++ ...on =3D> union-invalid-if-discriminator.json} | 0 ...out =3D> union-invalid-if-discriminator.out} | 0 tests/qapi-schema/union-no-base.err | 2 ++ ...-union-no-base.json =3D> union-no-base.json} | 0 ...at-union-no-base.out =3D> union-no-base.out} | 0 .../union-optional-discriminator.err | 2 ++ ...json =3D> union-optional-discriminator.json} | 0 ...r.out =3D> union-optional-discriminator.out} | 0 .../union-string-discriminator.err | 2 ++ ...r.json =3D> union-string-discriminator.json} | 0 ...tor.out =3D> union-string-discriminator.out} | 0 65 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 tests/qapi-schema/flat-union-array-branch.err delete mode 100644 tests/qapi-schema/flat-union-bad-base.err delete mode 100644 tests/qapi-schema/flat-union-bad-discriminator.err delete mode 100644 tests/qapi-schema/flat-union-base-any.err delete mode 100644 tests/qapi-schema/flat-union-base-union.err delete mode 100644 tests/qapi-schema/flat-union-clash-member.err delete mode 100644 tests/qapi-schema/flat-union-discriminator-bad-name.err delete mode 100644 tests/qapi-schema/flat-union-empty.err delete mode 100644 tests/qapi-schema/flat-union-inline-invalid-dict.err delete mode 100644 tests/qapi-schema/flat-union-int-branch.err delete mode 100644 tests/qapi-schema/flat-union-invalid-branch-key.err delete mode 100644 tests/qapi-schema/flat-union-invalid-discriminator.err delete mode 100644 tests/qapi-schema/flat-union-invalid-if-discriminator.e= rr delete mode 100644 tests/qapi-schema/flat-union-no-base.err delete mode 100644 tests/qapi-schema/flat-union-optional-discriminator.err delete mode 100644 tests/qapi-schema/flat-union-string-discriminator.err create mode 100644 tests/qapi-schema/union-array-branch.err rename tests/qapi-schema/{flat-union-array-branch.json =3D> union-array-br= anch.json} (100%) rename tests/qapi-schema/{flat-union-array-branch.out =3D> union-array-bra= nch.out} (100%) create mode 100644 tests/qapi-schema/union-bad-base.err rename tests/qapi-schema/{flat-union-bad-base.json =3D> union-bad-base.jso= n} (100%) rename tests/qapi-schema/{flat-union-bad-base.out =3D> union-bad-base.out}= (100%) create mode 100644 tests/qapi-schema/union-bad-discriminator.err rename tests/qapi-schema/{flat-union-bad-discriminator.json =3D> union-bad= -discriminator.json} (100%) rename tests/qapi-schema/{flat-union-bad-discriminator.out =3D> union-bad-= discriminator.out} (100%) create mode 100644 tests/qapi-schema/union-base-any.err rename tests/qapi-schema/{flat-union-base-any.json =3D> union-base-any.jso= n} (100%) rename tests/qapi-schema/{flat-union-base-any.out =3D> union-base-any.out}= (100%) create mode 100644 tests/qapi-schema/union-base-union.err rename tests/qapi-schema/{flat-union-base-union.json =3D> union-base-union= .json} (100%) rename tests/qapi-schema/{flat-union-base-union.out =3D> union-base-union.= out} (100%) create mode 100644 tests/qapi-schema/union-clash-member.err rename tests/qapi-schema/{flat-union-clash-member.json =3D> union-clash-me= mber.json} (100%) rename tests/qapi-schema/{flat-union-clash-member.out =3D> union-clash-mem= ber.out} (100%) create mode 100644 tests/qapi-schema/union-discriminator-bad-name.err rename tests/qapi-schema/{flat-union-discriminator-bad-name.json =3D> unio= n-discriminator-bad-name.json} (100%) rename tests/qapi-schema/{flat-union-discriminator-bad-name.out =3D> union= -discriminator-bad-name.out} (100%) create mode 100644 tests/qapi-schema/union-empty.err rename tests/qapi-schema/{flat-union-empty.json =3D> union-empty.json} (10= 0%) rename tests/qapi-schema/{flat-union-empty.out =3D> union-empty.out} (100%) create mode 100644 tests/qapi-schema/union-inline-invalid-dict.err rename tests/qapi-schema/{flat-union-inline-invalid-dict.json =3D> union-i= nline-invalid-dict.json} (100%) rename tests/qapi-schema/{flat-union-inline-invalid-dict.out =3D> union-in= line-invalid-dict.out} (100%) create mode 100644 tests/qapi-schema/union-int-branch.err rename tests/qapi-schema/{flat-union-int-branch.json =3D> union-int-branch= .json} (100%) rename tests/qapi-schema/{flat-union-int-branch.out =3D> union-int-branch.= out} (100%) create mode 100644 tests/qapi-schema/union-invalid-branch-key.err rename tests/qapi-schema/{flat-union-invalid-branch-key.json =3D> union-in= valid-branch-key.json} (100%) rename tests/qapi-schema/{flat-union-invalid-branch-key.out =3D> union-inv= alid-branch-key.out} (100%) create mode 100644 tests/qapi-schema/union-invalid-discriminator.err rename tests/qapi-schema/{flat-union-invalid-discriminator.json =3D> union= -invalid-discriminator.json} (100%) rename tests/qapi-schema/{flat-union-invalid-discriminator.out =3D> union-= invalid-discriminator.out} (100%) create mode 100644 tests/qapi-schema/union-invalid-if-discriminator.err rename tests/qapi-schema/{flat-union-invalid-if-discriminator.json =3D> un= ion-invalid-if-discriminator.json} (100%) rename tests/qapi-schema/{flat-union-invalid-if-discriminator.out =3D> uni= on-invalid-if-discriminator.out} (100%) create mode 100644 tests/qapi-schema/union-no-base.err rename tests/qapi-schema/{flat-union-no-base.json =3D> union-no-base.json}= (100%) rename tests/qapi-schema/{flat-union-no-base.out =3D> union-no-base.out} (= 100%) create mode 100644 tests/qapi-schema/union-optional-discriminator.err rename tests/qapi-schema/{flat-union-optional-discriminator.json =3D> unio= n-optional-discriminator.json} (100%) rename tests/qapi-schema/{flat-union-optional-discriminator.out =3D> union= -optional-discriminator.out} (100%) create mode 100644 tests/qapi-schema/union-string-discriminator.err rename tests/qapi-schema/{flat-union-string-discriminator.json =3D> union-= string-discriminator.json} (100%) rename tests/qapi-schema/{flat-union-string-discriminator.out =3D> union-s= tring-discriminator.out} (100%) diff --git a/tests/qapi-schema/flat-union-array-branch.err b/tests/qapi-sch= ema/flat-union-array-branch.err deleted file mode 100644 index 20a8ef1406..0000000000 --- a/tests/qapi-schema/flat-union-array-branch.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-array-branch.json: In union 'TestUnion': -flat-union-array-branch.json:8: 'data' member 'value1' cannot be an array diff --git a/tests/qapi-schema/flat-union-bad-base.err b/tests/qapi-schema/= flat-union-bad-base.err deleted file mode 100644 index e0a205a58c..0000000000 --- a/tests/qapi-schema/flat-union-bad-base.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-bad-base.json: In union 'TestUnion': -flat-union-bad-base.json:8: member 'string' of type 'TestTypeA' collides w= ith base member 'string' diff --git a/tests/qapi-schema/flat-union-bad-discriminator.err b/tests/qap= i-schema/flat-union-bad-discriminator.err deleted file mode 100644 index b705439bd9..0000000000 --- a/tests/qapi-schema/flat-union-bad-discriminator.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-bad-discriminator.json: In union 'TestUnion': -flat-union-bad-discriminator.json:11: 'discriminator' requires a string na= me diff --git a/tests/qapi-schema/flat-union-base-any.err b/tests/qapi-schema/= flat-union-base-any.err deleted file mode 100644 index c2d4de6a5d..0000000000 --- a/tests/qapi-schema/flat-union-base-any.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-base-any.json: In union 'TestUnion': -flat-union-base-any.json:8: 'base' requires a struct type, built-in type '= any' isn't diff --git a/tests/qapi-schema/flat-union-base-union.err b/tests/qapi-schem= a/flat-union-base-union.err deleted file mode 100644 index 3563e8777e..0000000000 --- a/tests/qapi-schema/flat-union-base-union.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-base-union.json: In union 'TestUnion': -flat-union-base-union.json:17: 'base' requires a struct type, union type '= UnionBase' isn't diff --git a/tests/qapi-schema/flat-union-clash-member.err b/tests/qapi-sch= ema/flat-union-clash-member.err deleted file mode 100644 index 07551e6ef5..0000000000 --- a/tests/qapi-schema/flat-union-clash-member.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-clash-member.json: In union 'TestUnion': -flat-union-clash-member.json:11: member 'name' of type 'Branch1' collides = with member 'name' of type 'Base' diff --git a/tests/qapi-schema/flat-union-discriminator-bad-name.err b/test= s/qapi-schema/flat-union-discriminator-bad-name.err deleted file mode 100644 index 28be49c31a..0000000000 --- a/tests/qapi-schema/flat-union-discriminator-bad-name.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-discriminator-bad-name.json: In union 'MyUnion': -flat-union-discriminator-bad-name.json:6: discriminator '*switch' is not a= member of 'base' diff --git a/tests/qapi-schema/flat-union-empty.err b/tests/qapi-schema/fla= t-union-empty.err deleted file mode 100644 index 89b0f25cb0..0000000000 --- a/tests/qapi-schema/flat-union-empty.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-empty.json: In union 'Union': -flat-union-empty.json:4: union has no branches diff --git a/tests/qapi-schema/flat-union-inline-invalid-dict.err b/tests/q= api-schema/flat-union-inline-invalid-dict.err deleted file mode 100644 index 53e5416707..0000000000 --- a/tests/qapi-schema/flat-union-inline-invalid-dict.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-inline-invalid-dict.json: In union 'TestUnion': -flat-union-inline-invalid-dict.json:7: 'data' member 'value1' misses key '= type' diff --git a/tests/qapi-schema/flat-union-int-branch.err b/tests/qapi-schem= a/flat-union-int-branch.err deleted file mode 100644 index ae7f800603..0000000000 --- a/tests/qapi-schema/flat-union-int-branch.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-int-branch.json: In union 'TestUnion': -flat-union-int-branch.json:8: branch 'value1' cannot use built-in type 'in= t' diff --git a/tests/qapi-schema/flat-union-invalid-branch-key.err b/tests/qa= pi-schema/flat-union-invalid-branch-key.err deleted file mode 100644 index 5576a25f9b..0000000000 --- a/tests/qapi-schema/flat-union-invalid-branch-key.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-invalid-branch-key.json: In union 'TestUnion': -flat-union-invalid-branch-key.json:13: branch 'value_wrong' is not a value= of enum type 'TestEnum' diff --git a/tests/qapi-schema/flat-union-invalid-discriminator.err b/tests= /qapi-schema/flat-union-invalid-discriminator.err deleted file mode 100644 index 99bca2ddab..0000000000 --- a/tests/qapi-schema/flat-union-invalid-discriminator.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-invalid-discriminator.json: In union 'TestUnion': -flat-union-invalid-discriminator.json:10: discriminator 'enum_wrong' is no= t a member of 'base' diff --git a/tests/qapi-schema/flat-union-invalid-if-discriminator.err b/te= sts/qapi-schema/flat-union-invalid-if-discriminator.err deleted file mode 100644 index 350f28da9d..0000000000 --- a/tests/qapi-schema/flat-union-invalid-if-discriminator.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-invalid-if-discriminator.json: In union 'TestUnion': -flat-union-invalid-if-discriminator.json:10: discriminator member 'enum1' = of 'base' must not be conditional diff --git a/tests/qapi-schema/flat-union-no-base.err b/tests/qapi-schema/f= lat-union-no-base.err deleted file mode 100644 index c60482f96b..0000000000 --- a/tests/qapi-schema/flat-union-no-base.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-no-base.json: In union 'TestUnion': -flat-union-no-base.json:8: union misses key 'base' diff --git a/tests/qapi-schema/flat-union-optional-discriminator.err b/test= s/qapi-schema/flat-union-optional-discriminator.err deleted file mode 100644 index 3d60a1b496..0000000000 --- a/tests/qapi-schema/flat-union-optional-discriminator.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-optional-discriminator.json: In union 'MyUnion': -flat-union-optional-discriminator.json:6: discriminator member 'switch' of= base type 'Base' must not be optional diff --git a/tests/qapi-schema/flat-union-string-discriminator.err b/tests/= qapi-schema/flat-union-string-discriminator.err deleted file mode 100644 index ff42c9728b..0000000000 --- a/tests/qapi-schema/flat-union-string-discriminator.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-string-discriminator.json: In union 'TestUnion': -flat-union-string-discriminator.json:13: discriminator member 'kind' of ba= se type 'TestBase' must be of enum type diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 85d3de1481..6187efbd58 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -107,22 +107,6 @@ schemas =3D [ 'features-name-bad-type.json', 'features-no-list.json', 'features-unknown-key.json', - 'flat-union-array-branch.json', - 'flat-union-bad-base.json', - 'flat-union-bad-discriminator.json', - 'flat-union-base-any.json', - 'flat-union-base-union.json', - 'flat-union-clash-member.json', - 'flat-union-discriminator-bad-name.json', - 'flat-union-empty.json', - 'flat-union-inline-invalid-dict.json', - 'flat-union-int-branch.json', - 'flat-union-invalid-branch-key.json', - 'flat-union-invalid-discriminator.json', - 'flat-union-invalid-if-discriminator.json', - 'flat-union-no-base.json', - 'flat-union-optional-discriminator.json', - 'flat-union-string-discriminator.json', 'funny-char.json', 'funny-word.json', 'ident-with-escape.json', @@ -190,12 +174,28 @@ schemas =3D [ 'unclosed-list.json', 'unclosed-object.json', 'unclosed-string.json', + 'union-array-branch.json', + 'union-bad-base.json', + 'union-bad-discriminator.json', + 'union-base-any.json', 'union-base-empty.json', 'union-base-no-discriminator.json', + 'union-base-union.json', 'union-branch-if-invalid.json', 'union-branch-invalid-dict.json', + 'union-clash-member.json', + 'union-discriminator-bad-name.json', + 'union-empty.json', + 'union-inline-invalid-dict.json', + 'union-int-branch.json', 'union-invalid-base.json', + 'union-invalid-branch-key.json', 'union-invalid-data.json', + 'union-invalid-discriminator.json', + 'union-invalid-if-discriminator.json', + 'union-no-base.json', + 'union-optional-discriminator.json', + 'union-string-discriminator.json', 'union-unknown.json', 'unknown-escape.json', 'unknown-expr-key.json', diff --git a/tests/qapi-schema/union-array-branch.err b/tests/qapi-schema/u= nion-array-branch.err new file mode 100644 index 0000000000..5db9c17481 --- /dev/null +++ b/tests/qapi-schema/union-array-branch.err @@ -0,0 +1,2 @@ +union-array-branch.json: In union 'TestUnion': +union-array-branch.json:8: 'data' member 'value1' cannot be an array diff --git a/tests/qapi-schema/flat-union-array-branch.json b/tests/qapi-sc= hema/union-array-branch.json similarity index 100% rename from tests/qapi-schema/flat-union-array-branch.json rename to tests/qapi-schema/union-array-branch.json diff --git a/tests/qapi-schema/flat-union-array-branch.out b/tests/qapi-sch= ema/union-array-branch.out similarity index 100% rename from tests/qapi-schema/flat-union-array-branch.out rename to tests/qapi-schema/union-array-branch.out diff --git a/tests/qapi-schema/union-bad-base.err b/tests/qapi-schema/union= -bad-base.err new file mode 100644 index 0000000000..42b2ed1dda --- /dev/null +++ b/tests/qapi-schema/union-bad-base.err @@ -0,0 +1,2 @@ +union-bad-base.json: In union 'TestUnion': +union-bad-base.json:8: member 'string' of type 'TestTypeA' collides with b= ase member 'string' diff --git a/tests/qapi-schema/flat-union-bad-base.json b/tests/qapi-schema= /union-bad-base.json similarity index 100% rename from tests/qapi-schema/flat-union-bad-base.json rename to tests/qapi-schema/union-bad-base.json diff --git a/tests/qapi-schema/flat-union-bad-base.out b/tests/qapi-schema/= union-bad-base.out similarity index 100% rename from tests/qapi-schema/flat-union-bad-base.out rename to tests/qapi-schema/union-bad-base.out diff --git a/tests/qapi-schema/union-bad-discriminator.err b/tests/qapi-sch= ema/union-bad-discriminator.err new file mode 100644 index 0000000000..7cfd470f58 --- /dev/null +++ b/tests/qapi-schema/union-bad-discriminator.err @@ -0,0 +1,2 @@ +union-bad-discriminator.json: In union 'TestUnion': +union-bad-discriminator.json:11: 'discriminator' requires a string name diff --git a/tests/qapi-schema/flat-union-bad-discriminator.json b/tests/qa= pi-schema/union-bad-discriminator.json similarity index 100% rename from tests/qapi-schema/flat-union-bad-discriminator.json rename to tests/qapi-schema/union-bad-discriminator.json diff --git a/tests/qapi-schema/flat-union-bad-discriminator.out b/tests/qap= i-schema/union-bad-discriminator.out similarity index 100% rename from tests/qapi-schema/flat-union-bad-discriminator.out rename to tests/qapi-schema/union-bad-discriminator.out diff --git a/tests/qapi-schema/union-base-any.err b/tests/qapi-schema/union= -base-any.err new file mode 100644 index 0000000000..82b48bc1c8 --- /dev/null +++ b/tests/qapi-schema/union-base-any.err @@ -0,0 +1,2 @@ +union-base-any.json: In union 'TestUnion': +union-base-any.json:8: 'base' requires a struct type, built-in type 'any' = isn't diff --git a/tests/qapi-schema/flat-union-base-any.json b/tests/qapi-schema= /union-base-any.json similarity index 100% rename from tests/qapi-schema/flat-union-base-any.json rename to tests/qapi-schema/union-base-any.json diff --git a/tests/qapi-schema/flat-union-base-any.out b/tests/qapi-schema/= union-base-any.out similarity index 100% rename from tests/qapi-schema/flat-union-base-any.out rename to tests/qapi-schema/union-base-any.out diff --git a/tests/qapi-schema/union-base-union.err b/tests/qapi-schema/uni= on-base-union.err new file mode 100644 index 0000000000..2bddaf6a84 --- /dev/null +++ b/tests/qapi-schema/union-base-union.err @@ -0,0 +1,2 @@ +union-base-union.json: In union 'TestUnion': +union-base-union.json:17: 'base' requires a struct type, union type 'Union= Base' isn't diff --git a/tests/qapi-schema/flat-union-base-union.json b/tests/qapi-sche= ma/union-base-union.json similarity index 100% rename from tests/qapi-schema/flat-union-base-union.json rename to tests/qapi-schema/union-base-union.json diff --git a/tests/qapi-schema/flat-union-base-union.out b/tests/qapi-schem= a/union-base-union.out similarity index 100% rename from tests/qapi-schema/flat-union-base-union.out rename to tests/qapi-schema/union-base-union.out diff --git a/tests/qapi-schema/union-clash-member.err b/tests/qapi-schema/u= nion-clash-member.err new file mode 100644 index 0000000000..c1f3a02552 --- /dev/null +++ b/tests/qapi-schema/union-clash-member.err @@ -0,0 +1,2 @@ +union-clash-member.json: In union 'TestUnion': +union-clash-member.json:11: member 'name' of type 'Branch1' collides with = member 'name' of type 'Base' diff --git a/tests/qapi-schema/flat-union-clash-member.json b/tests/qapi-sc= hema/union-clash-member.json similarity index 100% rename from tests/qapi-schema/flat-union-clash-member.json rename to tests/qapi-schema/union-clash-member.json diff --git a/tests/qapi-schema/flat-union-clash-member.out b/tests/qapi-sch= ema/union-clash-member.out similarity index 100% rename from tests/qapi-schema/flat-union-clash-member.out rename to tests/qapi-schema/union-clash-member.out diff --git a/tests/qapi-schema/union-discriminator-bad-name.err b/tests/qap= i-schema/union-discriminator-bad-name.err new file mode 100644 index 0000000000..5793e9af66 --- /dev/null +++ b/tests/qapi-schema/union-discriminator-bad-name.err @@ -0,0 +1,2 @@ +union-discriminator-bad-name.json: In union 'MyUnion': +union-discriminator-bad-name.json:6: discriminator '*switch' is not a memb= er of 'base' diff --git a/tests/qapi-schema/flat-union-discriminator-bad-name.json b/tes= ts/qapi-schema/union-discriminator-bad-name.json similarity index 100% rename from tests/qapi-schema/flat-union-discriminator-bad-name.json rename to tests/qapi-schema/union-discriminator-bad-name.json diff --git a/tests/qapi-schema/flat-union-discriminator-bad-name.out b/test= s/qapi-schema/union-discriminator-bad-name.out similarity index 100% rename from tests/qapi-schema/flat-union-discriminator-bad-name.out rename to tests/qapi-schema/union-discriminator-bad-name.out diff --git a/tests/qapi-schema/union-empty.err b/tests/qapi-schema/union-em= pty.err new file mode 100644 index 0000000000..d428439962 --- /dev/null +++ b/tests/qapi-schema/union-empty.err @@ -0,0 +1,2 @@ +union-empty.json: In union 'Union': +union-empty.json:4: union has no branches diff --git a/tests/qapi-schema/flat-union-empty.json b/tests/qapi-schema/un= ion-empty.json similarity index 100% rename from tests/qapi-schema/flat-union-empty.json rename to tests/qapi-schema/union-empty.json diff --git a/tests/qapi-schema/flat-union-empty.out b/tests/qapi-schema/uni= on-empty.out similarity index 100% rename from tests/qapi-schema/flat-union-empty.out rename to tests/qapi-schema/union-empty.out diff --git a/tests/qapi-schema/union-inline-invalid-dict.err b/tests/qapi-s= chema/union-inline-invalid-dict.err new file mode 100644 index 0000000000..25ddf7c765 --- /dev/null +++ b/tests/qapi-schema/union-inline-invalid-dict.err @@ -0,0 +1,2 @@ +union-inline-invalid-dict.json: In union 'TestUnion': +union-inline-invalid-dict.json:7: 'data' member 'value1' misses key 'type' diff --git a/tests/qapi-schema/flat-union-inline-invalid-dict.json b/tests/= qapi-schema/union-inline-invalid-dict.json similarity index 100% rename from tests/qapi-schema/flat-union-inline-invalid-dict.json rename to tests/qapi-schema/union-inline-invalid-dict.json diff --git a/tests/qapi-schema/flat-union-inline-invalid-dict.out b/tests/q= api-schema/union-inline-invalid-dict.out similarity index 100% rename from tests/qapi-schema/flat-union-inline-invalid-dict.out rename to tests/qapi-schema/union-inline-invalid-dict.out diff --git a/tests/qapi-schema/union-int-branch.err b/tests/qapi-schema/uni= on-int-branch.err new file mode 100644 index 0000000000..8fdc81edd1 --- /dev/null +++ b/tests/qapi-schema/union-int-branch.err @@ -0,0 +1,2 @@ +union-int-branch.json: In union 'TestUnion': +union-int-branch.json:8: branch 'value1' cannot use built-in type 'int' diff --git a/tests/qapi-schema/flat-union-int-branch.json b/tests/qapi-sche= ma/union-int-branch.json similarity index 100% rename from tests/qapi-schema/flat-union-int-branch.json rename to tests/qapi-schema/union-int-branch.json diff --git a/tests/qapi-schema/flat-union-int-branch.out b/tests/qapi-schem= a/union-int-branch.out similarity index 100% rename from tests/qapi-schema/flat-union-int-branch.out rename to tests/qapi-schema/union-int-branch.out diff --git a/tests/qapi-schema/union-invalid-branch-key.err b/tests/qapi-sc= hema/union-invalid-branch-key.err new file mode 100644 index 0000000000..bf58800507 --- /dev/null +++ b/tests/qapi-schema/union-invalid-branch-key.err @@ -0,0 +1,2 @@ +union-invalid-branch-key.json: In union 'TestUnion': +union-invalid-branch-key.json:13: branch 'value_wrong' is not a value of e= num type 'TestEnum' diff --git a/tests/qapi-schema/flat-union-invalid-branch-key.json b/tests/q= api-schema/union-invalid-branch-key.json similarity index 100% rename from tests/qapi-schema/flat-union-invalid-branch-key.json rename to tests/qapi-schema/union-invalid-branch-key.json diff --git a/tests/qapi-schema/flat-union-invalid-branch-key.out b/tests/qa= pi-schema/union-invalid-branch-key.out similarity index 100% rename from tests/qapi-schema/flat-union-invalid-branch-key.out rename to tests/qapi-schema/union-invalid-branch-key.out diff --git a/tests/qapi-schema/union-invalid-discriminator.err b/tests/qapi= -schema/union-invalid-discriminator.err new file mode 100644 index 0000000000..38efb24b98 --- /dev/null +++ b/tests/qapi-schema/union-invalid-discriminator.err @@ -0,0 +1,2 @@ +union-invalid-discriminator.json: In union 'TestUnion': +union-invalid-discriminator.json:10: discriminator 'enum_wrong' is not a m= ember of 'base' diff --git a/tests/qapi-schema/flat-union-invalid-discriminator.json b/test= s/qapi-schema/union-invalid-discriminator.json similarity index 100% rename from tests/qapi-schema/flat-union-invalid-discriminator.json rename to tests/qapi-schema/union-invalid-discriminator.json diff --git a/tests/qapi-schema/flat-union-invalid-discriminator.out b/tests= /qapi-schema/union-invalid-discriminator.out similarity index 100% rename from tests/qapi-schema/flat-union-invalid-discriminator.out rename to tests/qapi-schema/union-invalid-discriminator.out diff --git a/tests/qapi-schema/union-invalid-if-discriminator.err b/tests/q= api-schema/union-invalid-if-discriminator.err new file mode 100644 index 0000000000..3f41d03f8e --- /dev/null +++ b/tests/qapi-schema/union-invalid-if-discriminator.err @@ -0,0 +1,2 @@ +union-invalid-if-discriminator.json: In union 'TestUnion': +union-invalid-if-discriminator.json:10: discriminator member 'enum1' of 'b= ase' must not be conditional diff --git a/tests/qapi-schema/flat-union-invalid-if-discriminator.json b/t= ests/qapi-schema/union-invalid-if-discriminator.json similarity index 100% rename from tests/qapi-schema/flat-union-invalid-if-discriminator.json rename to tests/qapi-schema/union-invalid-if-discriminator.json diff --git a/tests/qapi-schema/flat-union-invalid-if-discriminator.out b/te= sts/qapi-schema/union-invalid-if-discriminator.out similarity index 100% rename from tests/qapi-schema/flat-union-invalid-if-discriminator.out rename to tests/qapi-schema/union-invalid-if-discriminator.out diff --git a/tests/qapi-schema/union-no-base.err b/tests/qapi-schema/union-= no-base.err new file mode 100644 index 0000000000..cbf12ac526 --- /dev/null +++ b/tests/qapi-schema/union-no-base.err @@ -0,0 +1,2 @@ +union-no-base.json: In union 'TestUnion': +union-no-base.json:8: union misses key 'base' diff --git a/tests/qapi-schema/flat-union-no-base.json b/tests/qapi-schema/= union-no-base.json similarity index 100% rename from tests/qapi-schema/flat-union-no-base.json rename to tests/qapi-schema/union-no-base.json diff --git a/tests/qapi-schema/flat-union-no-base.out b/tests/qapi-schema/u= nion-no-base.out similarity index 100% rename from tests/qapi-schema/flat-union-no-base.out rename to tests/qapi-schema/union-no-base.out diff --git a/tests/qapi-schema/union-optional-discriminator.err b/tests/qap= i-schema/union-optional-discriminator.err new file mode 100644 index 0000000000..8d980bd2ac --- /dev/null +++ b/tests/qapi-schema/union-optional-discriminator.err @@ -0,0 +1,2 @@ +union-optional-discriminator.json: In union 'MyUnion': +union-optional-discriminator.json:6: discriminator member 'switch' of base= type 'Base' must not be optional diff --git a/tests/qapi-schema/flat-union-optional-discriminator.json b/tes= ts/qapi-schema/union-optional-discriminator.json similarity index 100% rename from tests/qapi-schema/flat-union-optional-discriminator.json rename to tests/qapi-schema/union-optional-discriminator.json diff --git a/tests/qapi-schema/flat-union-optional-discriminator.out b/test= s/qapi-schema/union-optional-discriminator.out similarity index 100% rename from tests/qapi-schema/flat-union-optional-discriminator.out rename to tests/qapi-schema/union-optional-discriminator.out diff --git a/tests/qapi-schema/union-string-discriminator.err b/tests/qapi-= schema/union-string-discriminator.err new file mode 100644 index 0000000000..eccbe681bd --- /dev/null +++ b/tests/qapi-schema/union-string-discriminator.err @@ -0,0 +1,2 @@ +union-string-discriminator.json: In union 'TestUnion': +union-string-discriminator.json:13: discriminator member 'kind' of base ty= pe 'TestBase' must be of enum type diff --git a/tests/qapi-schema/flat-union-string-discriminator.json b/tests= /qapi-schema/union-string-discriminator.json similarity index 100% rename from tests/qapi-schema/flat-union-string-discriminator.json rename to tests/qapi-schema/union-string-discriminator.json diff --git a/tests/qapi-schema/flat-union-string-discriminator.out b/tests/= qapi-schema/union-string-discriminator.out similarity index 100% rename from tests/qapi-schema/flat-union-string-discriminator.out rename to tests/qapi-schema/union-string-discriminator.out --=20 2.31.1 From nobody Fri May 17 11:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552394; cv=none; d=zohomail.com; s=zohoarc; b=TTz39xt+3UtbrQytCawYxeuPfrdmduANlNsHJs++8KXMYFOtkOtMx96GDhVE5sK5jdFWK4ill5yHGW73P2j5DhNK87iQNdgACJiU1VvpGVCDEhOcpE24nGP47bKMzFE16OxfxzseM85JPvTXdtAjo9Fux823xCb9/zXxGuF79l4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552394; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Dh1qCXcBy1PNpZRi3lXvaT/kUO2EqqJepPg2N+BW8uc=; b=CB4CJH2/3rQd1qoVMIKBTxNTgHAP8DL07IDPo+UqFRMUUu1hZGQXZL4A/jcT1n9hVStOCXSk13lw42oia8ASMe5l9vuugUaKnYoJ4iLbeQR9cVu5LUPeJbNbpys6zBNfZJSrVNP/CpZDGlKqf2uLCfhg2oEIEAYdKcNCdk3cA1E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552394321152.6522124274005; Fri, 24 Sep 2021 23:46:34 -0700 (PDT) Received: from localhost ([::1]:43480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1SD-0001tx-94 for importer@patchew.org; Sat, 25 Sep 2021 02:46:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU189-0007fx-Bw for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007Mx-58 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-aOTH9cRYP1izjX0H5Y8Cqw-1; Sat, 25 Sep 2021 02:25:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87246802936; Sat, 25 Sep 2021 06:25:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66CB4652AB; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 685301135A4D; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dh1qCXcBy1PNpZRi3lXvaT/kUO2EqqJepPg2N+BW8uc=; b=R3QkT3ph1QLlYPByLjbT+n2CfUY2uS5hctcR0kGkRi0HjiZSiuROm3AMIoS57jmMr5BD6C 4+upw3NFhK5ymZlhPCiZ6u76NhGRlrVwRX0I+ClYBXUrwNQncCOhMWNfuni5fGTwVt5vzS +ILOm1+2sqQMXP0MEuu53QiiCcWKzuU= X-MC-Unique: aOTH9cRYP1izjX0H5Y8Cqw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 23/25] test-clone-visitor: Correct an accidental rename Date: Sat, 25 Sep 2021 08:25:23 +0200 Message-Id: <20210925062525.988405-24-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552395934100001 Commit b359f4b203 "tests: Rename UserDefNativeListUnion to UserDefListUnion" renamed test_clone_native_list() to test_clone_list_union(). The function has nothing to do with unions. Rename it to test_clone_list(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20210917143134.412106-24-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-clone-visitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-clone-visitor.c b/tests/unit/test-clone-visito= r.c index 4048018607..5d48e125b8 100644 --- a/tests/unit/test-clone-visitor.c +++ b/tests/unit/test-clone-visitor.c @@ -63,7 +63,7 @@ static void test_clone_alternate(void) qapi_free_AltEnumBool(s_dst); } =20 -static void test_clone_list_union(void) +static void test_clone_list(void) { uint8List *src =3D NULL, *dst; uint8List *tmp =3D NULL; @@ -203,7 +203,7 @@ int main(int argc, char **argv) =20 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/list_union", test_clone_list_union); + g_test_add_func("/visitor/clone/list", test_clone_list); 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); --=20 2.31.1 From nobody Fri May 17 11:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632552130; cv=none; d=zohomail.com; s=zohoarc; b=gc/w+U0r3R99NTeZkehiL/Y18i7Aj1KRdHXvzP/s4PnSSrCha6xia34JC5CcFVPmrN0Pqhalaq98EiGxFk/nqLTSWxZm66P1wPEgeghtpMPnLLghlclfYBv/xEacsXpla6ZPjxlz2Ujk5+XzsooRfTUsseO7WRkLFnzChl5b5FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632552130; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LSG/uh8jCjcZoH005UyBUF4D20nFAhsXpBisETAju9A=; b=BzI+9dbk4QkF9Usm1RDn5HVsuNaBX2KTQ6hUL2STtOuMaA1m/VKw6cPsQJZB/Y1F1IL/p4wap0tguATyA6gObPcHvnxS7fjyEyAAw64VE7MlHOsuRnWkaaDmqhaeMnrKpNYF7DbJIG7arp8rO8YKeeXbmTprVHDZzdd88iOERTU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632552130770926.8565974205212; Fri, 24 Sep 2021 23:42:10 -0700 (PDT) Received: from localhost ([::1]:35314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1Nw-0004kA-Op for importer@patchew.org; Sat, 25 Sep 2021 02:42:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU188-0007fR-IM for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU180-0007Le-P8 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-aqyMkI5fM46F2tt0a7hwnQ-1; Sat, 25 Sep 2021 02:25:36 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98FC78145E5; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6ADB35D740; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6B84F1135A7F; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LSG/uh8jCjcZoH005UyBUF4D20nFAhsXpBisETAju9A=; b=GLaez9uMJQOhmHRiVbXUPJlPeA1qgBjknxfPdCsd9bOwia345UzNWuaymOlely7PlCRbNd XFqQDHNsCgl4V55Ccy0RWlZv/5yPZQoh4SuDK/Dd+7RN2RCt+I+MVNbNWuM+27miq61H/b 04t/WBbza21B0UEmnGVSatfhFTFHKXw= X-MC-Unique: aqyMkI5fM46F2tt0a7hwnQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 24/25] tests/qapi-schema: Use Python OSError instead of outmoded IOError Date: Sat, 25 Sep 2021 08:25:24 +0200 Message-Id: <20210925062525.988405-25-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632552131038100001 https://docs.python.org/3.6/library/exceptions.html has Changed in version 3.3: EnvironmentError, IOError, WindowsError, socket.error, select.error and mmap.error have been merged into OSError, and the constructor may return a subclass. and The following exceptions are kept for compatibility with previous versions; starting from Python 3.3, they are aliases of OSError. exception EnvironmentError exception IOError exception WindowsError Only available on Windows. Switch to the preferred name. Signed-off-by: Markus Armbruster Message-Id: <20210922125619.670673-2-armbru@redhat.com> Reviewed-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 [Details added to commit message] --- tests/qapi-schema/test-qapi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 73cffae2b6..2e384f5efd 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -154,7 +154,7 @@ def test_and_diff(test_name, dir_name, update): errfp =3D open(os.path.join(dir_name, test_name + '.err'), mode) expected_out =3D outfp.readlines() expected_err =3D errfp.readlines() - except IOError as err: + except OSError as err: print("%s: can't open '%s': %s" % (sys.argv[0], err.filename, err.strerror), file=3Dsys.stderr) @@ -180,7 +180,7 @@ def test_and_diff(test_name, dir_name, update): errfp.truncate(0) errfp.seek(0) errfp.writelines(actual_err) - except IOError as err: + except OSError as err: print("%s: can't write '%s': %s" % (sys.argv[0], err.filename, err.strerror), file=3Dsys.stderr) --=20 2.31.1 From nobody Fri May 17 11:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632551791; cv=none; d=zohomail.com; s=zohoarc; b=kKe+rrrG/tntLkd3o+i2xjWotlfgUDL/E7KRFJnD6DLAkKWnrk5W3btkFpNq0IOIsW4uUpbN8wRwxofzWbvwTX9kZldR+FU2K09IjDIPv2EeDEeOdymtn7M1JSy37mqFR/qDvTE0dbZCIXdczC3vv0H1BYM0y6uEs4QykX3Zztk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632551791; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fjPpMnc58DLxC5DY4u0Ib6Ur9fvVvDsCHwZCAzUfZVo=; b=fOSdjXVyZWHMnJFESa305KZM6siCnK7QZ11owURIqSsy7HwT1cTnrfEzHWCdrB0FjSG5wVYVUyLk0ufKntwhwEb6GUS+kteLW851Uv+TwNWf78h8VcM1LEuYLDqaLyrV07Pxm8n9oWRb5TqgA2QNADoIF6mZkj1NKFsZRMVwArI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632551791392944.5545959874007; Fri, 24 Sep 2021 23:36:31 -0700 (PDT) Received: from localhost ([::1]:49958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU1IU-0003d3-67 for importer@patchew.org; Sat, 25 Sep 2021 02:36:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU189-0007g4-E3 for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU183-0007Lj-5b for qemu-devel@nongnu.org; Sat, 25 Sep 2021 02:25:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-VTY0_5I-NfGSljBM_JZ9jA-1; Sat, 25 Sep 2021 02:25:37 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB3BA802921; Sat, 25 Sep 2021 06:25:36 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FB5119736; Sat, 25 Sep 2021 06:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6EE6D1135221; Sat, 25 Sep 2021 08:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632551140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fjPpMnc58DLxC5DY4u0Ib6Ur9fvVvDsCHwZCAzUfZVo=; b=CmZ17oKUxnXTrDEyYcf93vsmJ0WlueJuw+ltiCxucxC1U1eywpXtdHYRh56XyKNLhg9tv8 oZzOn88VpXX50xt6yP7doHFcOodL6rnkIkOLWnCZ+zQxTng6ZYqhoKAwXtjYyE4I4MbHCX 45gqHDZW0lpHejmxbvzNksN8HXJCiyQ= X-MC-Unique: VTY0_5I-NfGSljBM_JZ9jA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 25/25] tests/qapi-schema: Make test-qapi.py -u work when files are absent Date: Sat, 25 Sep 2021 08:25:25 +0200 Message-Id: <20210925062525.988405-26-armbru@redhat.com> In-Reply-To: <20210925062525.988405-1-armbru@redhat.com> References: <20210925062525.988405-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632551792080100001 Content-Type: text/plain; charset="utf-8" test-qapi.py -u updates the expected files. Since it fails when they are absent, users have to create them manually before they can use test-qapi.py to fill in the contents, say for a new test. Silly. Improve -u to create them. Signed-off-by: Markus Armbruster Message-Id: <20210922125619.670673-3-armbru@redhat.com> Reviewed-by: John Snow --- tests/qapi-schema/test-qapi.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 2e384f5efd..c717a7a90b 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -132,6 +132,17 @@ def test_frontend(fname): print(' section=3D%s\n%s' % (section.name, section.text)) =20 =20 +def open_test_result(dir_name, file_name, update): + mode =3D 'r+' if update else 'r' + try: + fp =3D open(os.path.join(dir_name, file_name), mode) + except FileNotFoundError: + if not update: + raise + fp =3D open(os.path.join(dir_name, file_name), 'w+') + return fp + + def test_and_diff(test_name, dir_name, update): sys.stdout =3D StringIO() try: @@ -148,10 +159,9 @@ def test_and_diff(test_name, dir_name, update): sys.stdout.close() sys.stdout =3D sys.__stdout__ =20 - mode =3D 'r+' if update else 'r' try: - outfp =3D open(os.path.join(dir_name, test_name + '.out'), mode) - errfp =3D open(os.path.join(dir_name, test_name + '.err'), mode) + outfp =3D open_test_result(dir_name, test_name + '.out', update) + errfp =3D open_test_result(dir_name, test_name + '.err', update) expected_out =3D outfp.readlines() expected_err =3D errfp.readlines() except OSError as err: --=20 2.31.1