From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066731175167.98133680401725; Mon, 17 Dec 2018 09:12:11 -0800 (PST) Received: from localhost ([::1]:47731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvkt-0005hg-NR for importer@patchew.org; Mon, 17 Dec 2018 11:28:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveI-0000Q3-Ih for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveE-00007n-J2 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveE-00006I-2e for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F16C3E2CF for ; Mon, 17 Dec 2018 16:21:37 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07C31001F45; Mon, 17 Dec 2018 16:21:36 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:18 +0100 Message-Id: <1545063690-10116-2-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Dec 2018 16:21:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/13] tests/libqos/pci: Make PCI access functions independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QPCIBus already tracks QTestState, so use that state instead of an implicit reliance on global_qtest. Based on an earlier patch ("libqos: Use explicit QTestState for pci operations") from Eric Blake. Signed-off-by: Thomas Huth --- tests/libqos/pci-pc.c | 47 ++++++++++++++++++++++++--------------------= --- tests/libqos/pci-spapr.c | 20 ++++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index 585f528..a4fc02b 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -29,90 +29,91 @@ typedef struct QPCIBusPC =20 static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr) { - return inb(addr); + return qtest_inb(bus->qts, addr); } =20 static void qpci_pc_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val) { - outb(addr, val); + qtest_outb(bus->qts, addr, val); } =20 static uint16_t qpci_pc_pio_readw(QPCIBus *bus, uint32_t addr) { - return inw(addr); + return qtest_inw(bus->qts, addr); } =20 static void qpci_pc_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val) { - outw(addr, val); + qtest_outw(bus->qts, addr, val); } =20 static uint32_t qpci_pc_pio_readl(QPCIBus *bus, uint32_t addr) { - return inl(addr); + return qtest_inl(bus->qts, addr); } =20 static void qpci_pc_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val) { - outl(addr, val); + qtest_outl(bus->qts, addr, val); } =20 static uint64_t qpci_pc_pio_readq(QPCIBus *bus, uint32_t addr) { - return (uint64_t)inl(addr) + ((uint64_t)inl(addr + 4) << 32); + return (uint64_t)qtest_inl(bus->qts, addr) + + ((uint64_t)qtest_inl(bus->qts, addr + 4) << 32); } =20 static void qpci_pc_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val) { - outl(addr, val & 0xffffffff); - outl(addr + 4, val >> 32); + qtest_outl(bus->qts, addr, val & 0xffffffff); + qtest_outl(bus->qts, addr + 4, val >> 32); } =20 static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t= len) { - memread(addr, buf, len); + qtest_memread(bus->qts, addr, buf, len); } =20 static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr, const void *buf, size_t len) { - memwrite(addr, buf, len); + qtest_memwrite(bus->qts, addr, buf, len); } =20 static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offse= t) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - return inb(0xcfc); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + return qtest_inb(bus->qts, 0xcfc); } =20 static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offs= et) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - return inw(0xcfc); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + return qtest_inw(bus->qts, 0xcfc); } =20 static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offs= et) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - return inl(0xcfc); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + return qtest_inl(bus->qts, 0xcfc); } =20 static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset,= uint8_t value) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - outb(0xcfc, value); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + qtest_outb(bus->qts, 0xcfc, value); } =20 static void qpci_pc_config_writew(QPCIBus *bus, int devfn, uint8_t offset,= uint16_t value) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - outw(0xcfc, value); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + qtest_outw(bus->qts, 0xcfc, value); } =20 static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset,= uint32_t value) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - outl(0xcfc, value); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + qtest_outl(bus->qts, 0xcfc, value); } =20 QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c index c0f7e6d..4c29889 100644 --- a/tests/libqos/pci-spapr.c +++ b/tests/libqos/pci-spapr.c @@ -45,63 +45,63 @@ typedef struct QPCIBusSPAPR { static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return readb(s->pio_cpu_base + addr); + return qtest_readb(bus->qts, s->pio_cpu_base + addr); } =20 static void qpci_spapr_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writeb(s->pio_cpu_base + addr, val); + qtest_writeb(bus->qts, s->pio_cpu_base + addr, val); } =20 static uint16_t qpci_spapr_pio_readw(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return bswap16(readw(s->pio_cpu_base + addr)); + return bswap16(qtest_readw(bus->qts, s->pio_cpu_base + addr)); } =20 static void qpci_spapr_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t va= l) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writew(s->pio_cpu_base + addr, bswap16(val)); + qtest_writew(bus->qts, s->pio_cpu_base + addr, bswap16(val)); } =20 static uint32_t qpci_spapr_pio_readl(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return bswap32(readl(s->pio_cpu_base + addr)); + return bswap32(qtest_readl(bus->qts, s->pio_cpu_base + addr)); } =20 static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t va= l) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writel(s->pio_cpu_base + addr, bswap32(val)); + qtest_writel(bus->qts, s->pio_cpu_base + addr, bswap32(val)); } =20 static uint64_t qpci_spapr_pio_readq(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return bswap64(readq(s->pio_cpu_base + addr)); + return bswap64(qtest_readq(bus->qts, s->pio_cpu_base + addr)); } =20 static void qpci_spapr_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t va= l) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writeq(s->pio_cpu_base + addr, bswap64(val)); + qtest_writeq(bus->qts, s->pio_cpu_base + addr, bswap64(val)); } =20 static void qpci_spapr_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - memread(s->mmio32_cpu_base + addr, buf, len); + qtest_memread(bus->qts, s->mmio32_cpu_base + addr, buf, len); } =20 static void qpci_spapr_memwrite(QPCIBus *bus, uint32_t addr, const void *buf, size_t len) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - memwrite(s->mmio32_cpu_base + addr, buf, len); + qtest_memwrite(bus->qts, s->mmio32_cpu_base + addr, buf, len); } =20 static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t of= fset) --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066593166527.4380562590168; Mon, 17 Dec 2018 09:09:53 -0800 (PST) Received: from localhost ([::1]:47720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvjN-0004KL-IT for importer@patchew.org; Mon, 17 Dec 2018 11:26:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveK-0000Rm-Mr for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveI-0000D0-IK for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveG-00008D-EJ for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A057B3F21F for ; Mon, 17 Dec 2018 16:21:38 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC4EC1001942; Mon, 17 Dec 2018 16:21:37 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:19 +0100 Message-Id: <1545063690-10116-3-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Dec 2018 16:21:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/13] ivshmem-test: Drop dependence on global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Managing parallel connections to two different monitors via the implicit global_qtest makes it hard to copy-and-paste code to tests that are not aware of the implicit state. Since we have already fixed qpci to avoid global_qtest, we can now simplify by not using global_qtest anywhere in ivshmem-test. We can assert that the conversion is correct by checking that global_qtest remains NULL throughout the test (a later patch that changes global_qtest to not be a public global variable will drop the assertions). Signed-off-by: Eric Blake [thuth: Dropped the changes to test_ivshmem_hotplug() - will be fixed later] Signed-off-by: Thomas Huth --- tests/ivshmem-test.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index c37b196..089e268 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -71,13 +71,10 @@ static const char* reg2str(enum Reg reg) { static inline unsigned in_reg(IVState *s, enum Reg reg) { const char *name =3D reg2str(reg); - QTestState *qtest =3D global_qtest; unsigned res; =20 - global_qtest =3D s->qs->qts; res =3D qpci_io_readl(s->dev, s->reg_bar, reg); g_test_message("*%s -> %x\n", name, res); - global_qtest =3D qtest; =20 return res; } @@ -85,35 +82,25 @@ static inline unsigned in_reg(IVState *s, enum Reg reg) static inline void out_reg(IVState *s, enum Reg reg, unsigned v) { const char *name =3D reg2str(reg); - QTestState *qtest =3D global_qtest; =20 - global_qtest =3D s->qs->qts; g_test_message("%x -> *%s\n", v, name); qpci_io_writel(s->dev, s->reg_bar, reg, v); - global_qtest =3D qtest; } =20 static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t le= n) { - QTestState *qtest =3D global_qtest; - - global_qtest =3D s->qs->qts; qpci_memread(s->dev, s->mem_bar, off, buf, len); - global_qtest =3D qtest; } =20 static inline void write_mem(IVState *s, uint64_t off, const void *buf, size_t len) { - QTestState *qtest =3D global_qtest; - - global_qtest =3D s->qs->qts; qpci_memwrite(s->dev, s->mem_bar, off, buf, len); - global_qtest =3D qtest; } =20 static void cleanup_vm(IVState *s) { + assert(!global_qtest); g_free(s->dev); qtest_shutdown(s->qs); } @@ -131,7 +118,6 @@ static void setup_vm_cmd(IVState *s, const char *cmd, b= ool msix) g_printerr("ivshmem-test tests are only available on x86 or ppc64\= n"); exit(EXIT_FAILURE); } - global_qtest =3D s->qs->qts; s->dev =3D get_device(s->qs->pcibus); =20 s->reg_bar =3D qpci_iomap(s->dev, 0, &barsize); @@ -354,7 +340,6 @@ static void test_ivshmem_server(bool msi) g_assert_cmpint(vm1, !=3D, vm2); =20 /* check number of MSI-X vectors */ - global_qtest =3D s1->qs->qts; if (msi) { ret =3D qpci_msix_table_size(s1->dev); g_assert_cmpuint(ret, =3D=3D, nvectors); @@ -377,7 +362,6 @@ static void test_ivshmem_server(bool msi) g_assert_cmpuint(ret, !=3D, 0); =20 /* ping vm1 -> vm2 on vector 1 */ - global_qtest =3D s2->qs->qts; if (msi) { ret =3D qpci_msix_pending(s2->dev, 1); g_assert_cmpuint(ret, =3D=3D, 0); --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066826924432.6988920565026; Mon, 17 Dec 2018 09:13:46 -0800 (PST) Received: from localhost ([::1]:47729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvkp-0005ag-G0 for importer@patchew.org; Mon, 17 Dec 2018 11:28:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveO-0000T4-DS for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveK-0000Fn-BV for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34046) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveG-00009Y-Gr for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D03E6D215C for ; Mon, 17 Dec 2018 16:21:39 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF00B100034B; Mon, 17 Dec 2018 16:21:38 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:20 +0100 Message-Id: <1545063690-10116-4-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Dec 2018 16:21:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/13] tests/acpi-utils: Drop dependence on global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Adjust the helper code to use explicit state instead, and update all callers. bios-tables-test no longer depends on global_qtest, now that it passes explicit state through the testsuite data; an assert proves this fact (although we will get rid of it later, once global_qtest is gone). Signed-off-by: Eric Blake Acked-by: Igor Mammedov Tested-by: Igor Mammedov [thuth: adapted patch to current master branch] Signed-off-by: Thomas Huth --- tests/acpi-utils.c | 19 +++++------ tests/acpi-utils.h | 63 +++++++++++++++++++------------------ tests/bios-tables-test.c | 82 +++++++++++++++++++++++++-------------------= ---- tests/vmgenid-test.c | 24 +++++++------- 4 files changed, 96 insertions(+), 92 deletions(-) diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c index 41dc1ea..6dc8ca1 100644 --- a/tests/acpi-utils.c +++ b/tests/acpi-utils.c @@ -32,7 +32,7 @@ uint8_t acpi_calc_checksum(const uint8_t *data, int len) return sum; } =20 -uint32_t acpi_find_rsdp_address(void) +uint32_t acpi_find_rsdp_address(QTestState *qts) { uint32_t off; =20 @@ -42,7 +42,7 @@ uint32_t acpi_find_rsdp_address(void) int i; =20 for (i =3D 0; i < sizeof sig - 1; ++i) { - sig[i] =3D readb(off + i); + sig[i] =3D qtest_readb(qts, off + i); } =20 if (!memcmp(sig, "RSD PTR ", sizeof sig)) { @@ -52,14 +52,15 @@ uint32_t acpi_find_rsdp_address(void) return off; } =20 -void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table) +void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, + AcpiRsdpDescriptor *rsdp_table) { - ACPI_READ_FIELD(rsdp_table->signature, addr); + ACPI_READ_FIELD(qts, rsdp_table->signature, addr); ACPI_ASSERT_CMP64(rsdp_table->signature, "RSD PTR "); =20 - ACPI_READ_FIELD(rsdp_table->checksum, addr); - ACPI_READ_ARRAY(rsdp_table->oem_id, addr); - ACPI_READ_FIELD(rsdp_table->revision, addr); - ACPI_READ_FIELD(rsdp_table->rsdt_physical_address, addr); - ACPI_READ_FIELD(rsdp_table->length, addr); + ACPI_READ_FIELD(qts, rsdp_table->checksum, addr); + ACPI_READ_ARRAY(qts, rsdp_table->oem_id, addr); + ACPI_READ_FIELD(qts, rsdp_table->revision, addr); + ACPI_READ_FIELD(qts, rsdp_table->rsdt_physical_address, addr); + ACPI_READ_FIELD(qts, rsdp_table->length, addr); } diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h index ac52abd..a06a4ed 100644 --- a/tests/acpi-utils.h +++ b/tests/acpi-utils.h @@ -28,34 +28,34 @@ typedef struct { bool tmp_files_retain; /* do not delete the temp asl/aml */ } AcpiSdtTable; =20 -#define ACPI_READ_FIELD(field, addr) \ - do { \ - memread(addr, &field, sizeof(field)); \ - addr +=3D sizeof(field); \ +#define ACPI_READ_FIELD(qts, field, addr) \ + do { \ + qtest_memread(qts, addr, &field, sizeof(field)); \ + addr +=3D sizeof(field); \ } while (0) =20 -#define ACPI_READ_ARRAY_PTR(arr, length, addr) \ - do { \ - int idx; \ - for (idx =3D 0; idx < length; ++idx) { \ - ACPI_READ_FIELD(arr[idx], addr); \ - } \ +#define ACPI_READ_ARRAY_PTR(qts, arr, length, addr) \ + do { \ + int idx; \ + for (idx =3D 0; idx < length; ++idx) { \ + ACPI_READ_FIELD(qts, arr[idx], addr); \ + } \ } while (0) =20 -#define ACPI_READ_ARRAY(arr, addr) \ - ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr) +#define ACPI_READ_ARRAY(qts, arr, addr) \ + ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr) =20 -#define ACPI_READ_TABLE_HEADER(table, addr) \ +#define ACPI_READ_TABLE_HEADER(qts, table, addr) \ do { \ - ACPI_READ_FIELD((table)->signature, addr); \ - ACPI_READ_FIELD((table)->length, addr); \ - ACPI_READ_FIELD((table)->revision, addr); \ - ACPI_READ_FIELD((table)->checksum, addr); \ - ACPI_READ_ARRAY((table)->oem_id, addr); \ - ACPI_READ_ARRAY((table)->oem_table_id, addr); \ - ACPI_READ_FIELD((table)->oem_revision, addr); \ - ACPI_READ_ARRAY((table)->asl_compiler_id, addr); \ - ACPI_READ_FIELD((table)->asl_compiler_revision, addr); \ + ACPI_READ_FIELD(qts, (table)->signature, addr); \ + ACPI_READ_FIELD(qts, (table)->length, addr); \ + ACPI_READ_FIELD(qts, (table)->revision, addr); \ + ACPI_READ_FIELD(qts, (table)->checksum, addr); \ + ACPI_READ_ARRAY(qts, (table)->oem_id, addr); \ + ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr); \ + ACPI_READ_FIELD(qts, (table)->oem_revision, addr); \ + ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr); \ + ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr); \ } while (0) =20 #define ACPI_ASSERT_CMP(actual, expected) do { \ @@ -70,18 +70,19 @@ typedef struct { g_assert_cmpstr(ACPI_ASSERT_CMP_str, =3D=3D, expected); \ } while (0) =20 -#define ACPI_READ_GENERIC_ADDRESS(field, addr) \ - do { \ - ACPI_READ_FIELD((field).space_id, addr); \ - ACPI_READ_FIELD((field).bit_width, addr); \ - ACPI_READ_FIELD((field).bit_offset, addr); \ - ACPI_READ_FIELD((field).access_width, addr); \ - ACPI_READ_FIELD((field).address, addr); \ +#define ACPI_READ_GENERIC_ADDRESS(qts, field, addr) \ + do { \ + ACPI_READ_FIELD(qts, (field).space_id, addr); \ + ACPI_READ_FIELD(qts, (field).bit_width, addr); \ + ACPI_READ_FIELD(qts, (field).bit_offset, addr); \ + ACPI_READ_FIELD(qts, (field).access_width, addr); \ + ACPI_READ_FIELD(qts, (field).address, addr); \ } while (0) =20 =20 uint8_t acpi_calc_checksum(const uint8_t *data, int len); -uint32_t acpi_find_rsdp_address(void); -void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table); +uint32_t acpi_find_rsdp_address(QTestState *qts); +void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, + AcpiRsdpDescriptor *rsdp_table); =20 #endif /* TEST_ACPI_UTILS_H */ diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index d661d9b..fabbed9 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -39,6 +39,7 @@ typedef struct { struct smbios_21_entry_point smbios_ep_table; uint8_t *required_struct_types; int required_struct_types_len; + QTestState *qts; } test_data; =20 static char disk[] =3D "tests/acpi-test-disk-XXXXXX"; @@ -78,7 +79,7 @@ static void free_test_data(test_data *data) =20 static void test_acpi_rsdp_address(test_data *data) { - uint32_t off =3D acpi_find_rsdp_address(); + uint32_t off =3D acpi_find_rsdp_address(data->qts); g_assert_cmphex(off, <, 0x100000); data->rsdp_addr =3D off; } @@ -88,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data) AcpiRsdpDescriptor *rsdp_table =3D &data->rsdp_table; uint32_t addr =3D data->rsdp_addr; =20 - acpi_parse_rsdp_table(addr, rsdp_table); + acpi_parse_rsdp_table(data->qts, addr, rsdp_table); =20 /* rsdp checksum is not for the whole table, but for the first 20 byte= s */ g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20)); @@ -104,7 +105,7 @@ static void test_acpi_rsdt_table(test_data *data) uint32_t rsdt_table_length; =20 /* read the header */ - ACPI_READ_TABLE_HEADER(rsdt_table, addr); + ACPI_READ_TABLE_HEADER(data->qts, rsdt_table, addr); ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT"); =20 rsdt_table_length =3D le32_to_cpu(rsdt_table->length); @@ -116,7 +117,7 @@ static void test_acpi_rsdt_table(test_data *data) =20 /* get the addresses of the tables pointed by rsdt */ tables =3D g_new0(uint32_t, tables_nr); - ACPI_READ_ARRAY_PTR(tables, tables_nr, addr); + ACPI_READ_ARRAY_PTR(data->qts, tables, tables_nr, addr); =20 checksum =3D acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table_leng= th) + acpi_calc_checksum((uint8_t *)tables, @@ -135,11 +136,11 @@ static void fadt_fetch_facs_and_dsdt_ptrs(test_data *= data) =20 /* FADT table comes first */ addr =3D le32_to_cpu(data->rsdt_tables_addr[0]); - ACPI_READ_TABLE_HEADER(&hdr, addr); + ACPI_READ_TABLE_HEADER(data->qts, &hdr, addr); ACPI_ASSERT_CMP(hdr.signature, "FACP"); =20 - ACPI_READ_FIELD(data->facs_addr, addr); - ACPI_READ_FIELD(data->dsdt_addr, addr); + ACPI_READ_FIELD(data->qts, data->facs_addr, addr); + ACPI_READ_FIELD(data->qts, data->dsdt_addr, addr); } =20 static void sanitize_fadt_ptrs(test_data *data) @@ -182,13 +183,13 @@ static void test_acpi_facs_table(test_data *data) AcpiFacsDescriptorRev1 *facs_table =3D &data->facs_table; uint32_t addr =3D le32_to_cpu(data->facs_addr); =20 - ACPI_READ_FIELD(facs_table->signature, addr); - ACPI_READ_FIELD(facs_table->length, addr); - ACPI_READ_FIELD(facs_table->hardware_signature, addr); - ACPI_READ_FIELD(facs_table->firmware_waking_vector, addr); - ACPI_READ_FIELD(facs_table->global_lock, addr); - ACPI_READ_FIELD(facs_table->flags, addr); - ACPI_READ_ARRAY(facs_table->resverved3, addr); + ACPI_READ_FIELD(data->qts, facs_table->signature, addr); + ACPI_READ_FIELD(data->qts, facs_table->length, addr); + ACPI_READ_FIELD(data->qts, facs_table->hardware_signature, addr); + ACPI_READ_FIELD(data->qts, facs_table->firmware_waking_vector, addr); + ACPI_READ_FIELD(data->qts, facs_table->global_lock, addr); + ACPI_READ_FIELD(data->qts, facs_table->flags, addr); + ACPI_READ_ARRAY(data->qts, facs_table->resverved3, addr); =20 ACPI_ASSERT_CMP(facs_table->signature, "FACS"); } @@ -197,17 +198,17 @@ static void test_acpi_facs_table(test_data *data) * load ACPI table at @addr into table descriptor @sdt_table * and check that header checksum matches actual one. */ -static void fetch_table(AcpiSdtTable *sdt_table, uint32_t addr) +static void fetch_table(QTestState *qts, AcpiSdtTable *sdt_table, uint32_t= addr) { uint8_t checksum; =20 memset(sdt_table, 0, sizeof(*sdt_table)); - ACPI_READ_TABLE_HEADER(&sdt_table->header, addr); + ACPI_READ_TABLE_HEADER(qts, &sdt_table->header, addr); =20 sdt_table->aml_len =3D le32_to_cpu(sdt_table->header.length) - sizeof(AcpiTableHeader); sdt_table->aml =3D g_malloc0(sdt_table->aml_len); - ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr); + ACPI_READ_ARRAY_PTR(qts, sdt_table->aml, sdt_table->aml_len, addr); =20 checksum =3D acpi_calc_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) + @@ -221,7 +222,7 @@ static void test_acpi_dsdt_table(test_data *data) AcpiSdtTable dsdt_table; uint32_t addr =3D le32_to_cpu(data->dsdt_addr); =20 - fetch_table(&dsdt_table, addr); + fetch_table(data->qts, &dsdt_table, addr); ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT"); =20 /* Since DSDT isn't in RSDT, add DSDT to ASL test tables list manually= */ @@ -239,7 +240,7 @@ static void fetch_rsdt_referenced_tables(test_data *dat= a) uint32_t addr; =20 addr =3D le32_to_cpu(data->rsdt_tables_addr[i]); - fetch_table(&ssdt_table, addr); + fetch_table(data->qts, &ssdt_table, addr); =20 /* Add table to ASL test tables list */ g_array_append_val(data->tables, ssdt_table); @@ -482,32 +483,32 @@ static bool smbios_ep_table_ok(test_data *data) struct smbios_21_entry_point *ep_table =3D &data->smbios_ep_table; uint32_t addr =3D data->smbios_ep_addr; =20 - ACPI_READ_ARRAY(ep_table->anchor_string, addr); + ACPI_READ_ARRAY(data->qts, ep_table->anchor_string, addr); if (memcmp(ep_table->anchor_string, "_SM_", 4)) { return false; } - ACPI_READ_FIELD(ep_table->checksum, addr); - ACPI_READ_FIELD(ep_table->length, addr); - ACPI_READ_FIELD(ep_table->smbios_major_version, addr); - ACPI_READ_FIELD(ep_table->smbios_minor_version, addr); - ACPI_READ_FIELD(ep_table->max_structure_size, addr); - ACPI_READ_FIELD(ep_table->entry_point_revision, addr); - ACPI_READ_ARRAY(ep_table->formatted_area, addr); - ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr); + ACPI_READ_FIELD(data->qts, ep_table->checksum, addr); + ACPI_READ_FIELD(data->qts, ep_table->length, addr); + ACPI_READ_FIELD(data->qts, ep_table->smbios_major_version, addr); + ACPI_READ_FIELD(data->qts, ep_table->smbios_minor_version, addr); + ACPI_READ_FIELD(data->qts, ep_table->max_structure_size, addr); + ACPI_READ_FIELD(data->qts, ep_table->entry_point_revision, addr); + ACPI_READ_ARRAY(data->qts, ep_table->formatted_area, addr); + ACPI_READ_ARRAY(data->qts, ep_table->intermediate_anchor_string, addr); if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) { return false; } - ACPI_READ_FIELD(ep_table->intermediate_checksum, addr); - ACPI_READ_FIELD(ep_table->structure_table_length, addr); + ACPI_READ_FIELD(data->qts, ep_table->intermediate_checksum, addr); + ACPI_READ_FIELD(data->qts, ep_table->structure_table_length, addr); if (ep_table->structure_table_length =3D=3D 0) { return false; } - ACPI_READ_FIELD(ep_table->structure_table_address, addr); - ACPI_READ_FIELD(ep_table->number_of_structures, addr); + ACPI_READ_FIELD(data->qts, ep_table->structure_table_address, addr); + ACPI_READ_FIELD(data->qts, ep_table->number_of_structures, addr); if (ep_table->number_of_structures =3D=3D 0) { return false; } - ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr); + ACPI_READ_FIELD(data->qts, ep_table->smbios_bcd_revision, addr); if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) || acpi_calc_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)) { @@ -526,7 +527,7 @@ static void test_smbios_entry_point(test_data *data) int i; =20 for (i =3D 0; i < sizeof sig - 1; ++i) { - sig[i] =3D readb(off + i); + sig[i] =3D qtest_readb(data->qts, off + i); } =20 if (!memcmp(sig, "_SM_", sizeof sig)) { @@ -569,9 +570,9 @@ static void test_smbios_structs(test_data *data) for (i =3D 0; i < le16_to_cpu(ep_table->number_of_structures); i++) { =20 /* grab type and formatted area length from struct header */ - type =3D readb(addr); + type =3D qtest_readb(data->qts, addr); g_assert_cmpuint(type, <=3D, SMBIOS_MAX_TYPE); - len =3D readb(addr + 1); + len =3D qtest_readb(data->qts, addr + 1); =20 /* single-instance structs must not have been encountered before */ if (smbios_single_instance(type)) { @@ -583,7 +584,7 @@ static void test_smbios_structs(test_data *data) prv =3D crt =3D 1; while (prv || crt) { prv =3D crt; - crt =3D readb(addr + len); + crt =3D qtest_readb(data->qts, addr + len); len++; } =20 @@ -620,9 +621,9 @@ static void test_acpi_one(const char *params, test_data= *data) data->machine, "kvm:tcg", params ? params : "", disk); =20 - qtest_start(args); + data->qts =3D qtest_init(args); =20 - boot_sector_test(global_qtest); + boot_sector_test(data->qts); =20 data->tables =3D g_array_new(false, true, sizeof(AcpiSdtTable)); test_acpi_rsdp_address(data); @@ -646,7 +647,8 @@ static void test_acpi_one(const char *params, test_data= *data) test_smbios_entry_point(data); test_smbios_structs(data); =20 - qtest_quit(global_qtest); + assert(!global_qtest); + qtest_quit(data->qts); g_free(args); } =20 diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 0a6fb55..c9c4f8c 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -31,7 +31,7 @@ typedef struct { uint32_t vgia_val; } QEMU_PACKED VgidTable; =20 -static uint32_t acpi_find_vgia(void) +static uint32_t acpi_find_vgia(QTestState *qts) { uint32_t rsdp_offset; uint32_t guid_offset =3D 0; @@ -45,18 +45,18 @@ static uint32_t acpi_find_vgia(void) int i; =20 /* Wait for guest firmware to finish and start the payload. */ - boot_sector_test(global_qtest); + boot_sector_test(qts); =20 /* Tables should be initialized now. */ - rsdp_offset =3D acpi_find_rsdp_address(); + rsdp_offset =3D acpi_find_rsdp_address(qts); =20 g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID); =20 - acpi_parse_rsdp_table(rsdp_offset, &rsdp_table); + acpi_parse_rsdp_table(qts, rsdp_offset, &rsdp_table); =20 rsdt =3D le32_to_cpu(rsdp_table.rsdt_physical_address); /* read the header */ - ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt); + ACPI_READ_TABLE_HEADER(qts, &rsdt_table, rsdt); ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT"); rsdt_table_length =3D le32_to_cpu(rsdt_table.length); =20 @@ -67,22 +67,22 @@ static uint32_t acpi_find_vgia(void) =20 /* get the addresses of the tables pointed by rsdt */ tables =3D g_new0(uint32_t, tables_nr); - ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt); + ACPI_READ_ARRAY_PTR(qts, tables, tables_nr, rsdt); =20 for (i =3D 0; i < tables_nr; i++) { uint32_t addr =3D le32_to_cpu(tables[i]); - ACPI_READ_TABLE_HEADER(&ssdt_table, addr); + ACPI_READ_TABLE_HEADER(qts, &ssdt_table, addr); if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) { /* the first entry in the table should be VGIA * That's all we need */ - ACPI_READ_FIELD(vgid_table.name_op, addr); + ACPI_READ_FIELD(qts, vgid_table.name_op, addr); g_assert(vgid_table.name_op =3D=3D 0x08); /* name */ - ACPI_READ_ARRAY(vgid_table.vgia, addr); + ACPI_READ_ARRAY(qts, vgid_table.vgia, addr); g_assert(memcmp(vgid_table.vgia, "VGIA", 4) =3D=3D 0); - ACPI_READ_FIELD(vgid_table.val_op, addr); + ACPI_READ_FIELD(qts, vgid_table.val_op, addr); g_assert(vgid_table.val_op =3D=3D 0x0C); /* dword */ - ACPI_READ_FIELD(vgid_table.vgia_val, addr); + ACPI_READ_FIELD(qts, vgid_table.vgia_val, addr); /* The GUID is written at a fixed offset into the fw_cfg file * in order to implement the "OVMF SDT Header probe suppressor" * see docs/specs/vmgenid.txt for more details @@ -100,7 +100,7 @@ static void read_guid_from_memory(QemuUUID *guid) uint32_t vmgenid_addr; int i; =20 - vmgenid_addr =3D acpi_find_vgia(); + vmgenid_addr =3D acpi_find_vgia(global_qtest); g_assert(vmgenid_addr); =20 /* Read the GUID directly from guest memory */ --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066651685790.6619684285073; Mon, 17 Dec 2018 09:10:51 -0800 (PST) Received: from localhost ([::1]:47706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvi0-0002wq-PZ for importer@patchew.org; Mon, 17 Dec 2018 11:25:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveO-0000T3-8r for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveK-0000GZ-O1 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22523) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveI-0000B4-FX for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E043880F95 for ; Mon, 17 Dec 2018 16:21:40 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C15A1001942; Mon, 17 Dec 2018 16:21:39 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:21 +0100 Message-Id: <1545063690-10116-5-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 17 Dec 2018 16:21:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/13] tests/vmgenid: Make test independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The biggest part has already been done in the previous patch, we now only have to replace some few qmp() and readb() calls with the corresponding qtest_*() functions to get there. Acked-by: Igor Mammedov Signed-off-by: Thomas Huth --- tests/vmgenid-test.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index c9c4f8c..84449ce 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -95,17 +95,17 @@ static uint32_t acpi_find_vgia(QTestState *qts) return guid_offset; } =20 -static void read_guid_from_memory(QemuUUID *guid) +static void read_guid_from_memory(QTestState *qts, QemuUUID *guid) { uint32_t vmgenid_addr; int i; =20 - vmgenid_addr =3D acpi_find_vgia(global_qtest); + vmgenid_addr =3D acpi_find_vgia(qts); g_assert(vmgenid_addr); =20 /* Read the GUID directly from guest memory */ for (i =3D 0; i < 16; i++) { - guid->data[i] =3D readb(vmgenid_addr + i); + guid->data[i] =3D qtest_readb(qts, vmgenid_addr + i); } /* The GUID is in little-endian format in the guest, while QEMU * uses big-endian. Swap after reading. @@ -113,12 +113,12 @@ static void read_guid_from_memory(QemuUUID *guid) qemu_uuid_bswap(guid); } =20 -static void read_guid_from_monitor(QemuUUID *guid) +static void read_guid_from_monitor(QTestState *qts, QemuUUID *guid) { QDict *rsp, *rsp_ret; const char *guid_str; =20 - rsp =3D qmp("{ 'execute': 'query-vm-generation-id' }"); + rsp =3D qtest_qmp(qts, "{ 'execute': 'query-vm-generation-id' }"); if (qdict_haskey(rsp, "return")) { rsp_ret =3D qdict_get_qdict(rsp, "return"); g_assert(qdict_haskey(rsp_ret, "guid")); @@ -139,45 +139,48 @@ static char disk[] =3D "tests/vmgenid-test-disk-XXXXX= X"; static void vmgenid_set_guid_test(void) { QemuUUID expected, measured; + QTestState *qts; =20 g_assert(qemu_uuid_parse(VGID_GUID, &expected) =3D=3D 0); =20 - global_qtest =3D qtest_initf(GUID_CMD(VGID_GUID)); + qts =3D qtest_initf(GUID_CMD(VGID_GUID)); =20 /* Read the GUID from accessing guest memory */ - read_guid_from_memory(&measured); + read_guid_from_memory(qts, &measured); g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) = =3D=3D 0); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 static void vmgenid_set_guid_auto_test(void) { QemuUUID measured; + QTestState *qts; =20 - global_qtest =3D qtest_initf(GUID_CMD("auto")); + qts =3D qtest_initf(GUID_CMD("auto")); =20 - read_guid_from_memory(&measured); + read_guid_from_memory(qts, &measured); =20 /* Just check that the GUID is non-null */ g_assert(!qemu_uuid_is_null(&measured)); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 static void vmgenid_query_monitor_test(void) { QemuUUID expected, measured; + QTestState *qts; =20 g_assert(qemu_uuid_parse(VGID_GUID, &expected) =3D=3D 0); =20 - global_qtest =3D qtest_initf(GUID_CMD(VGID_GUID)); + qts =3D qtest_initf(GUID_CMD(VGID_GUID)); =20 /* Read the GUID via the monitor */ - read_guid_from_monitor(&measured); + read_guid_from_monitor(qts, &measured); g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) = =3D=3D 0); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066682367572.6277106083639; Mon, 17 Dec 2018 09:11:22 -0800 (PST) Received: from localhost ([::1]:47704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvhg-0002eN-RG for importer@patchew.org; Mon, 17 Dec 2018 11:25:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveS-0000Wa-77 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveO-0000Mk-6C for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveK-0000CM-LP for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8E2FA4055 for ; Mon, 17 Dec 2018 16:21:41 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2931E1001942; Mon, 17 Dec 2018 16:21:41 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:22 +0100 Message-Id: <1545063690-10116-6-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Dec 2018 16:21:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/13] tests/pvpanic: Make the pvpanic test independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We want to get rid of global_qtest in the long run, thus do not use the wrappers like inb() and outb() here anymore. Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- tests/pvpanic-test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/pvpanic-test.c b/tests/pvpanic-test.c index 7461a72..ff9176a 100644 --- a/tests/pvpanic-test.c +++ b/tests/pvpanic-test.c @@ -15,13 +15,16 @@ static void test_panic(void) { uint8_t val; QDict *response, *data; + QTestState *qts; =20 - val =3D inb(0x505); + qts =3D qtest_init("-device pvpanic"); + + val =3D qtest_inb(qts, 0x505); g_assert_cmpuint(val, =3D=3D, 1); =20 - outb(0x505, 0x1); + qtest_outb(qts, 0x505, 0x1); =20 - response =3D qmp_receive(); + response =3D qtest_qmp_receive(qts); g_assert(qdict_haskey(response, "event")); g_assert_cmpstr(qdict_get_str(response, "event"), =3D=3D, "GUEST_PANIC= KED"); g_assert(qdict_haskey(response, "data")); @@ -29,6 +32,8 @@ static void test_panic(void) g_assert(qdict_haskey(data, "action")); g_assert_cmpstr(qdict_get_str(data, "action"), =3D=3D, "pause"); qobject_unref(response); + + qtest_quit(qts); } =20 int main(int argc, char **argv) @@ -38,10 +43,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic/panic", test_panic); =20 - qtest_start("-device pvpanic"); ret =3D g_test_run(); =20 - qtest_end(); - return ret; } --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154506651359745.1954061710079; Mon, 17 Dec 2018 09:08:33 -0800 (PST) Received: from localhost ([::1]:47734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvm3-0007Et-Dm for importer@patchew.org; Mon, 17 Dec 2018 11:29:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveS-0000WX-4q for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveN-0000Ls-Kn for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42328) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveK-0000EO-KQ for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1732389AEF for ; Mon, 17 Dec 2018 16:21:43 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 353B3100034B; Mon, 17 Dec 2018 16:21:42 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:23 +0100 Message-Id: <1545063690-10116-7-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Dec 2018 16:21:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/13] tests/boot-serial: Get rid of global_qtest variable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The test does not use any of the functions that require global_qtest, so we can simply get rid of this global variable here. Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- tests/boot-serial-test.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 8ec6aed..366fe51 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -161,6 +161,7 @@ static void test_machine(const void *data) char codetmp[] =3D "/tmp/qtest-boot-serial-cXXXXXX"; const char *codeparam =3D ""; const uint8_t *code =3D NULL; + QTestState *qts; int ser_fd; =20 ser_fd =3D mkstemp(serialtmp); @@ -189,11 +190,11 @@ static void test_machine(const void *data) * Make sure that this test uses tcg if available: It is used as a * fast-enough smoketest for that. */ - global_qtest =3D qtest_initf("%s %s -M %s,accel=3Dtcg:kvm " - "-chardev file,id=3Dserial0,path=3D%s " - "-no-shutdown -serial chardev:serial0 %s", - codeparam, code ? codetmp : "", - test->machine, serialtmp, test->extra); + qts =3D qtest_initf("%s %s -M %s,accel=3Dtcg:kvm -no-shutdown " + "-chardev file,id=3Dserial0,path=3D%s " + "-serial chardev:serial0 %s", + codeparam, code ? codetmp : "", test->machine, + serialtmp, test->extra); if (code) { unlink(codetmp); } @@ -204,7 +205,7 @@ static void test_machine(const void *data) } unlink(serialtmp); =20 - qtest_quit(global_qtest); + qtest_quit(qts); =20 close(ser_fd); } --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066575276109.02895663103436; Mon, 17 Dec 2018 09:09:35 -0800 (PST) Received: from localhost ([::1]:47748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvnf-0000Bx-3u for importer@patchew.org; Mon, 17 Dec 2018 11:31:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveS-0000WW-4p for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveO-0000NO-E3 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveM-0000Fb-Q8 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1BE04C0495AE for ; Mon, 17 Dec 2018 16:21:44 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44C74100034B; Mon, 17 Dec 2018 16:21:43 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:24 +0100 Message-Id: <1545063690-10116-8-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Dec 2018 16:21:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/13] tests/test-filter: Make tests independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Apart from using qmp() in the qmp_discard_response() macro, these tests do not have any dependencies to the global_qtest variable, so we can simply get rid of it here by replacing the qmp() with qtest_qmp() in the macro. Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- tests/test-filter-mirror.c | 9 +++++---- tests/test-filter-redirector.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c index d15917e..7ab2aed 100644 --- a/tests/test-filter-mirror.c +++ b/tests/test-filter-mirror.c @@ -17,7 +17,7 @@ #include "qemu/main-loop.h" =20 /* TODO actually test the results and get rid of this */ -#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) +#define qmp_discard_response(qs, ...) qobject_unref(qtest_qmp(qs, __VA_ARG= S__)) =20 static void test_mirror(void) { @@ -29,6 +29,7 @@ static void test_mirror(void) uint32_t size =3D sizeof(send_buf); size =3D htonl(size); const char *devstr =3D "e1000"; + QTestState *qts; =20 if (g_str_equal(qtest_get_arch(), "s390x")) { devstr =3D "virtio-net-ccw"; @@ -40,7 +41,7 @@ static void test_mirror(void) ret =3D mkstemp(sock_path); g_assert_cmpint(ret, !=3D, -1); =20 - global_qtest =3D qtest_initf( + qts =3D qtest_initf( "-netdev socket,id=3Dqtest-bn0,fd=3D%d " "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " "-chardev socket,id=3Dmirror0,path=3D%s,server,nowait " @@ -61,7 +62,7 @@ static void test_mirror(void) }; =20 /* send a qmp command to guarantee that 'connected' is setting to true= . */ - qmp_discard_response("{ 'execute' : 'query-status'}"); + qmp_discard_response(qts, "{ 'execute' : 'query-status'}"); ret =3D iov_send(send_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_b= uf)); g_assert_cmpint(ret, =3D=3D, sizeof(send_buf) + sizeof(size)); close(send_sock[0]); @@ -78,6 +79,7 @@ static void test_mirror(void) g_free(recv_buf); close(recv_sock); unlink(sock_path); + qtest_quit(qts); } =20 int main(int argc, char **argv) @@ -88,7 +90,6 @@ int main(int argc, char **argv) =20 qtest_add_func("/netfilter/mirror", test_mirror); ret =3D g_test_run(); - qtest_end(); =20 return ret; } diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index 615ff5c..9ca9fea 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -59,7 +59,7 @@ #include "qemu/main-loop.h" =20 /* TODO actually test the results and get rid of this */ -#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) +#define qmp_discard_response(qs, ...) qobject_unref(qtest_qmp(qs, __VA_ARG= S__)) =20 static const char *get_devstr(void) { @@ -81,6 +81,7 @@ static void test_redirector_tx(void) char *recv_buf; uint32_t size =3D sizeof(send_buf); size =3D htonl(size); + QTestState *qts; =20 ret =3D socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock); g_assert_cmpint(ret, !=3D, -1); @@ -90,7 +91,7 @@ static void test_redirector_tx(void) ret =3D mkstemp(sock_path1); g_assert_cmpint(ret, !=3D, -1); =20 - global_qtest =3D qtest_initf( + qts =3D qtest_initf( "-netdev socket,id=3Dqtest-bn0,fd=3D%d " "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " @@ -108,7 +109,7 @@ static void test_redirector_tx(void) g_assert_cmpint(recv_sock, !=3D, -1); =20 /* send a qmp command to guarantee that 'connected' is setting to true= . */ - qmp_discard_response("{ 'execute' : 'query-status'}"); + qmp_discard_response(qts, "{ 'execute' : 'query-status'}"); =20 struct iovec iov[] =3D { { @@ -137,7 +138,7 @@ static void test_redirector_tx(void) close(recv_sock); unlink(sock_path0); unlink(sock_path1); - qtest_end(); + qtest_quit(qts); } =20 static void test_redirector_rx(void) @@ -150,6 +151,7 @@ static void test_redirector_rx(void) char *recv_buf; uint32_t size =3D sizeof(send_buf); size =3D htonl(size); + QTestState *qts; =20 ret =3D socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock); g_assert_cmpint(ret, !=3D, -1); @@ -159,7 +161,7 @@ static void test_redirector_rx(void) ret =3D mkstemp(sock_path1); g_assert_cmpint(ret, !=3D, -1); =20 - global_qtest =3D qtest_initf( + qts =3D qtest_initf( "-netdev socket,id=3Dqtest-bn0,fd=3D%d " "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " @@ -186,7 +188,7 @@ static void test_redirector_rx(void) send_sock =3D unix_connect(sock_path1, NULL); g_assert_cmpint(send_sock, !=3D, -1); /* send a qmp command to guarantee that 'connected' is setting to true= . */ - qmp_discard_response("{ 'execute' : 'query-status'}"); + qmp_discard_response(qts, "{ 'execute' : 'query-status'}"); =20 ret =3D iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf)= ); g_assert_cmpint(ret, =3D=3D, sizeof(send_buf) + sizeof(size)); @@ -204,7 +206,7 @@ static void test_redirector_rx(void) g_free(recv_buf); unlink(sock_path0); unlink(sock_path1); - qtest_end(); + qtest_quit(qts); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066532257242.56307655474507; Mon, 17 Dec 2018 09:08:52 -0800 (PST) Received: from localhost ([::1]:47726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvkU-0005Hl-0c for importer@patchew.org; Mon, 17 Dec 2018 11:28:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveS-0000Wk-EA for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveQ-0000PW-59 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveO-0000HY-Du for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A43889ADC for ; Mon, 17 Dec 2018 16:21:45 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54D011001942; Mon, 17 Dec 2018 16:21:44 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:25 +0100 Message-Id: <1545063690-10116-9-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Dec 2018 16:21:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/13] tests/machine-none: Make test independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Apart from using qmp() in one spot, this test does not have any dependencies to the global_qtest variable, so we can simply get rid of it here by replacing the qmp() with qtest_qmp(). Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- tests/machine-none-test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c index 2b3b750..4c6d470 100644 --- a/tests/machine-none-test.c +++ b/tests/machine-none-test.c @@ -75,6 +75,7 @@ static void test_machine_cpu_cli(void) QDict *response; const char *arch =3D qtest_get_arch(); const char *cpu_model =3D get_cpu_model_by_arch(arch); + QTestState *qts; =20 if (!cpu_model) { if (!(!strcmp(arch, "microblaze") || !strcmp(arch, "microblazeel")= )) { @@ -83,13 +84,13 @@ static void test_machine_cpu_cli(void) } return; /* TODO: die here to force all targets have a test */ } - global_qtest =3D qtest_initf("-machine none -cpu '%s'", cpu_model); + qts =3D qtest_initf("-machine none -cpu '%s'", cpu_model); =20 - response =3D qmp("{ 'execute': 'quit' }"); + response =3D qtest_qmp(qts, "{ 'execute': 'quit' }"); g_assert(qdict_haskey(response, "return")); qobject_unref(response); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066735292467.0688167588813; Mon, 17 Dec 2018 09:12:15 -0800 (PST) Received: from localhost ([::1]:47761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvqy-0002gY-IY for importer@patchew.org; Mon, 17 Dec 2018 11:34:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveT-0000YW-Vl for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveS-0000R1-6v for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveQ-0000J2-B7 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C83931488 for ; Mon, 17 Dec 2018 16:21:46 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F5B41001942; Mon, 17 Dec 2018 16:21:45 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:26 +0100 Message-Id: <1545063690-10116-10-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 17 Dec 2018 16:21:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/13] tests/prom-env: Make test independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" global_qtest is only needed here for one readl(). Let's replace it with qtest_readl() and we can remove the global_qtest variable here. Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- tests/prom-env-test.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/prom-env-test.c b/tests/prom-env-test.c index 198d007..4821254 100644 --- a/tests/prom-env-test.c +++ b/tests/prom-env-test.c @@ -25,14 +25,14 @@ #define MAGIC 0xcafec0de #define ADDRESS 0x4000 =20 -static void check_guest_memory(void) +static void check_guest_memory(QTestState *qts) { uint32_t signature; int i; =20 /* Poll until code has run and modified memory. Wait at most 600 secon= ds */ for (i =3D 0; i < 60000; ++i) { - signature =3D readl(ADDRESS); + signature =3D qtest_readl(qts, ADDRESS); if (signature =3D=3D MAGIC) { break; } @@ -45,17 +45,16 @@ static void check_guest_memory(void) static void test_machine(const void *machine) { const char *extra_args; + QTestState *qts; =20 /* The pseries firmware boots much faster without the default devices = */ extra_args =3D strcmp(machine, "pseries") =3D=3D 0 ? "-nodefaults" : "= "; =20 - global_qtest =3D qtest_initf("-M %s,accel=3Dtcg %s " - "-prom-env 'use-nvramrc?=3Dtrue' " - "-prom-env 'nvramrc=3D%x %x l!' ", - (const char *)machine, extra_args, - MAGIC, ADDRESS); - check_guest_memory(); - qtest_quit(global_qtest); + qts =3D qtest_initf("-M %s,accel=3Dtcg %s -prom-env 'use-nvramrc?=3Dtr= ue' " + "-prom-env 'nvramrc=3D%x %x l!' ", (const char *)mac= hine, + extra_args, MAGIC, ADDRESS); + check_guest_memory(qts); + qtest_quit(qts); } =20 static void add_tests(const char *machines[]) --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066628845791.7547270543852; Mon, 17 Dec 2018 09:10:28 -0800 (PST) Received: from localhost ([::1]:47751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvp6-0001HX-Dq for importer@patchew.org; Mon, 17 Dec 2018 11:32:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveS-0000Wh-Bn for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveQ-0000Pr-CD for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveQ-0000Lc-1k for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49B4B89AF2 for ; Mon, 17 Dec 2018 16:21:47 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A88A100034B; Mon, 17 Dec 2018 16:21:46 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:27 +0100 Message-Id: <1545063690-10116-11-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Dec 2018 16:21:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/13] tests/pxe: Make test independent of global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" global_qtest is not really required here, since boot_sector_test() is already independent from that global variable. Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- tests/pxe-test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 6e36796..73ac1d1 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -61,6 +61,7 @@ static testdef_t s390x_tests[] =3D { =20 static void test_pxe_one(const testdef_t *test, bool ipv6) { + QTestState *qts; char *args; =20 args =3D g_strdup_printf( @@ -70,9 +71,9 @@ static void test_pxe_one(const testdef_t *test, bool ipv6) test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off", test->model); =20 - qtest_start(args); - boot_sector_test(global_qtest); - qtest_quit(global_qtest); + qts =3D qtest_init(args); + boot_sector_test(qts); + qtest_quit(qts); g_free(args); } =20 --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066806389529.9023163670273; Mon, 17 Dec 2018 09:13:26 -0800 (PST) Received: from localhost ([::1]:47760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvqu-0002cA-Jf for importer@patchew.org; Mon, 17 Dec 2018 11:34:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveb-0000fn-QX for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveX-0000VH-GA for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38084) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveX-0000UU-6N for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47698325B2; Mon, 17 Dec 2018 16:21:56 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7759F1001942; Mon, 17 Dec 2018 16:21:47 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:28 +0100 Message-Id: <1545063690-10116-12-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Dec 2018 16:21:56 +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 Subject: [Qemu-devel] [PULL 11/13] tests: Exit boot-serial-test loop if child dies X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Richard Henderson There's no point in waiting 5 full minutes when there will be no more output. Compute timeout based on elapsed wall clock time instead of N * delays, as the delay is a minimum sleep time. Cc: Thomas Huth Cc: Laurent Vivier Cc: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Wainer dos Santos Moschetta [thuth: Replaced global_qtest with local qts variable] Signed-off-by: Thomas Huth --- tests/boot-serial-test.c | 20 ++++++++++---- tests/libqtest.c | 72 ++++++++++++++++++++++++++++++--------------= ---- tests/libqtest.h | 8 ++++++ 3 files changed, 68 insertions(+), 32 deletions(-) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 366fe51..58a48f3 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -128,13 +128,14 @@ static testdef_t tests[] =3D { { NULL } }; =20 -static bool check_guest_output(const testdef_t *test, int fd) +static bool check_guest_output(QTestState *qts, const testdef_t *test, int= fd) { - int i, nbr =3D 0, pos =3D 0, ccnt; + int nbr =3D 0, pos =3D 0, ccnt; + time_t now, start =3D time(NULL); char ch; =20 - /* Poll serial output... Wait at most 360 seconds */ - for (i =3D 0; i < 36000; ++i) { + /* Poll serial output... */ + while (1) { ccnt =3D 0; while (ccnt++ < 512 && (nbr =3D read(fd, &ch, 1)) =3D=3D 1) { if (ch =3D=3D test->expect[pos]) { @@ -148,6 +149,15 @@ static bool check_guest_output(const testdef_t *test, = int fd) } } g_assert(nbr >=3D 0); + /* Wait only if the child is still alive. */ + if (!qtest_probe_child(qts)) { + break; + } + /* Wait at most 360 seconds. */ + now =3D time(NULL); + if (now - start >=3D 360) { + break; + } g_usleep(10000); } =20 @@ -199,7 +209,7 @@ static void test_machine(const void *data) unlink(codetmp); } =20 - if (!check_guest_output(test, ser_fd)) { + if (!check_guest_output(qts, test, ser_fd)) { g_error("Failed to find expected string. Please check '%s'", serialtmp); } diff --git a/tests/libqtest.c b/tests/libqtest.c index 43be078..1d75d3c 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -39,10 +39,11 @@ struct QTestState { int fd; int qmp_fd; - bool irq_level[MAX_IRQ]; - GString *rx; pid_t qemu_pid; /* our child QEMU process */ + int wstatus; bool big_endian; + bool irq_level[MAX_IRQ]; + GString *rx; }; =20 static GHookList abrt_hooks; @@ -96,36 +97,52 @@ static int socket_accept(int sock) return ret; } =20 -static void kill_qemu(QTestState *s) +bool qtest_probe_child(QTestState *s) { - if (s->qemu_pid !=3D -1) { - int wstatus =3D 0; - pid_t pid; + pid_t pid =3D s->qemu_pid; =20 - kill(s->qemu_pid, SIGTERM); - TFR(pid =3D waitpid(s->qemu_pid, &wstatus, 0)); + if (pid !=3D -1) { + pid =3D waitpid(pid, &s->wstatus, WNOHANG); + if (pid =3D=3D 0) { + return true; + } + s->qemu_pid =3D -1; + } + return false; +} =20 +static void kill_qemu(QTestState *s) +{ + pid_t pid =3D s->qemu_pid; + int wstatus; + + /* Skip wait if qtest_probe_child already reaped. */ + if (pid !=3D -1) { + kill(pid, SIGTERM); + TFR(pid =3D waitpid(s->qemu_pid, &s->wstatus, 0)); assert(pid =3D=3D s->qemu_pid); - /* - * We expect qemu to exit with status 0; anything else is - * fishy and should be logged with as much detail as possible. - */ - if (wstatus) { - if (WIFEXITED(wstatus)) { - fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEM= U " - "process but encountered exit status %d\n", - __FILE__, __LINE__, WEXITSTATUS(wstatus)); - } else if (WIFSIGNALED(wstatus)) { - int sig =3D WTERMSIG(wstatus); - const char *signame =3D strsignal(sig) ?: "unknown ???"; - const char *dump =3D WCOREDUMP(wstatus) ? " (core dumped)"= : ""; - - fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death " - "from signal %d (%s)%s\n", - __FILE__, __LINE__, sig, signame, dump); - } - abort(); + } + + /* + * We expect qemu to exit with status 0; anything else is + * fishy and should be logged with as much detail as possible. + */ + wstatus =3D s->wstatus; + if (wstatus) { + if (WIFEXITED(wstatus)) { + fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU " + "process but encountered exit status %d\n", + __FILE__, __LINE__, WEXITSTATUS(wstatus)); + } else if (WIFSIGNALED(wstatus)) { + int sig =3D WTERMSIG(wstatus); + const char *signame =3D strsignal(sig) ?: "unknown ???"; + const char *dump =3D WCOREDUMP(wstatus) ? " (core dumped)" : "= "; + + fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death " + "from signal %d (%s)%s\n", + __FILE__, __LINE__, sig, signame, dump); } + abort(); } } =20 @@ -228,6 +245,7 @@ QTestState *qtest_init_without_qmp_handshake(const char= *extra_args) =20 g_test_message("starting QEMU: %s", command); =20 + s->wstatus =3D 0; s->qemu_pid =3D fork(); if (s->qemu_pid =3D=3D 0) { setenv("QEMU_AUDIO_DRV", "none", true); diff --git a/tests/libqtest.h b/tests/libqtest.h index 96a6c01..9758c51 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -1011,4 +1011,12 @@ bool qmp_rsp_is_err(QDict *rsp); */ void qmp_assert_error_class(QDict *rsp, const char *class); =20 +/** + * qtest_probe_child: + * @s: QTestState instance to operate on. + * + * Returns: true if the child is still alive. + */ +bool qtest_probe_child(QTestState *s); + #endif --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154506677520912.743473942163632; Mon, 17 Dec 2018 09:12:55 -0800 (PST) Received: from localhost ([::1]:47747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvnb-00007X-N9 for importer@patchew.org; Mon, 17 Dec 2018 11:31:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYveb-0000fj-Pp for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYveY-0000Wx-JL for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYveY-0000VW-8X for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:21:58 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 781A3A7FE2 for ; Mon, 17 Dec 2018 16:21:57 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 881C21001F45; Mon, 17 Dec 2018 16:21:56 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:29 +0100 Message-Id: <1545063690-10116-13-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Dec 2018 16:21:57 +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 Subject: [Qemu-devel] [PULL 12/13] tests: acpi: remove not used ACPI_READ_GENERIC_ADDRESS macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 [thuth: Fixed conflicts with additional "qts" parameter] Signed-off-by: Thomas Huth --- tests/acpi-utils.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h index a06a4ed..791bd54 100644 --- a/tests/acpi-utils.h +++ b/tests/acpi-utils.h @@ -70,14 +70,6 @@ typedef struct { g_assert_cmpstr(ACPI_ASSERT_CMP_str, =3D=3D, expected); \ } while (0) =20 -#define ACPI_READ_GENERIC_ADDRESS(qts, field, addr) \ - do { \ - ACPI_READ_FIELD(qts, (field).space_id, addr); \ - ACPI_READ_FIELD(qts, (field).bit_width, addr); \ - ACPI_READ_FIELD(qts, (field).bit_offset, addr); \ - ACPI_READ_FIELD(qts, (field).access_width, addr); \ - ACPI_READ_FIELD(qts, (field).address, addr); \ - } while (0) =20 =20 uint8_t acpi_calc_checksum(const uint8_t *data, int len); --=20 1.8.3.1 From nobody Mon May 6 07:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545066605762378.93748616389735; Mon, 17 Dec 2018 09:10:05 -0800 (PST) Received: from localhost ([::1]:47744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvnA-0008Fd-6Z for importer@patchew.org; Mon, 17 Dec 2018 11:30:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYvee-0000hx-0v for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYved-0000di-2C for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYvec-0000cI-Lr for qemu-devel@nongnu.org; Mon, 17 Dec 2018 11:22:02 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6E8788302 for ; Mon, 17 Dec 2018 16:22:01 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id B83A3100034B; Mon, 17 Dec 2018 16:21:57 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 17:21:30 +0100 Message-Id: <1545063690-10116-14-git-send-email-thuth@redhat.com> In-Reply-To: <1545063690-10116-1-git-send-email-thuth@redhat.com> References: <1545063690-10116-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Dec 2018 16:22: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 Subject: [Qemu-devel] [PULL 13/13] tests/bios-tables-test: Sanitize test verbose output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , 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" From: Philippe Mathieu-Daud=C3=A9 Fix the extraneous extra blank lines in the test output when running with V= =3D1. Before: TEST: tests/bios-tables-test... (pid=3D25678) /i386/acpi/piix4: Looking for expected file 'tests/acpi-test-data/pc/DSDT' Using expected file 'tests/acpi-test-data/pc/DSDT' Looking for expected file 'tests/acpi-test-data/pc/FACP' Using expected file 'tests/acpi-test-data/pc/FACP' Looking for expected file 'tests/acpi-test-data/pc/APIC' Using expected file 'tests/acpi-test-data/pc/APIC' Looking for expected file 'tests/acpi-test-data/pc/HPET' Using expected file 'tests/acpi-test-data/pc/HPET' OK After: TEST: tests/bios-tables-test... (pid=3D667) /i386/acpi/piix4: Looking for expected file 'tests/acpi-test-data/pc/DSDT' Using expected file 'tests/acpi-test-data/pc/DSDT' Looking for expected file 'tests/acpi-test-data/pc/FACP' Using expected file 'tests/acpi-test-data/pc/FACP' Looking for expected file 'tests/acpi-test-data/pc/APIC' Using expected file 'tests/acpi-test-data/pc/APIC' Looking for expected file 'tests/acpi-test-data/pc/HPET' Using expected file 'tests/acpi-test-data/pc/HPET' OK Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Igor Mammedov Signed-off-by: Thomas Huth --- tests/bios-tables-test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index fabbed9..bac4b01 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -372,6 +372,9 @@ static GArray *load_expected_aml(test_data *data) gboolean ret; =20 GArray *exp_tables =3D g_array_new(false, true, sizeof(AcpiSdtTable)); + if (getenv("V")) { + fputc('\n', stderr); + } for (i =3D 0; i < data->tables->len; ++i) { AcpiSdtTable exp_sdt; gchar *aml_file =3D NULL; @@ -386,7 +389,7 @@ try_again: aml_file =3D g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machi= ne, (gchar *)&sdt->header.signature, ext); if (getenv("V")) { - fprintf(stderr, "\nLooking for expected file '%s'\n", aml_file= ); + fprintf(stderr, "Looking for expected file '%s'\n", aml_file); } if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) { exp_sdt.aml_file =3D aml_file; @@ -398,7 +401,7 @@ try_again: } g_assert(exp_sdt.aml_file); if (getenv("V")) { - fprintf(stderr, "\nUsing expected file '%s'\n", aml_file); + fprintf(stderr, "Using expected file '%s'\n", aml_file); } ret =3D g_file_get_contents(aml_file, &exp_sdt.aml, &exp_sdt.aml_len, &error); --=20 1.8.3.1