qtest patches
Hi Peter,
the following changes since commit 139108f68486550869bd201f903f1884b78a4ae1:
.shippable.yml: disable the win cross tests (2018-12-17 13:02:12 +0000)
are available in the git repository at:
https://gitlab.com/huth/qemu.git tags/pull-request-2018-12-17
for you to fetch changes up to fe17cca6bd2cdfb9cc7f29da8e71aa1238bcdba7:
tests/bios-tables-test: Sanitize test verbose output (2018-12-17 16:21:51 +0100)
----------------------------------------------------------------
- Replace global_qtest in some tests
- Exit boot-serial-test loop if child dies
- Sanitize verbose output in biot-tables-test
----------------------------------------------------------------
Eric Blake (2):
ivshmem-test: Drop dependence on global_qtest tests/acpi-utils: Drop dependence on global_qtest
Igor Mammedov (1):
tests: acpi: remove not used ACPI_READ_GENERIC_ADDRESS macro
Philippe Mathieu-Daudé (1):
tests/bios-tables-test: Sanitize test verbose output
Richard Henderson (1):
tests: Exit boot-serial-test loop if child dies
Thomas Huth (8):
tests/libqos/pci: Make PCI access functions independent of global_qtest tests/vmgenid: Make test independent of global_qtest tests/pvpanic: Make the pvpanic test independent of global_qtest tests/boot-serial: Get rid of global_qtest variable tests/test-filter: Make tests independent of global_qtest tests/machine-none: Make test independent of global_qtest tests/prom-env: Make test independent of global_qtest tests/pxe: Make test independent of global_qtest
tests/acpi-utils.c | 19 ++++----- tests/acpi-utils.h | 57 ++++++++++++--------------- tests/bios-tables-test.c | 89 ++++++++++++++++++++++-------------------- tests/boot-serial-test.c | 33 ++++++++++------ tests/ivshmem-test.c | 18 +-------- tests/libqos/pci-pc.c | 47 +++++++++++----------- tests/libqos/pci-spapr.c | 20 +++++----- tests/libqtest.c | 72 +++++++++++++++++++++------------- tests/libqtest.h | 8 ++++ tests/machine-none-test.c | 7 ++-- tests/prom-env-test.c | 17 ++++---- tests/pvpanic-test.c | 14 ++++--- tests/pxe-test.c | 7 ++-- tests/test-filter-mirror.c | 9 +++-- tests/test-filter-redirector.c | 16 ++++---- tests/vmgenid-test.c | 53 +++++++++++++------------ 16 files changed, 258 insertions(+), 228 deletions(-)
[Qemu-devel] [PULL 01/13] tests/libqos/pci: Make PCI access functions independent of global_qtest
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.
--- tests/libqos/pci-pc.c | 47 ++++++++++++++++++++++++----------------------- tests/libqos/pci-spapr.c | 20 ++++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-)
tests/libqos/pci-pc.c +24 -23
@@ -29,90 +29,91 @@ typedef struct QPCIBusPCstatic uint8_t qpci_pc_pio_readb (QPCIBus *bus,uint32_t addr) { -return inb (addr); +return qtest_inb (bus->qts, addr); }static void qpci_pc_pio_writeb (QPCIBus *bus,uint32_t addr,uint8_t val) { -outb (addr, val); +qtest_outb (bus->qts, addr, val); }static uint16_t qpci_pc_pio_readw (QPCIBus *bus,uint32_t addr) { -return inw (addr); +return qtest_inw (bus->qts, addr); }static void qpci_pc_pio_writew (QPCIBus *bus,uint32_t addr,uint16_t val) { -outw (addr, val); +qtest_outw (bus->qts, addr, val); }static uint32_t qpci_pc_pio_readl (QPCIBus *bus,uint32_t addr) { -return inl (addr); +return qtest_inl (bus->qts, addr); }static void qpci_pc_pio_writel (QPCIBus *bus,uint32_t addr,uint32_t val) { -outl (addr, val); +qtest_outl (bus->qts, addr, val); }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 ); }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 ); }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); }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); }static uint8_t qpci_pc_config_readb (QPCIBus *bus,int devfn,uint8_t offset) { -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 ); }static uint16_t qpci_pc_config_readw (QPCIBus *bus,int devfn,uint8_t offset) { -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 ); }static uint32_t qpci_pc_config_readl (QPCIBus *bus,int devfn,uint8_t offset) { -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 ); }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); }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); }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); }QPCIBus *qpci_init_pc (QTestState *qts,QGuestAllocator *alloc)
tests/libqos/pci-spapr.c +10 -10
@@ -45,63 +45,63 @@ typedef struct QPCIBusSPAPR {static uint8_t qpci_spapr_pio_readb (QPCIBus *bus,uint32_t addr) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -return readb (s->pio_cpu_base + addr); +return qtest_readb (bus->qts, s->pio_cpu_base + addr); }static void qpci_spapr_pio_writeb (QPCIBus *bus,uint32_t addr,uint8_t val) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -writeb (s->pio_cpu_base + addr, val); +qtest_writeb (bus->qts, s->pio_cpu_base + addr, val); }static uint16_t qpci_spapr_pio_readw (QPCIBus *bus,uint32_t addr) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -return bswap16 (readw (s->pio_cpu_base + addr)); +return bswap16 (qtest_readw (bus->qts, s->pio_cpu_base + addr)); }static void qpci_spapr_pio_writew (QPCIBus *bus,uint32_t addr,uint16_t val) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -writew (s->pio_cpu_base + addr,bswap16 (val)); +qtest_writew (bus->qts, s->pio_cpu_base + addr,bswap16 (val)); }static uint32_t qpci_spapr_pio_readl (QPCIBus *bus,uint32_t addr) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -return bswap32 (readl (s->pio_cpu_base + addr)); +return bswap32 (qtest_readl (bus->qts, s->pio_cpu_base + addr)); }static void qpci_spapr_pio_writel (QPCIBus *bus,uint32_t addr,uint32_t val) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -writel (s->pio_cpu_base + addr,bswap32 (val)); +qtest_writel (bus->qts, s->pio_cpu_base + addr,bswap32 (val)); }static uint64_t qpci_spapr_pio_readq (QPCIBus *bus,uint32_t addr) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -return bswap64 (readq (s->pio_cpu_base + addr)); +return bswap64 (qtest_readq (bus->qts, s->pio_cpu_base + addr)); }static void qpci_spapr_pio_writeq (QPCIBus *bus,uint32_t addr,uint64_t val) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -writeq (s->pio_cpu_base + addr,bswap64 (val)); +qtest_writeq (bus->qts, s->pio_cpu_base + addr,bswap64 (val)); }static void qpci_spapr_memread (QPCIBus *bus,uint32_t addr,void *buf,size_t len) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -memread (s->mmio32_cpu_base + addr, buf, len); +qtest_memread (bus->qts, s->mmio32_cpu_base + addr, buf, len); }static void qpci_spapr_memwrite (QPCIBus *bus,uint32_t addr,const void *buf,size_t len) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); -memwrite (s->mmio32_cpu_base + addr, buf, len); +qtest_memwrite (bus->qts, s->mmio32_cpu_base + addr, buf, len); }static uint8_t qpci_spapr_config_readb (QPCIBus *bus,int devfn,uint8_t offset)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 02/13] ivshmem-test: Drop dependence on global_qtest
In reply to Thomas HuthFrom: Eric Blake <[email protected]>
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).
--- tests/ivshmem-test.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
tests/ivshmem-test.c +1 -17
@@ -71,13 +71,10 @@ static const char* reg2str(enum Reg reg) {static inline unsigned in_reg (IVState *s,enum Reg reg) {const char *name =reg2str (reg); -QTestState *qtest = global_qtest;unsigned res; - global_qtest = s->qs->qts; res =qpci_io_readl (s->dev, s->reg_bar, reg);g_test_message ("*%s -> %x\n" , name, res); - global_qtest = qtest;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 =reg2str (reg); -QTestState *qtest = global_qtest; - global_qtest = s->qs->qts;g_test_message ("%x -> *%s\n" , v, name);qpci_io_writel (s->dev, s->reg_bar, reg, v); - global_qtest = qtest; }static inline void read_mem (IVState *s,uint64_t off,void *buf,size_t len) { -QTestState *qtest = global_qtest; - - global_qtest = s->qs->qts;qpci_memread (s->dev, s->mem_bar, off, buf, len); - global_qtest = qtest; }static inline void write_mem (IVState *s,uint64_t off,const void *buf,size_t len) { -QTestState *qtest = global_qtest; - - global_qtest = s->qs->qts;qpci_memwrite (s->dev, s->mem_bar, off, buf, len); - global_qtest = qtest; }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, bool msix)g_printerr ("ivshmem-test tests are only available on x86 or ppc64\n" );exit (EXIT_FAILURE ); } - global_qtest = s->qs->qts; s->dev =get_device (s->qs->pcibus); s->reg_bar =qpci_iomap (s->dev,0 , &barsize);
@@ -354,7 +340,6 @@ static void test_ivshmem_server(bool msi) g_assert_cmpint(vm1, !=, vm2);/* check number of MSI-X vectors */ - global_qtest = s1->qs->qts;if (msi) { ret =qpci_msix_table_size (s1->dev); g_assert_cmpuint(ret, ==, nvectors);
@@ -377,7 +362,6 @@ static void test_ivshmem_server(bool msi) g_assert_cmpuint(ret, !=, 0);/* ping vm1 -> vm2 on vector 1 */ - global_qtest = s2->qs->qts;if (msi) { ret =qpci_msix_pending (s2->dev,1 ); g_assert_cmpuint(ret, ==, 0);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 03/13] tests/acpi-utils: Drop dependence on global_qtest
In reply to Thomas HuthFrom: Eric Blake <[email protected]>
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).
--- 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(-)
tests/acpi-utils.c +10 -9
@@ -32,7 +32,7 @@ uint8_t acpi_calc_checksum(const uint8_t *data, int len)return sum; } -uint32_t acpi_find_rsdp_address (void ) +uint32_t acpi_find_rsdp_address (QTestState *qts) {uint32_t off;
@@ -42,7 +42,7 @@ uint32_t acpi_find_rsdp_address(void)int i;for (i =0 ; i <sizeof sig -1 ; ++i) { - sig[i] =readb (off + i); + sig[i] =qtest_readb (qts, off + i); }if (!memcmp (sig,"RSD PTR " ,sizeof sig)) {
@@ -52,14 +52,15 @@ uint32_t acpi_find_rsdp_address(void)return off; } -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 " ); -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); }
tests/acpi-utils.h +32 -31
84 lines not on this page · raw message
tests/bios-tables-test.c +42 -40
202 lines not on this page · raw message
tests/vmgenid-test.c +12 -12
@@ -31,7 +31,7 @@ typedef struct {uint32_t vgia_val; }QEMU_PACKED VgidTable; -static uint32_t acpi_find_vgia (void ) +static uint32_t acpi_find_vgia (QTestState *qts) {uint32_t rsdp_offset;uint32_t guid_offset =0 ;
@@ -45,18 +45,18 @@ static uint32_t acpi_find_vgia(void)int i;/* Wait for guest firmware to finish and start the payload. */ -boot_sector_test (global_qtest); +boot_sector_test (qts);/* Tables should be initialized now. */ - rsdp_offset =acpi_find_rsdp_address (); + rsdp_offset =acpi_find_rsdp_address (qts); g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID); -acpi_parse_rsdp_table (rsdp_offset, &rsdp_table); +acpi_parse_rsdp_table (qts, rsdp_offset, &rsdp_table); rsdt =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 =le32_to_cpu (rsdt_table.length);
@@ -67,22 +67,22 @@ static uint32_t acpi_find_vgia(void)/* get the addresses of the tables pointed by rsdt */ tables =g_new0 (uint32_t, tables_nr); -ACPI_READ_ARRAY_PTR (tables, tables_nr, rsdt); +ACPI_READ_ARRAY_PTR (qts, tables, tables_nr, rsdt);for (i =0 ; i < tables_nr; i++) {uint32_t addr =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 ==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 ) ==0 ); -ACPI_READ_FIELD (vgid_table.val_op, addr); +ACPI_READ_FIELD (qts, vgid_table.val_op, addr);g_assert (vgid_table.val_op ==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; - vmgenid_addr =acpi_find_vgia (); + vmgenid_addr =acpi_find_vgia (global_qtest);g_assert (vmgenid_addr);/* Read the GUID directly from guest memory */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 04/13] tests/vmgenid: Make test independent of global_qtest
In reply to Thomas HuthThe 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.
--- tests/vmgenid-test.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
tests/vmgenid-test.c +17 -14
@@ -95,17 +95,17 @@ static uint32_t acpi_find_vgia(QTestState *qts)return guid_offset; } -static void read_guid_from_memory (QemuUUID *guid) +static void read_guid_from_memory (QTestState *qts,QemuUUID *guid) {uint32_t vmgenid_addr;int i; - vmgenid_addr =acpi_find_vgia (global_qtest); + vmgenid_addr =acpi_find_vgia (qts);g_assert (vmgenid_addr);/* Read the GUID directly from guest memory */ for (i =0 ; i <16 ; i++) { - guid->data[i] =readb (vmgenid_addr + i); + guid->data[i] =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); } -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; - rsp =qmp ("{ 'execute': 'query-vm-generation-id' }" ); + rsp =qtest_qmp (qts,"{ 'execute': 'query-vm-generation-id' }" );if (qdict_haskey (rsp,"return" )) { rsp_ret =qdict_get_qdict (rsp,"return" );g_assert (qdict_haskey (rsp_ret,"guid" ));
@@ -139,45 +139,48 @@ static char disk[] = "tests/vmgenid-test-disk-XXXXXX";static void vmgenid_set_guid_test (void ) {QemuUUID expected, measured; +QTestState *qts;g_assert (qemu_uuid_parse (VGID_GUID , &expected) ==0 ); - global_qtest =qtest_initf (GUID_CMD (VGID_GUID )); + qts =qtest_initf (GUID_CMD (VGID_GUID ));/* 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)) ==0 ); -qtest_quit (global_qtest); +qtest_quit (qts); }static void vmgenid_set_guid_auto_test (void ) {QemuUUID measured; +QTestState *qts; - global_qtest =qtest_initf (GUID_CMD ("auto" )); + qts =qtest_initf (GUID_CMD ("auto" )); -read_guid_from_memory (&measured); +read_guid_from_memory (qts, &measured);/* Just check that the GUID is non-null */ g_assert (!qemu_uuid_is_null (&measured)); -qtest_quit (global_qtest); +qtest_quit (qts); }static void vmgenid_query_monitor_test (void ) {QemuUUID expected, measured; +QTestState *qts;g_assert (qemu_uuid_parse (VGID_GUID , &expected) ==0 ); - global_qtest =qtest_initf (GUID_CMD (VGID_GUID )); + qts =qtest_initf (GUID_CMD (VGID_GUID ));/* 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)) ==0 ); -qtest_quit (global_qtest); +qtest_quit (qts); }int main (int argc,char **argv)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 10/13] tests/pxe: Make test independent of global_qtest
In reply to Thomas Huthglobal_qtest is not really required here, since boot_sector_test() is already independent from that global variable.
--- tests/pxe-test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tests/pxe-test.c +4 -3
@@ -61,6 +61,7 @@ static testdef_t s390x_tests[] = {static void test_pxe_one (const testdef_t *test,bool ipv6) { +QTestState *qts;char *args; args = 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); -qtest_start (args); -boot_sector_test (global_qtest); -qtest_quit (global_qtest); + qts =qtest_init (args); +boot_sector_test (qts); +qtest_quit (qts);g_free (args); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 05/13] tests/pvpanic: Make the pvpanic test independent of global_qtest
In reply to Thomas HuthWe want to get rid of global_qtest in the long run, thus do not use the wrappers like inb() and outb() here anymore.
--- tests/pvpanic-test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
tests/pvpanic-test.c +8 -6
@@ -15,13 +15,16 @@ static void test_panic(void) {uint8_t val;QDict *response, *data; +QTestState *qts; - val =inb (0x505 ); + qts =qtest_init ("-device pvpanic" ); + + val =qtest_inb (qts,0x505 ); g_assert_cmpuint(val, ==, 1); -outb (0x505 ,0x1 ); +qtest_outb (qts,0x505 ,0x1 ); - response =qmp_receive (); + response =qtest_qmp_receive (qts);g_assert (qdict_haskey (response,"event" )); g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");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"), ==, "pause");qobject_unref (response); + +qtest_quit (qts); }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); -qtest_start ("-device pvpanic" ); ret =g_test_run (); -qtest_end (); -return ret; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 06/13] tests/boot-serial: Get rid of global_qtest variable
In reply to Thomas HuthThe test does not use any of the functions that require global_qtest, so we can simply get rid of this global variable here.
--- tests/boot-serial-test.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
tests/boot-serial-test.c +7 -6
@@ -161,6 +161,7 @@ static void test_machine(const void *data)char codetmp[] ="/tmp/qtest-boot-serial-cXXXXXX" ;const char *codeparam ="" ;const uint8_t *code =NULL ; +QTestState *qts;int ser_fd; ser_fd =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 =qtest_initf ("%s %s -M %s,accel=tcg:kvm " -"-chardev file,id=serial0,path=%s " -"-no-shutdown -serial chardev:serial0 %s" , - codeparam, code ? codetmp :"" , - test->machine, serialtmp, test->extra); + qts =qtest_initf ("%s %s -M %s,accel=tcg:kvm -no-shutdown " +"-chardev file,id=serial0,path=%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); -qtest_quit (global_qtest); +qtest_quit (qts);close (ser_fd); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 08/13] tests/machine-none: Make test independent of global_qtest
In reply to Thomas HuthApart 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().
--- tests/machine-none-test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tests/machine-none-test.c +4 -3
@@ -75,6 +75,7 @@ static void test_machine_cpu_cli(void)QDict *response;const char *arch =qtest_get_arch ();const char *cpu_model =get_cpu_model_by_arch (arch); +QTestState *qts;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 =qtest_initf ("-machine none -cpu '%s'" , cpu_model); + qts =qtest_initf ("-machine none -cpu '%s'" , cpu_model); - response =qmp ("{ 'execute': 'quit' }" ); + response =qtest_qmp (qts,"{ 'execute': 'quit' }" );g_assert (qdict_haskey (response,"return" ));qobject_unref (response); -qtest_quit (global_qtest); +qtest_quit (qts); }int main (int argc,char **argv)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 07/13] tests/test-filter: Make tests independent of global_qtest
In reply to Thomas HuthApart 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.
--- tests/test-filter-mirror.c | 9 +++++---- tests/test-filter-redirector.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-)
tests/test-filter-mirror.c +5 -4
@@ -17,7 +17,7 @@#include "qemu/main-loop.h" /* 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_ARGS__))static void test_mirror (void ) {
@@ -29,6 +29,7 @@ static void test_mirror(void)uint32_t size =sizeof (send_buf); size =htonl (size);const char *devstr ="e1000" ; +QTestState *qts;if (g_str_equal (qtest_get_arch (),"s390x" )) { devstr ="virtio-net-ccw" ;
@@ -40,7 +41,7 @@ static void test_mirror(void) ret =mkstemp (sock_path); g_assert_cmpint(ret, !=, -1); - global_qtest =qtest_initf ( + qts =qtest_initf ("-netdev socket,id=qtest-bn0,fd=%d " "-device %s,netdev=qtest-bn0,id=qtest-e0 " "-chardev socket,id=mirror0,path=%s,server,nowait "
@@ -61,7 +62,7 @@ static void test_mirror(void) };/* 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 =iov_send (send_sock[0 ], iov,2 ,0 ,sizeof (size) +sizeof (send_buf)); g_assert_cmpint(ret, ==, 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); }int main (int argc,char **argv)
@@ -88,7 +90,6 @@ int main(int argc, char **argv)qtest_add_func ("/netfilter/mirror" , test_mirror); ret =g_test_run (); -qtest_end ();return ret; }
tests/test-filter-redirector.c +9 -7
@@ -59,7 +59,7 @@#include "qemu/main-loop.h" /* 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_ARGS__))static const char *get_devstr (void ) {
@@ -81,6 +81,7 @@ static void test_redirector_tx(void)char *recv_buf;uint32_t size =sizeof (send_buf); size =htonl (size); +QTestState *qts; ret =socketpair (PF_UNIX ,SOCK_STREAM ,0 , backend_sock); g_assert_cmpint(ret, !=, -1);
@@ -90,7 +91,7 @@ static void test_redirector_tx(void) ret =mkstemp (sock_path1); g_assert_cmpint(ret, !=, -1); - global_qtest =qtest_initf ( + qts =qtest_initf ("-netdev socket,id=qtest-bn0,fd=%d " "-device %s,netdev=qtest-bn0,id=qtest-e0 " "-chardev socket,id=redirector0,path=%s,server,nowait "
@@ -108,7 +109,7 @@ static void test_redirector_tx(void) g_assert_cmpint(recv_sock, !=, -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'}" );struct iovec iov[] = { {
@@ -137,7 +138,7 @@ static void test_redirector_tx(void)close (recv_sock);unlink (sock_path0);unlink (sock_path1); -qtest_end (); +qtest_quit (qts); }static void test_redirector_rx (void )
@@ -150,6 +151,7 @@ static void test_redirector_rx(void)char *recv_buf;uint32_t size =sizeof (send_buf); size =htonl (size); +QTestState *qts; ret =socketpair (PF_UNIX ,SOCK_STREAM ,0 , backend_sock); g_assert_cmpint(ret, !=, -1);
@@ -159,7 +161,7 @@ static void test_redirector_rx(void) ret =mkstemp (sock_path1); g_assert_cmpint(ret, !=, -1); - global_qtest =qtest_initf ( + qts =qtest_initf ("-netdev socket,id=qtest-bn0,fd=%d " "-device %s,netdev=qtest-bn0,id=qtest-e0 " "-chardev socket,id=redirector0,path=%s,server,nowait "
@@ -186,7 +188,7 @@ static void test_redirector_rx(void) send_sock =unix_connect (sock_path1,NULL ); g_assert_cmpint(send_sock, !=, -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'}" ); ret =iov_send (send_sock, iov,2 ,0 ,sizeof (size) +sizeof (send_buf)); g_assert_cmpint(ret, ==, 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); }int main (int argc,char **argv)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 09/13] tests/prom-env: Make test independent of global_qtest
In reply to Thomas Huthglobal_qtest is only needed here for one readl(). Let's replace it with qtest_readl() and we can remove the global_qtest variable here.
--- tests/prom-env-test.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
tests/prom-env-test.c +8 -9
@@ -25,14 +25,14 @@#define MAGIC 0xcafec0de#define ADDRESS 0x4000 -static void check_guest_memory (void ) +static void check_guest_memory (QTestState *qts) {uint32_t signature;int i;/* Poll until code has run and modified memory. Wait at most 600 seconds */ for (i =0 ; i <60000 ; ++i) { - signature =readl (ADDRESS ); + signature =qtest_readl (qts,ADDRESS );if (signature ==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;/* The pseries firmware boots much faster without the default devices */ extra_args =strcmp (machine,"pseries" ) ==0 ?"-nodefaults" :"" ; - global_qtest =qtest_initf ("-M %s,accel=tcg %s " -"-prom-env 'use-nvramrc?=true' " -"-prom-env 'nvramrc=%x %x l!' " , - (const char *)machine, extra_args, -MAGIC ,ADDRESS ); -check_guest_memory (); -qtest_quit (global_qtest); + qts =qtest_initf ("-M %s,accel=tcg %s -prom-env 'use-nvramrc?=true' " +"-prom-env 'nvramrc=%x %x l!' " , (const char *)machine, + extra_args,MAGIC ,ADDRESS ); +check_guest_memory (qts); +qtest_quit (qts); }static void add_tests (const char *machines[])
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 11/13] tests: Exit boot-serial-test loop if child dies
In reply to Thomas HuthFrom: Richard Henderson <[email protected]>
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.
--- tests/boot-serial-test.c | 20 ++++++++++---- tests/libqtest.c | 72 ++++++++++++++++++++++++++++++------------------ tests/libqtest.h | 8 ++++++ 3 files changed, 68 insertions(+), 32 deletions(-)
tests/boot-serial-test.c +15 -5
@@ -128,13 +128,14 @@ static testdef_t tests[] = { { NULL } }; -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 =0 , pos =0 , ccnt; +int nbr =0 , pos =0 , ccnt; +time_t now, start =time (NULL );char ch; -/* Poll serial output... Wait at most 360 seconds */ -for (i =0 ; i <36000 ; ++i) { +/* Poll serial output... */ +while (1 ) { ccnt =0 ;while (ccnt++ <512 && (nbr =read (fd, &ch,1 )) ==1 ) {if (ch == test->expect[pos]) {
@@ -148,6 +149,15 @@ static bool check_guest_output(const testdef_t *test, int fd) } }g_assert (nbr >=0 ); +/* Wait only if the child is still alive. */ +if (!qtest_probe_child (qts)) { +break ; + } +/* Wait at most 360 seconds. */ + now =time (NULL ); +if (now - start >=360 ) { +break ; + }g_usleep (10000 ); }
@@ -199,7 +209,7 @@ static void test_machine(const void *data)unlink (codetmp); } -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); }
tests/libqtest.c +45 -27
97 lines not on this page · raw message
tests/libqtest.h +8 -0
@@ -1011,4 +1011,12 @@ bool qmp_rsp_is_err(QDict *rsp);*/ void qmp_assert_error_class (QDict *rsp,const char *class); +/** +* qtest_probe_child: +* @s: QTestState instance to operate on. +* +* Returns: true if the child is still alive. +*/ +bool qtest_probe_child (QTestState *s); +#endif
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 12/13] tests: acpi: remove not used ACPI_READ_GENERIC_ADDRESS macro
In reply to Thomas HuthFrom: Igor Mammedov <[email protected]>
--- tests/acpi-utils.h | 8 -------- 1 file changed, 8 deletions(-)
tests/acpi-utils.h +0 -8
@@ -70,14 +70,6 @@ typedef struct { g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \ }while (0 ) -#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) uint8_t acpi_calc_checksum(const uint8_t *data, int len);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 13/13] tests/bios-tables-test: Sanitize test verbose output
In reply to Thomas HuthFrom: Philippe Mathieu-Daudé <[email protected]>
Fix the extraneous extra blank lines in the test output when running with V=1.
Before:
TEST: tests/bios-tables-test... (pid=25678)
/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=667)
/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
--- tests/bios-tables-test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tests/bios-tables-test.c +5 -2
@@ -372,6 +372,9 @@ static GArray *load_expected_aml(test_data *data)gboolean ret;GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable)); +if (getenv ("V" )) { +fputc ('\n' , stderr); + }for (i =0 ; i < data->tables->len; ++i) {AcpiSdtTable exp_sdt;gchar *aml_file =NULL ;
@@ -386,7 +389,7 @@ try_again: aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, data->machine, (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 = 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 =g_file_get_contents (aml_file, &exp_sdt.aml, &exp_sdt.aml_len, &error);
Signature · 1 line
1.8.3.1
Peter Maydell
AppliedQuoted 13 lines · Thomas Huth
Hi Peter,
the following changes since commit
139108f68486550869bd201f903f1884b78a4ae1:.shippable.yml: disable the win cross tests (2018-12-17 13:02:12 +0000)
are available in the git repository at:
https://gitlab.com/huth/qemu.git tags/pull-request-2018-12-17
for you to fetch changes up to
fe17cca6bd2cdfb9cc7f29da8e71aa1238bcdba7:
Quoted 7 lines
tests/bios-tables-test: Sanitize test verbose output (2018-12-17 16:21:51 +0100)
----------------------------------------------------------------
- Replaceglobal_qtestin some tests
- Exit boot-serial-test loop if child dies
- Sanitize verbose output in biot-tables-test
----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.
-- PMM