From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570461739; cv=none; d=zoho.com; s=zohoarc; b=Fn6X9ZDbW8rMoM/KOhHd0jqVqmI4YU79m41mRQfwkHYTp3DCxBTC0ooEKCcL+AkJzyVoU/4luO7CfX9pE3Do07aJ1U0QXdnB+bz/OjqeJmRBrL0cB9lL0Yrzx6OJ7qH4EGivGwWR0/haVgsMpInu8R7ubBcd6R1QeU+lmfiW1sQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461739; 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:ARC-Authentication-Results; bh=aTyTPuQLjPJeIxv8TwwS0lYyMlSdzv9qk+g9EsGhurw=; b=PLNjjzfSg3Oho4AImB47TlZQ6axbKGG6VGJK9rb3kEuJshSwKP1IedtOk5i6afOht6QMCVXbjW9N48ioOAv7XovixUTGFgVgQsY6JSt+mLIkd++4AX/3CRDNI4Jn3M61sf0vB2YmHUi5c2jgVVRsLPh1xakbGkEzr0PtFQW9urA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570461739310254.19788281233104; Mon, 7 Oct 2019 08:22:19 -0700 (PDT) Received: from localhost ([::1]:45994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUpz-00049P-DT for importer@patchew.org; Mon, 07 Oct 2019 11:22:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47282) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUnI-0002QE-2e for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUnG-0007th-Hm for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUnG-0007tE-BR for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:26 -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 mx1.redhat.com (Postfix) with ESMTPS id 91C5E309DEF2; Mon, 7 Oct 2019 15:19:25 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D29C19D70; Mon, 7 Oct 2019 15:19:20 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/7] tests/libqos/fw_cfg: Document io_fw_cfg_init to drop io_fw_cfg_uninit Date: Mon, 7 Oct 2019 17:18:59 +0200 Message-Id: <20191007151905.32766-2-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 07 Oct 2019 15:19:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Document io_fw_cfg_init() return value must be released with g_free(). Directly calling g_free() we don't really need io_fw_cfg_uninit(): remove it. This partly reverts commit 0729d833d6d6: "tests/libqos: Add io_fw_cfg_uninit()" Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang --- tests/libqos/fw_cfg.c | 5 ----- tests/libqos/fw_cfg.h | 11 +++++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index 1f46258f96..37c3f2cf4d 100644 --- a/tests/libqos/fw_cfg.c +++ b/tests/libqos/fw_cfg.c @@ -157,8 +157,3 @@ QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base) =20 return fw_cfg; } - -void io_fw_cfg_uninit(QFWCFG *fw_cfg) -{ - g_free(fw_cfg); -} diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 13325cc4ff..15604040bd 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -36,8 +36,15 @@ size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *file= name, =20 QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); void mm_fw_cfg_uninit(QFWCFG *fw_cfg); +/** + * io_fw_cfg_init(): + * @qts: The #QTestState that will be referred to by the QFWCFG object. + * @base: The I/O address of the fw_cfg device in the guest. + * + * Returns a newly allocated QFWCFG object which must be released + * with a call to g_free() when no longer required. + */ QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); -void io_fw_cfg_uninit(QFWCFG *fw_cfg); =20 static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) { @@ -46,7 +53,7 @@ static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) =20 static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg) { - io_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); } =20 #endif --=20 2.21.0 From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570461762; cv=none; d=zoho.com; s=zohoarc; b=AF/od50dAga+fQyrydtd1tQsk3BLJqe0XbQrawlNirqabFgYw8qCZNzg5hjLSD36tLM9BjAEPpCDTSojG/i1N8ItItqWJaEll6mlG0+FBFSdxiDUct/4fdbs7bM18EBv2QF1dZMTJTHrDjEl5B1YLmQ/pa5vDcdUQQs8DugxJ68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461762; 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:ARC-Authentication-Results; bh=6jxmfj4QU/sVCQTrnpKFvz2ruOJcfQnG5WxdyF4viXc=; b=Z7VefQilDkv45MEiaKxMDiWrsPS1DYC/QM7iuTp2ODazMHYJGk8GVwe7mK9viFtUZ9sJav3HEAfuQp7xjfWPUq9Va7J64vNh9OJ1Zqh0a8z4QDiZop3hQYad21y0H4bCnQhgokaadgs5AnCk7CHbAkNc8Zg/nBMuEVwt+HWQwzA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570461762942392.3878531305173; Mon, 7 Oct 2019 08:22:42 -0700 (PDT) Received: from localhost ([::1]:45998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUqM-0004Yf-SG for importer@patchew.org; Mon, 07 Oct 2019 11:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47397) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUnk-0002rF-AN for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUni-0008I7-BY for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUni-0008FV-49 for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:54 -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 mx1.redhat.com (Postfix) with ESMTPS id 4E7BE30ADBBF; Mon, 7 Oct 2019 15:19:52 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10F2719D70; Mon, 7 Oct 2019 15:19:25 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] tests/libqos/fw_cfg: Document mm_fw_cfg_init to drop mm_fw_cfg_uninit Date: Mon, 7 Oct 2019 17:19:00 +0200 Message-Id: <20191007151905.32766-3-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 07 Oct 2019 15:19:52 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Document mm_fw_cfg_init() return value must be released with g_free(). mm_fw_cfg_uninit() was never used, remove it. This partly reverts commit 0729d833d6d6: "tests/libqos: Add mm_fw_cfg_uninit()" Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang --- tests/libqos/fw_cfg.c | 5 ----- tests/libqos/fw_cfg.h | 10 +++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index 37c3f2cf4d..ddeec821db 100644 --- a/tests/libqos/fw_cfg.c +++ b/tests/libqos/fw_cfg.c @@ -126,11 +126,6 @@ QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base) return fw_cfg; } =20 -void mm_fw_cfg_uninit(QFWCFG *fw_cfg) -{ - g_free(fw_cfg); -} - static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { qtest_outw(fw_cfg->qts, fw_cfg->base, key); diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 15604040bd..3247fd4000 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -34,8 +34,16 @@ uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key); size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename, void *data, size_t buflen); =20 +/** + * mm_fw_cfg_init(): + * @qts: The #QTestState that will be referred to by the QFWCFG object. + * @base: The MMIO base address of the fw_cfg device in the guest. + * + * Returns a newly allocated QFWCFG object which must be released + * with a call to g_free() when no longer required. + */ QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); -void mm_fw_cfg_uninit(QFWCFG *fw_cfg); + /** * io_fw_cfg_init(): * @qts: The #QTestState that will be referred to by the QFWCFG object. --=20 2.21.0 From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570461938; cv=none; d=zoho.com; s=zohoarc; b=ByTiCMDhoHTWlj7ND+zjvVWodtClsMZ9LWjtGcID0EgXp0g+84L4sDExb5WBmrbyaz7q9CO7L5wU66q2fP73IeTezj2U9BLx7CypFHjWgVotkuA6eaMqH/SHUwgvAKrIezFmgoSxMDrrIvytDqmMCGhUSP/qmyqrgg5PXf6p9Og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461938; 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:ARC-Authentication-Results; bh=z2qwLPh70fbtsKQIb8Y4e2hrVbYKTuIpXomwqULclps=; b=F9QRSWoxZg3fPCXSw01sT+/+9yDyiQeL9dm4r0nlsghSWwb2hoz0YaxUsb6m6mJufEJOswmjMEKjtHdpJdVoKVzZTu3Kt0hkZQdgAGfD0xFbaPbpTI6apMUSC1ZC2yWFwYOjFc8Iuj4nZ50RDDGZr2mczkrcAc3ClaSKVVX/Ss8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570461938895313.9545761492707; Mon, 7 Oct 2019 08:25:38 -0700 (PDT) Received: from localhost ([::1]:46022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUtA-0007eh-L5 for importer@patchew.org; Mon, 07 Oct 2019 11:25:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47410) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUno-0002ts-5E for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUnm-0008Ly-SB for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41681) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUnk-0008Iy-8X for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:56 -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 mx1.redhat.com (Postfix) with ESMTPS id 4789E8A1CAE; Mon, 7 Oct 2019 15:19:55 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF16519C5B; Mon, 7 Oct 2019 15:19:52 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] tests/libqos/fw_cfg: Document pc_fw_cfg_init to drop pc_fw_cfg_uninit Date: Mon, 7 Oct 2019 17:19:01 +0200 Message-Id: <20191007151905.32766-4-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 07 Oct 2019 15:19:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Document pc_fw_cfg_init() return value must be released with g_free(). Directly calling g_free() we don't really need pc_fw_cfg_uninit(): remove it. This reverts commit 65461d124363: "tests/libqos: Add pc_fw_cfg_uninit() and use it" Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang --- tests/fw_cfg-test.c | 22 +++++++++++----------- tests/libqos/fw_cfg.h | 14 +++++++++----- tests/libqos/malloc-pc.c | 2 +- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 1d3147f821..53ae82f7c8 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -36,7 +36,7 @@ static void test_fw_cfg_signature(void) buf[4] =3D 0; =20 g_assert_cmpstr(buf, =3D=3D, "QEMU"); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -52,7 +52,7 @@ static void test_fw_cfg_id(void) id =3D qfw_cfg_get_u32(fw_cfg, FW_CFG_ID); g_assert((id =3D=3D 1) || (id =3D=3D 3)); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -73,7 +73,7 @@ static void test_fw_cfg_uuid(void) qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16); g_assert(memcmp(buf, uuid, sizeof(buf)) =3D=3D 0); =20 - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); =20 } @@ -88,7 +88,7 @@ static void test_fw_cfg_ram_size(void) =20 g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), =3D=3D, ram_= size); =20 - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -102,7 +102,7 @@ static void test_fw_cfg_nographic(void) =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), =3D=3D, 0); =20 - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -116,7 +116,7 @@ static void test_fw_cfg_nb_cpus(void) =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), =3D=3D, nb_cp= us); =20 - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -129,7 +129,7 @@ static void test_fw_cfg_max_cpus(void) fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), =3D=3D, max_= cpus); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -158,7 +158,7 @@ static void test_fw_cfg_numa(void) =20 g_free(node_mask); g_free(cpu_mask); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -171,7 +171,7 @@ static void test_fw_cfg_boot_menu(void) fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), =3D=3D, boo= t_menu); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -190,7 +190,7 @@ static void test_fw_cfg_reboot_timeout(void) g_assert_cmpint(filesize, =3D=3D, sizeof(reboot_timeout)); reboot_timeout =3D le32_to_cpu(reboot_timeout); g_assert_cmpint(reboot_timeout, =3D=3D, 15); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 @@ -209,7 +209,7 @@ static void test_fw_cfg_splash_time(void) g_assert_cmpint(filesize, =3D=3D, sizeof(splash_time)); splash_time =3D le16_to_cpu(splash_time); g_assert_cmpint(splash_time, =3D=3D, 12); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } =20 diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 3247fd4000..6316f4c354 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -54,14 +54,18 @@ QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); */ QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); =20 +/** + * pc_fw_cfg_init(): + * @qts: The #QTestState that will be referred to by the QFWCFG object. + * + * This function is specific to the PC machine (X86). + * + * Returns a newly allocated QFWCFG object which must be released + * with a call to g_free() when no longer required. + */ static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) { return io_fw_cfg_init(qts, 0x510); } =20 -static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg) -{ - g_free(fw_cfg); -} - #endif diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c index 6f92ce4135..949a99361d 100644 --- a/tests/libqos/malloc-pc.c +++ b/tests/libqos/malloc-pc.c @@ -29,5 +29,5 @@ void pc_alloc_init(QGuestAllocator *s, QTestState *qts, Q= AllocOpts flags) alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), PAGE_SIZE); =20 /* clean-up */ - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); } --=20 2.21.0 From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570461971; cv=none; d=zoho.com; s=zohoarc; b=Iz1hQFqWjHJoUxY8O0KK/0i4P6PTNffpKGn26QKOkti7yz5Q4EsT18PX+nXgf2QellpXJDB5uSnBlcKzSrS3Yozmuuqr8AjTQVIwrIGTcZUpprLDxwicUI556kZQOXmakkyJuGi4SF/vds81ZMkm/99hG7Bvm7kJANwIO/eK7vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461971; 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:ARC-Authentication-Results; bh=F6uH387Yd5qT1tPxnY5E5VpoT12GSqqm23yLlJZ81l4=; b=d0eRmoNpxWHNvW0iN1wkvcLcCbFwbiM5wrwzF2gfccsEDZ3tu9sm3FrJSaLJW10mUGE8JuGeRdAareGiqcIyDKV7463SwFsGKHO8Udre3LGIOIvh+TTaRm68oNgPonSoAb8XWN9/AaealOsCGOt3BTVtXIvXhEILAMyhuewiDIk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570461970998545.6774669714712; Mon, 7 Oct 2019 08:26:10 -0700 (PDT) Received: from localhost ([::1]:46028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUtl-0008GO-SJ for importer@patchew.org; Mon, 07 Oct 2019 11:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47432) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUnr-0002yb-RX for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUnq-0008P1-2E for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUnp-0008Nq-Pn for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:02 -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 mx1.redhat.com (Postfix) with ESMTPS id 110D030B9BED; Mon, 7 Oct 2019 15:20:01 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF81C19C5B; Mon, 7 Oct 2019 15:19:55 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/7] tests/fw_cfg: Let the tests use a context Date: Mon, 7 Oct 2019 17:19:02 +0200 Message-Id: <20191007151905.32766-5-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 07 Oct 2019 15:20:01 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Introduce the local QTestCtx structure, and register the tests with qtest_add_data_func(ctx). For now the context only contains the machine name (which is fixed to the 'pc' machine, since this test only runs on the x86 architecture). Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang --- v2: Use const QTestCtx *ctx, do not g_new(QTestCtx) (Laszlo) --- tests/fw_cfg-test.c | 87 ++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 53ae82f7c8..65785bca73 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -23,13 +23,18 @@ static uint16_t max_cpus =3D 1; static uint64_t nb_nodes =3D 0; static uint16_t boot_menu =3D 0; =20 -static void test_fw_cfg_signature(void) +typedef struct { + const char *machine_name; +} QTestCtx; + +static void test_fw_cfg_signature(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; char buf[5]; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4); @@ -40,13 +45,14 @@ static void test_fw_cfg_signature(void) qtest_quit(s); } =20 -static void test_fw_cfg_id(void) +static void test_fw_cfg_id(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; uint32_t id; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 id =3D qfw_cfg_get_u32(fw_cfg, FW_CFG_ID); @@ -56,8 +62,9 @@ static void test_fw_cfg_id(void) qtest_quit(s); } =20 -static void test_fw_cfg_uuid(void) +static void test_fw_cfg_uuid(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; =20 @@ -67,7 +74,8 @@ static void test_fw_cfg_uuid(void) 0x8a, 0xcb, 0x81, 0xc6, 0xea, 0x54, 0xf2, 0xd8, }; =20 - s =3D qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8"); + s =3D qtest_initf("-M %s -uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8", + ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16); @@ -78,12 +86,13 @@ static void test_fw_cfg_uuid(void) =20 } =20 -static void test_fw_cfg_ram_size(void) +static void test_fw_cfg_ram_size(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), =3D=3D, ram_= size); @@ -92,12 +101,13 @@ static void test_fw_cfg_ram_size(void) qtest_quit(s); } =20 -static void test_fw_cfg_nographic(void) +static void test_fw_cfg_nographic(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), =3D=3D, 0); @@ -106,12 +116,13 @@ static void test_fw_cfg_nographic(void) qtest_quit(s); } =20 -static void test_fw_cfg_nb_cpus(void) +static void test_fw_cfg_nb_cpus(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), =3D=3D, nb_cp= us); @@ -120,12 +131,13 @@ static void test_fw_cfg_nb_cpus(void) qtest_quit(s); } =20 -static void test_fw_cfg_max_cpus(void) +static void test_fw_cfg_max_cpus(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), =3D=3D, max_= cpus); @@ -133,14 +145,15 @@ static void test_fw_cfg_max_cpus(void) qtest_quit(s); } =20 -static void test_fw_cfg_numa(void) +static void test_fw_cfg_numa(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; uint64_t *cpu_mask; uint64_t *node_mask; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_NUMA), =3D=3D, nb_nodes= ); @@ -162,12 +175,13 @@ static void test_fw_cfg_numa(void) qtest_quit(s); } =20 -static void test_fw_cfg_boot_menu(void) +static void test_fw_cfg_boot_menu(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; =20 - s =3D qtest_init(""); + s =3D qtest_initf("-M %s", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), =3D=3D, boo= t_menu); @@ -175,14 +189,15 @@ static void test_fw_cfg_boot_menu(void) qtest_quit(s); } =20 -static void test_fw_cfg_reboot_timeout(void) +static void test_fw_cfg_reboot_timeout(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; uint32_t reboot_timeout =3D 0; size_t filesize; =20 - s =3D qtest_init("-boot reboot-timeout=3D15"); + s =3D qtest_initf("-M %s -boot reboot-timeout=3D15", ctx->machine_name= ); fw_cfg =3D pc_fw_cfg_init(s); =20 filesize =3D qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait", @@ -194,14 +209,15 @@ static void test_fw_cfg_reboot_timeout(void) qtest_quit(s); } =20 -static void test_fw_cfg_splash_time(void) +static void test_fw_cfg_splash_time(const void *opaque) { + const QTestCtx *ctx =3D opaque; QFWCFG *fw_cfg; QTestState *s; uint16_t splash_time =3D 0; size_t filesize; =20 - s =3D qtest_init("-boot splash-time=3D12"); + s =3D qtest_initf("-M %s -boot splash-time=3D12", ctx->machine_name); fw_cfg =3D pc_fw_cfg_init(s); =20 filesize =3D qfw_cfg_get_file(fw_cfg, "etc/boot-menu-wait", @@ -215,25 +231,30 @@ static void test_fw_cfg_splash_time(void) =20 int main(int argc, char **argv) { + QTestCtx ctx; + g_test_init(&argc, &argv, NULL); =20 - qtest_add_func("fw_cfg/signature", test_fw_cfg_signature); - qtest_add_func("fw_cfg/id", test_fw_cfg_id); - qtest_add_func("fw_cfg/uuid", test_fw_cfg_uuid); - qtest_add_func("fw_cfg/ram_size", test_fw_cfg_ram_size); - qtest_add_func("fw_cfg/nographic", test_fw_cfg_nographic); - qtest_add_func("fw_cfg/nb_cpus", test_fw_cfg_nb_cpus); + ctx.machine_name =3D "pc"; + + qtest_add_data_func("fw_cfg/signature", &ctx, test_fw_cfg_signature); + qtest_add_data_func("fw_cfg/id", &ctx, test_fw_cfg_id); + qtest_add_data_func("fw_cfg/uuid", &ctx, test_fw_cfg_uuid); + qtest_add_data_func("fw_cfg/ram_size", &ctx, test_fw_cfg_ram_size); + qtest_add_data_func("fw_cfg/nographic", &ctx, test_fw_cfg_nographic); + qtest_add_data_func("fw_cfg/nb_cpus", &ctx, test_fw_cfg_nb_cpus); #if 0 qtest_add_func("fw_cfg/machine_id", test_fw_cfg_machine_id); qtest_add_func("fw_cfg/kernel", test_fw_cfg_kernel); qtest_add_func("fw_cfg/initrd", test_fw_cfg_initrd); qtest_add_func("fw_cfg/boot_device", test_fw_cfg_boot_device); #endif - qtest_add_func("fw_cfg/max_cpus", test_fw_cfg_max_cpus); - qtest_add_func("fw_cfg/numa", test_fw_cfg_numa); - qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu); - qtest_add_func("fw_cfg/reboot_timeout", test_fw_cfg_reboot_timeout); - qtest_add_func("fw_cfg/splash_time", test_fw_cfg_splash_time); + qtest_add_data_func("fw_cfg/max_cpus", &ctx, test_fw_cfg_max_cpus); + qtest_add_data_func("fw_cfg/numa", &ctx, test_fw_cfg_numa); + qtest_add_data_func("fw_cfg/boot_menu", &ctx, test_fw_cfg_boot_menu); + qtest_add_data_func("fw_cfg/reboot_timeout", &ctx, + test_fw_cfg_reboot_timeout); + qtest_add_data_func("fw_cfg/splash_time", &ctx, test_fw_cfg_splash_tim= e); =20 return g_test_run(); } --=20 2.21.0 From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570462033; cv=none; d=zoho.com; s=zohoarc; b=POd+p7Sab3PSqdSmJK2CGdDJE6RfqoG6ignYvhMgG3rNAVSKxrHNgz8Toa84+LhbNhXgaEV7M0jYFv0Bv7/L1PNBgw1lNYMSW+Pxw1EAS/U1VAIS58gfRv+9l3fK09k97DRVJR44tgEbWjUfhoaYgbRsXyVGv2x8dqkMGWhv5+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570462033; 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:ARC-Authentication-Results; bh=AL/7y46PhSCzdZTA8IsPf64ZzG9lHz8lXznmK3h+SZk=; b=iQ5RwV1+cjkiuoFkybQRmp32WXL2BNFrMXCmNa9e0D4H6FvDomUYuY2R1bSxfHgnyUooBKZFflKPOgfEWgZlJekdW8bRO8dViGLo1KaMcwGTYnzx5HahfFSJh/yZvOBScvUTs8QBpxFxG0H9nlF2pXPzCy7kTmRmpTXtB+/G3SI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570462033719621.3344667930378; Mon, 7 Oct 2019 08:27:13 -0700 (PDT) Received: from localhost ([::1]:46032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUuh-0000J6-6x for importer@patchew.org; Mon, 07 Oct 2019 11:27:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47525) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUoB-00039Z-8b for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUo8-00008Z-1s for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUo6-00006t-4I for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:19 -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 mx1.redhat.com (Postfix) with ESMTPS id D40AC859FC; Mon, 7 Oct 2019 15:20:16 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 827CC19C5B; Mon, 7 Oct 2019 15:20:01 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] tests/libqos/fw_cfg: Pass QTestState as argument Date: Mon, 7 Oct 2019 17:19:03 +0200 Message-Id: <20191007151905.32766-6-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Oct 2019 15:20:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since a QFWCFG object is not tied to a particular test, we can call *_fw_cfg_init() once before creating QTests and use the same for all the tests, then release the object with g_free() once all the tests are run. Refactor the qfw_cfg* API to take QTestState as argument. Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang --- tests/boot-order-test.c | 12 ++++---- tests/fw_cfg-test.c | 49 ++++++++++++++++---------------- tests/libqos/fw_cfg.c | 61 ++++++++++++++++++++-------------------- tests/libqos/fw_cfg.h | 31 +++++++++----------- tests/libqos/malloc-pc.c | 4 +-- 5 files changed, 78 insertions(+), 79 deletions(-) diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index a725bce729..e2d1b7940f 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -134,9 +134,9 @@ static void test_prep_boot_order(void) =20 static uint64_t read_boot_order_pmac(QTestState *qts) { - QFWCFG *fw_cfg =3D mm_fw_cfg_init(qts, 0xf0000510); + QFWCFG *fw_cfg =3D mm_fw_cfg_init(0xf0000510); =20 - return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); + return qfw_cfg_get_u16(qts, fw_cfg, FW_CFG_BOOT_DEVICE); } =20 static const boot_order_test test_cases_fw_cfg[] =3D { @@ -159,9 +159,9 @@ static void test_pmac_newworld_boot_order(void) =20 static uint64_t read_boot_order_sun4m(QTestState *qts) { - QFWCFG *fw_cfg =3D mm_fw_cfg_init(qts, 0xd00000510ULL); + QFWCFG *fw_cfg =3D mm_fw_cfg_init(0xd00000510ULL); =20 - return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); + return qfw_cfg_get_u16(qts, fw_cfg, FW_CFG_BOOT_DEVICE); } =20 static void test_sun4m_boot_order(void) @@ -171,9 +171,9 @@ static void test_sun4m_boot_order(void) =20 static uint64_t read_boot_order_sun4u(QTestState *qts) { - QFWCFG *fw_cfg =3D io_fw_cfg_init(qts, 0x510); + QFWCFG *fw_cfg =3D io_fw_cfg_init(0x510); =20 - return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); + return qfw_cfg_get_u16(qts, fw_cfg, FW_CFG_BOOT_DEVICE); } =20 static void test_sun4u_boot_order(void) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 65785bca73..dda9a9fb07 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -35,9 +35,9 @@ static void test_fw_cfg_signature(const void *opaque) char buf[5]; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4); + qfw_cfg_get(s, fw_cfg, FW_CFG_SIGNATURE, buf, 4); buf[4] =3D 0; =20 g_assert_cmpstr(buf, =3D=3D, "QEMU"); @@ -53,9 +53,9 @@ static void test_fw_cfg_id(const void *opaque) uint32_t id; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - id =3D qfw_cfg_get_u32(fw_cfg, FW_CFG_ID); + id =3D qfw_cfg_get_u32(s, fw_cfg, FW_CFG_ID); g_assert((id =3D=3D 1) || (id =3D=3D 3)); g_free(fw_cfg); @@ -76,9 +76,9 @@ static void test_fw_cfg_uuid(const void *opaque) =20 s =3D qtest_initf("-M %s -uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16); + qfw_cfg_get(s, fw_cfg, FW_CFG_UUID, buf, 16); g_assert(memcmp(buf, uuid, sizeof(buf)) =3D=3D 0); =20 g_free(fw_cfg); @@ -93,9 +93,9 @@ static void test_fw_cfg_ram_size(const void *opaque) QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), =3D=3D, ram_= size); + g_assert_cmpint(qfw_cfg_get_u64(s, fw_cfg, FW_CFG_RAM_SIZE), =3D=3D, r= am_size); =20 g_free(fw_cfg); qtest_quit(s); @@ -108,9 +108,9 @@ static void test_fw_cfg_nographic(const void *opaque) QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), =3D=3D, 0); + g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_NOGRAPHIC), =3D=3D, = 0); =20 g_free(fw_cfg); qtest_quit(s); @@ -123,9 +123,9 @@ static void test_fw_cfg_nb_cpus(const void *opaque) QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), =3D=3D, nb_cp= us); + g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_NB_CPUS), =3D=3D, nb= _cpus); =20 g_free(fw_cfg); qtest_quit(s); @@ -138,9 +138,9 @@ static void test_fw_cfg_max_cpus(const void *opaque) QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), =3D=3D, max_= cpus); + g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_MAX_CPUS), =3D=3D, m= ax_cpus); g_free(fw_cfg); qtest_quit(s); } @@ -154,15 +154,15 @@ static void test_fw_cfg_numa(const void *opaque) uint64_t *node_mask; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_NUMA), =3D=3D, nb_nodes= ); + g_assert_cmpint(qfw_cfg_get_u64(s, fw_cfg, FW_CFG_NUMA), =3D=3D, nb_no= des); =20 cpu_mask =3D g_new0(uint64_t, max_cpus); node_mask =3D g_new0(uint64_t, nb_nodes); =20 - qfw_cfg_read_data(fw_cfg, cpu_mask, sizeof(uint64_t) * max_cpus); - qfw_cfg_read_data(fw_cfg, node_mask, sizeof(uint64_t) * nb_nodes); + qfw_cfg_read_data(s, fw_cfg, cpu_mask, sizeof(uint64_t) * max_cpus); + qfw_cfg_read_data(s, fw_cfg, node_mask, sizeof(uint64_t) * nb_nodes); =20 if (nb_nodes) { g_assert(cpu_mask[0] & 0x01); @@ -182,9 +182,10 @@ static void test_fw_cfg_boot_menu(const void *opaque) QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), =3D=3D, boo= t_menu); + g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_BOOT_MENU), + =3D=3D, boot_menu); g_free(fw_cfg); qtest_quit(s); } @@ -198,9 +199,9 @@ static void test_fw_cfg_reboot_timeout(const void *opaq= ue) size_t filesize; =20 s =3D qtest_initf("-M %s -boot reboot-timeout=3D15", ctx->machine_name= ); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - filesize =3D qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait", + filesize =3D qfw_cfg_get_file(s, fw_cfg, "etc/boot-fail-wait", &reboot_timeout, sizeof(reboot_timeout)); g_assert_cmpint(filesize, =3D=3D, sizeof(reboot_timeout)); reboot_timeout =3D le32_to_cpu(reboot_timeout); @@ -218,9 +219,9 @@ static void test_fw_cfg_splash_time(const void *opaque) size_t filesize; =20 s =3D qtest_initf("-M %s -boot splash-time=3D12", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(s); + fw_cfg =3D pc_fw_cfg_init(); =20 - filesize =3D qfw_cfg_get_file(fw_cfg, "etc/boot-menu-wait", + filesize =3D qfw_cfg_get_file(s, fw_cfg, "etc/boot-menu-wait", &splash_time, sizeof(splash_time)); g_assert_cmpint(filesize, =3D=3D, sizeof(splash_time)); splash_time =3D le16_to_cpu(splash_time); diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index ddeec821db..d25a367194 100644 --- a/tests/libqos/fw_cfg.c +++ b/tests/libqos/fw_cfg.c @@ -18,46 +18,47 @@ #include "qemu/bswap.h" #include "hw/nvram/fw_cfg.h" =20 -void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key) +void qfw_cfg_select(QTestState *qts, QFWCFG *fw_cfg, uint16_t key) { - fw_cfg->select(fw_cfg, key); + fw_cfg->select(qts, fw_cfg, key); } =20 -void qfw_cfg_read_data(QFWCFG *fw_cfg, void *data, size_t len) +void qfw_cfg_read_data(QTestState *qts, QFWCFG *fw_cfg, void *data, size_t= len) { - fw_cfg->read(fw_cfg, data, len); + fw_cfg->read(qts, fw_cfg, data, len); } =20 -void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len) +void qfw_cfg_get(QTestState *qts, QFWCFG *fw_cfg, uint16_t key, + void *data, size_t len) { - qfw_cfg_select(fw_cfg, key); - qfw_cfg_read_data(fw_cfg, data, len); + qfw_cfg_select(qts, fw_cfg, key); + qfw_cfg_read_data(qts, fw_cfg, data, len); } =20 -uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key) +uint16_t qfw_cfg_get_u16(QTestState *qts, QFWCFG *fw_cfg, uint16_t key) { uint16_t value; - qfw_cfg_get(fw_cfg, key, &value, sizeof(value)); + qfw_cfg_get(qts, fw_cfg, key, &value, sizeof(value)); return le16_to_cpu(value); } =20 -uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key) +uint32_t qfw_cfg_get_u32(QTestState *qts, QFWCFG *fw_cfg, uint16_t key) { uint32_t value; - qfw_cfg_get(fw_cfg, key, &value, sizeof(value)); + qfw_cfg_get(qts, fw_cfg, key, &value, sizeof(value)); return le32_to_cpu(value); } =20 -uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key) +uint64_t qfw_cfg_get_u64(QTestState *qts, QFWCFG *fw_cfg, uint16_t key) { uint64_t value; - qfw_cfg_get(fw_cfg, key, &value, sizeof(value)); + qfw_cfg_get(qts, fw_cfg, key, &value, sizeof(value)); return le64_to_cpu(value); } =20 -static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) +static void mm_fw_cfg_select(QTestState *qts, QFWCFG *fw_cfg, uint16_t key) { - qtest_writew(fw_cfg->qts, fw_cfg->base, key); + qtest_writew(qts, fw_cfg->base, key); } =20 /* @@ -72,8 +73,8 @@ static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) * necessary in total. And, while the caller's buffer has been fully * populated, it has received only a starting slice of the fw_cfg file. */ -size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename, - void *data, size_t buflen) +size_t qfw_cfg_get_file(QTestState *qts, QFWCFG *fw_cfg, const char *filen= ame, + void *data, size_t buflen) { uint32_t count; uint32_t i; @@ -82,11 +83,11 @@ size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *fil= ename, FWCfgFile *pdir_entry; size_t filesize =3D 0; =20 - qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, &count, sizeof(count)); + qfw_cfg_get(qts, fw_cfg, FW_CFG_FILE_DIR, &count, sizeof(count)); count =3D be32_to_cpu(count); dsize =3D sizeof(uint32_t) + count * sizeof(struct fw_cfg_file); filesbuf =3D g_malloc(dsize); - qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize); + qfw_cfg_get(qts, fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize); pdir_entry =3D (FWCfgFile *)(filesbuf + sizeof(uint32_t)); for (i =3D 0; i < count; ++i, ++pdir_entry) { if (!strcmp(pdir_entry->name, filename)) { @@ -96,7 +97,7 @@ size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filen= ame, if (len > buflen) { len =3D buflen; } - qfw_cfg_get(fw_cfg, sel, data, len); + qfw_cfg_get(qts, fw_cfg, sel, data, len); break; } } @@ -104,49 +105,49 @@ size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *f= ilename, return filesize; } =20 -static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len) +static void mm_fw_cfg_read(QTestState *qts, QFWCFG *fw_cfg, + void *data, size_t len) { uint8_t *ptr =3D data; int i; =20 for (i =3D 0; i < len; i++) { - ptr[i] =3D qtest_readb(fw_cfg->qts, fw_cfg->base + 2); + ptr[i] =3D qtest_readb(qts, fw_cfg->base + 2); } } =20 -QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base) +QFWCFG *mm_fw_cfg_init(uint64_t base) { QFWCFG *fw_cfg =3D g_malloc0(sizeof(*fw_cfg)); =20 fw_cfg->base =3D base; - fw_cfg->qts =3D qts; fw_cfg->select =3D mm_fw_cfg_select; fw_cfg->read =3D mm_fw_cfg_read; =20 return fw_cfg; } =20 -static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) +static void io_fw_cfg_select(QTestState *qts, QFWCFG *fw_cfg, uint16_t key) { - qtest_outw(fw_cfg->qts, fw_cfg->base, key); + qtest_outw(qts, fw_cfg->base, key); } =20 -static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len) +static void io_fw_cfg_read(QTestState *qts, QFWCFG *fw_cfg, + void *data, size_t len) { uint8_t *ptr =3D data; int i; =20 for (i =3D 0; i < len; i++) { - ptr[i] =3D qtest_inb(fw_cfg->qts, fw_cfg->base + 1); + ptr[i] =3D qtest_inb(qts, fw_cfg->base + 1); } } =20 -QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base) +QFWCFG *io_fw_cfg_init(uint16_t base) { QFWCFG *fw_cfg =3D g_malloc0(sizeof(*fw_cfg)); =20 fw_cfg->base =3D base; - fw_cfg->qts =3D qts; fw_cfg->select =3D io_fw_cfg_select; fw_cfg->read =3D io_fw_cfg_read; =20 diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 6316f4c354..f9e69be450 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -20,52 +20,49 @@ typedef struct QFWCFG QFWCFG; struct QFWCFG { uint64_t base; - QTestState *qts; - void (*select)(QFWCFG *fw_cfg, uint16_t key); - void (*read)(QFWCFG *fw_cfg, void *data, size_t len); + void (*select)(QTestState *qts, QFWCFG *fw_cfg, uint16_t key); + void (*read)(QTestState *qts, QFWCFG *fw_cfg, void *data, size_t len); }; =20 -void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key); -void qfw_cfg_read_data(QFWCFG *fw_cfg, void *data, size_t len); -void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len); -uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key); -uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key); -uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key); -size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename, +void qfw_cfg_select(QTestState *qts, QFWCFG *fw_cfg, uint16_t key); +void qfw_cfg_read_data(QTestState *qts, QFWCFG *fw_cfg, void *data, size_t= len); +void qfw_cfg_get(QTestState *qts, QFWCFG *fw_cfg, uint16_t key, + void *data, size_t len); +uint16_t qfw_cfg_get_u16(QTestState *qts, QFWCFG *fw_cfg, uint16_t key); +uint32_t qfw_cfg_get_u32(QTestState *qts, QFWCFG *fw_cfg, uint16_t key); +uint64_t qfw_cfg_get_u64(QTestState *qts, QFWCFG *fw_cfg, uint16_t key); +size_t qfw_cfg_get_file(QTestState *qts, QFWCFG *fw_cfg, const char *filen= ame, void *data, size_t buflen); =20 /** * mm_fw_cfg_init(): - * @qts: The #QTestState that will be referred to by the QFWCFG object. * @base: The MMIO base address of the fw_cfg device in the guest. * * Returns a newly allocated QFWCFG object which must be released * with a call to g_free() when no longer required. */ -QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); +QFWCFG *mm_fw_cfg_init(uint64_t base); =20 /** * io_fw_cfg_init(): - * @qts: The #QTestState that will be referred to by the QFWCFG object. * @base: The I/O address of the fw_cfg device in the guest. * * Returns a newly allocated QFWCFG object which must be released * with a call to g_free() when no longer required. */ -QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); +QFWCFG *io_fw_cfg_init(uint16_t base); =20 /** * pc_fw_cfg_init(): - * @qts: The #QTestState that will be referred to by the QFWCFG object. * * This function is specific to the PC machine (X86). * * Returns a newly allocated QFWCFG object which must be released * with a call to g_free() when no longer required. */ -static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) +static inline QFWCFG *pc_fw_cfg_init(void) { - return io_fw_cfg_init(qts, 0x510); + return io_fw_cfg_init(0x510); } =20 #endif diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c index 949a99361d..4932ae092d 100644 --- a/tests/libqos/malloc-pc.c +++ b/tests/libqos/malloc-pc.c @@ -23,9 +23,9 @@ void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags) { uint64_t ram_size; - QFWCFG *fw_cfg =3D pc_fw_cfg_init(qts); + QFWCFG *fw_cfg =3D pc_fw_cfg_init(); =20 - ram_size =3D qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE); + ram_size =3D qfw_cfg_get_u64(qts, fw_cfg, FW_CFG_RAM_SIZE); alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), PAGE_SIZE); =20 /* clean-up */ --=20 2.21.0 From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570462198; cv=none; d=zoho.com; s=zohoarc; b=C4qa6jAGETkJ6w+sBQg/npA+LhokA+/ajdJlZ6XAsArmIxGktTMJVnBnsJx79h1/LYab1hnB42DZJWMzg18wD8dkc4gEaVbROo6fM9BDBERSVt3n0ZiExHdq3lYypvnmIZu5Zq0JimC/cj0liygKHhLh4XaEMNXIqbfcrOlq2FA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570462198; 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:ARC-Authentication-Results; bh=hZdP5SXF71BDSQkYu6DBHOXSqIvll8FNIKYb+PhTNCo=; b=i9cBp1q25RDmlSawPYPrxPxWYfh+z8Xfb0ZM1IHiIDd0qSr3EJ1hMDwF7gX6bvU0R0AWHJgE0V+a4h+QhzjfzxNdorCYp4KmPF4En8fH5ofzNdKIqVDFhjzy6t/WpoLlXohd3ZU/eZ/wcTGscZj2keVorYbTgS8POCo/8gB7tnc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157046219852550.80087148782354; Mon, 7 Oct 2019 08:29:58 -0700 (PDT) Received: from localhost ([::1]:46128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUxQ-0002fp-FM for importer@patchew.org; Mon, 07 Oct 2019 11:29:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47551) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUoH-0003Ia-QS for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUoF-0000Dn-5e for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUoE-0000Bd-Sb for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:27 -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 mx1.redhat.com (Postfix) with ESMTPS id 23A7118C8921; Mon, 7 Oct 2019 15:20:25 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A98619C5B; Mon, 7 Oct 2019 15:20:17 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 6/7] tests/fw_cfg: Declare one QFWCFG for all tests Date: Mon, 7 Oct 2019 17:19:04 +0200 Message-Id: <20191007151905.32766-7-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Mon, 07 Oct 2019 15:20:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It is pointless to create/remove a QFWCFG object for each test. Move it to the test context and create/remove it only once. Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang --- tests/fw_cfg-test.c | 80 ++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index dda9a9fb07..35af0de7e6 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -25,47 +25,42 @@ static uint16_t boot_menu =3D 0; =20 typedef struct { const char *machine_name; + QFWCFG *fw_cfg; } QTestCtx; =20 static void test_fw_cfg_signature(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; char buf[5]; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - qfw_cfg_get(s, fw_cfg, FW_CFG_SIGNATURE, buf, 4); + qfw_cfg_get(s, ctx->fw_cfg, FW_CFG_SIGNATURE, buf, 4); buf[4] =3D 0; - g_assert_cmpstr(buf, =3D=3D, "QEMU"); - g_free(fw_cfg); + qtest_quit(s); } =20 static void test_fw_cfg_id(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; uint32_t id; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - id =3D qfw_cfg_get_u32(s, fw_cfg, FW_CFG_ID); + id =3D qfw_cfg_get_u32(s, ctx->fw_cfg, FW_CFG_ID); g_assert((id =3D=3D 1) || (id =3D=3D 3)); - g_free(fw_cfg); + qtest_quit(s); } =20 static void test_fw_cfg_uuid(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; =20 uint8_t buf[16]; @@ -76,12 +71,10 @@ static void test_fw_cfg_uuid(const void *opaque) =20 s =3D qtest_initf("-M %s -uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - qfw_cfg_get(s, fw_cfg, FW_CFG_UUID, buf, 16); + qfw_cfg_get(s, ctx->fw_cfg, FW_CFG_UUID, buf, 16); g_assert(memcmp(buf, uuid, sizeof(buf)) =3D=3D 0); =20 - g_free(fw_cfg); qtest_quit(s); =20 } @@ -89,80 +82,71 @@ static void test_fw_cfg_uuid(const void *opaque) static void test_fw_cfg_ram_size(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u64(s, fw_cfg, FW_CFG_RAM_SIZE), =3D=3D, r= am_size); + g_assert_cmpint(qfw_cfg_get_u64(s, ctx->fw_cfg, FW_CFG_RAM_SIZE), + =3D=3D, ram_size); =20 - g_free(fw_cfg); qtest_quit(s); } =20 static void test_fw_cfg_nographic(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_NOGRAPHIC), =3D=3D, = 0); + g_assert_cmpint(qfw_cfg_get_u16(s, ctx->fw_cfg, FW_CFG_NOGRAPHIC), =3D= =3D, 0); =20 - g_free(fw_cfg); qtest_quit(s); } =20 static void test_fw_cfg_nb_cpus(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_NB_CPUS), =3D=3D, nb= _cpus); + g_assert_cmpint(qfw_cfg_get_u16(s, ctx->fw_cfg, FW_CFG_NB_CPUS), + =3D=3D, nb_cpus); =20 - g_free(fw_cfg); qtest_quit(s); } =20 static void test_fw_cfg_max_cpus(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_MAX_CPUS), =3D=3D, m= ax_cpus); - g_free(fw_cfg); + g_assert_cmpint(qfw_cfg_get_u16(s, ctx->fw_cfg, FW_CFG_MAX_CPUS), + =3D=3D, max_cpus); + qtest_quit(s); } =20 static void test_fw_cfg_numa(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; uint64_t *cpu_mask; uint64_t *node_mask; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u64(s, fw_cfg, FW_CFG_NUMA), =3D=3D, nb_no= des); + g_assert_cmpint(qfw_cfg_get_u64(s, ctx->fw_cfg, FW_CFG_NUMA), + =3D=3D, nb_nodes); =20 cpu_mask =3D g_new0(uint64_t, max_cpus); node_mask =3D g_new0(uint64_t, nb_nodes); =20 - qfw_cfg_read_data(s, fw_cfg, cpu_mask, sizeof(uint64_t) * max_cpus); - qfw_cfg_read_data(s, fw_cfg, node_mask, sizeof(uint64_t) * nb_nodes); + qfw_cfg_read_data(s, ctx->fw_cfg, cpu_mask, sizeof(uint64_t) * max_cpu= s); + qfw_cfg_read_data(s, ctx->fw_cfg, node_mask, sizeof(uint64_t) * nb_nod= es); =20 if (nb_nodes) { g_assert(cpu_mask[0] & 0x01); @@ -171,72 +155,68 @@ static void test_fw_cfg_numa(const void *opaque) =20 g_free(node_mask); g_free(cpu_mask); - g_free(fw_cfg); + qtest_quit(s); } =20 static void test_fw_cfg_boot_menu(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; =20 s =3D qtest_initf("-M %s", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - g_assert_cmpint(qfw_cfg_get_u16(s, fw_cfg, FW_CFG_BOOT_MENU), + g_assert_cmpint(qfw_cfg_get_u16(s, ctx->fw_cfg, FW_CFG_BOOT_MENU), =3D=3D, boot_menu); - g_free(fw_cfg); + qtest_quit(s); } =20 static void test_fw_cfg_reboot_timeout(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; uint32_t reboot_timeout =3D 0; size_t filesize; =20 s =3D qtest_initf("-M %s -boot reboot-timeout=3D15", ctx->machine_name= ); - fw_cfg =3D pc_fw_cfg_init(); =20 - filesize =3D qfw_cfg_get_file(s, fw_cfg, "etc/boot-fail-wait", + filesize =3D qfw_cfg_get_file(s, ctx->fw_cfg, "etc/boot-fail-wait", &reboot_timeout, sizeof(reboot_timeout)); g_assert_cmpint(filesize, =3D=3D, sizeof(reboot_timeout)); reboot_timeout =3D le32_to_cpu(reboot_timeout); g_assert_cmpint(reboot_timeout, =3D=3D, 15); - g_free(fw_cfg); + qtest_quit(s); } =20 static void test_fw_cfg_splash_time(const void *opaque) { const QTestCtx *ctx =3D opaque; - QFWCFG *fw_cfg; QTestState *s; uint16_t splash_time =3D 0; size_t filesize; =20 s =3D qtest_initf("-M %s -boot splash-time=3D12", ctx->machine_name); - fw_cfg =3D pc_fw_cfg_init(); =20 - filesize =3D qfw_cfg_get_file(s, fw_cfg, "etc/boot-menu-wait", + filesize =3D qfw_cfg_get_file(s, ctx->fw_cfg, "etc/boot-menu-wait", &splash_time, sizeof(splash_time)); g_assert_cmpint(filesize, =3D=3D, sizeof(splash_time)); splash_time =3D le16_to_cpu(splash_time); g_assert_cmpint(splash_time, =3D=3D, 12); - g_free(fw_cfg); + qtest_quit(s); } =20 int main(int argc, char **argv) { QTestCtx ctx; + int ret; =20 g_test_init(&argc, &argv, NULL); =20 ctx.machine_name =3D "pc"; + ctx.fw_cfg =3D pc_fw_cfg_init(); =20 qtest_add_data_func("fw_cfg/signature", &ctx, test_fw_cfg_signature); qtest_add_data_func("fw_cfg/id", &ctx, test_fw_cfg_id); @@ -257,5 +237,9 @@ int main(int argc, char **argv) test_fw_cfg_reboot_timeout); qtest_add_data_func("fw_cfg/splash_time", &ctx, test_fw_cfg_splash_tim= e); =20 - return g_test_run(); + ret =3D g_test_run(); + + g_free(ctx.fw_cfg); + + return ret; } --=20 2.21.0 From nobody Fri Apr 26 08:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1570461852; cv=none; d=zoho.com; s=zohoarc; b=DhPApMpWl8/6zXkR6S8EekxPq1jf7IGuZwTwC2GC6ZchqboJPcE2W477g70CfDkNyhqPH5vQhDSzc5ff/F2MbSKhaVfiUkGihCrn6b8+veCe6mPf3p8etuer7AM7mIPSKL4Io+p+slKKC1yh80x/fhai7fj8Lp0feD1/0APRlmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461852; 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:ARC-Authentication-Results; bh=Df1DpCDDnsTRU2PGGCV8ftQPlhy8tFLLHOfV2bT6uos=; b=OD5BuWpdrBM2GgvOM1SHlHBBKbLLB8yvZddujyodblbOLN+v/d8HCMtfX06BjIlia2DtdUxRBOJ+I75uvU81I0KlEdFKT1xmWthmxE+Yei/rljc0kOstEuoghgHsJeuFSiyXHtHM9N/i+d6CsfezYWMNEvYOBt/3bb7Lf0heWos= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570461852583132.8430773253632; Mon, 7 Oct 2019 08:24:12 -0700 (PDT) Received: from localhost ([::1]:46014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUrq-0006BS-Ke for importer@patchew.org; Mon, 07 Oct 2019 11:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47569) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUoJ-0003Lb-Es for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUoI-0000Il-31 for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUoH-0000Ga-Q1 for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:30 -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 mx1.redhat.com (Postfix) with ESMTPS id 1085530ADBAB; Mon, 7 Oct 2019 15:20:28 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B4F419C5B; Mon, 7 Oct 2019 15:20:25 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] tests/fw_cfg: Run the tests on big-endian targets Date: Mon, 7 Oct 2019 17:19:05 +0200 Message-Id: <20191007151905.32766-8-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 07 Oct 2019 15:20:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have been restricting our fw_cfg tests to the PC machine, which is a little-endian architecture. The fw_cfg device is also used on the SPARC and PowerPC architectures, which can run in big-endian configuration. Since we want to be sure our device does not regress regardless the endianess used, enable this test one these targets. The NUMA selector is X86 specific, restrict it to this arch. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Laszlo Ersek --- v2: test ppc32 too (lvivier) --- tests/Makefile.include | 2 ++ tests/fw_cfg-test.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 3543451ed3..4ae3d5140a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -226,6 +226,7 @@ check-qtest-ppc-y +=3D tests/prom-env-test$(EXESUF) check-qtest-ppc-y +=3D tests/drive_del-test$(EXESUF) check-qtest-ppc-y +=3D tests/boot-serial-test$(EXESUF) check-qtest-ppc-$(CONFIG_M48T59) +=3D tests/m48t59-test$(EXESUF) +check-qtest-ppc-y +=3D tests/fw_cfg-test$(EXESUF) =20 check-qtest-ppc64-y +=3D $(check-qtest-ppc-y) check-qtest-ppc64-$(CONFIG_PSERIES) +=3D tests/device-plug-test$(EXESUF) @@ -250,6 +251,7 @@ check-qtest-sh4eb-$(CONFIG_ISA_TESTDEV) =3D tests/endia= nness-test$(EXESUF) check-qtest-sparc-y +=3D tests/prom-env-test$(EXESUF) check-qtest-sparc-y +=3D tests/m48t59-test$(EXESUF) check-qtest-sparc-y +=3D tests/boot-serial-test$(EXESUF) +check-qtest-sparc-y +=3D tests/fw_cfg-test$(EXESUF) =20 check-qtest-sparc64-$(CONFIG_ISA_TESTDEV) =3D tests/endianness-test$(EXESU= F) check-qtest-sparc64-y +=3D tests/prom-env-test$(EXESUF) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 35af0de7e6..1250e87097 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -210,13 +210,30 @@ static void test_fw_cfg_splash_time(const void *opaqu= e) =20 int main(int argc, char **argv) { - QTestCtx ctx; - int ret; + const char *arch =3D qtest_get_arch(); + bool has_numa =3D false; + QTestCtx ctx =3D {}; + int ret =3D 0; =20 g_test_init(&argc, &argv, NULL); =20 - ctx.machine_name =3D "pc"; - ctx.fw_cfg =3D pc_fw_cfg_init(); + if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) { + has_numa =3D true; + ctx.machine_name =3D "pc"; + ctx.fw_cfg =3D pc_fw_cfg_init(); + } else if (g_str_equal(arch, "sparc")) { + ctx.machine_name =3D "SS-5"; + ctx.fw_cfg =3D mm_fw_cfg_init(0xd00000510ULL); + } else if (g_str_equal(arch, "ppc") || g_str_equal(arch, "ppc64")) { + /* + * The mac99 machine is different for 32/64-bit target: + * + * ppc(32): the G4 which can be either little or big endian, + * ppc64: the G5 (970FX) is only big-endian. + */ + ctx.machine_name =3D "mac99"; + ctx.fw_cfg =3D mm_fw_cfg_init(0xf0000510); + } =20 qtest_add_data_func("fw_cfg/signature", &ctx, test_fw_cfg_signature); qtest_add_data_func("fw_cfg/id", &ctx, test_fw_cfg_id); @@ -231,14 +248,18 @@ int main(int argc, char **argv) qtest_add_func("fw_cfg/boot_device", test_fw_cfg_boot_device); #endif qtest_add_data_func("fw_cfg/max_cpus", &ctx, test_fw_cfg_max_cpus); - qtest_add_data_func("fw_cfg/numa", &ctx, test_fw_cfg_numa); qtest_add_data_func("fw_cfg/boot_menu", &ctx, test_fw_cfg_boot_menu); qtest_add_data_func("fw_cfg/reboot_timeout", &ctx, test_fw_cfg_reboot_timeout); qtest_add_data_func("fw_cfg/splash_time", &ctx, test_fw_cfg_splash_tim= e); =20 - ret =3D g_test_run(); + if (has_numa) { + qtest_add_data_func("fw_cfg/numa", &ctx, test_fw_cfg_numa); + } =20 + if (ctx.machine_name) { + ret =3D g_test_run(); + } g_free(ctx.fw_cfg); =20 return ret; --=20 2.21.0