diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.include | 23 | ||||
-rw-r--r-- | tests/boot-order-test.c | 59 | ||||
-rw-r--r-- | tests/endianness-test.c | 329 | ||||
-rw-r--r-- | tests/hexloader-test.c | 2 | ||||
-rw-r--r-- | tests/pnv-xscom-test.c | 29 | ||||
-rwxr-xr-x | tests/qemu-iotests/223 | 2 | ||||
-rw-r--r-- | tests/qemu-iotests/223.out | 20 | ||||
-rwxr-xr-x | tests/qemu-iotests/233 | 30 | ||||
-rw-r--r-- | tests/qemu-iotests/233.out | 19 |
9 files changed, 283 insertions, 230 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include index 5e6b2c7058..4eea38ae99 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -167,13 +167,13 @@ check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF) check-qtest-pci-$(CONFIG_NVME_PCI) += tests/nvme-test$(EXESUF) check-qtest-pci-$(CONFIG_AC97) += tests/ac97-test$(EXESUF) check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF) -check-qtest-pci-y += $(check-qtest-virtio-y) +check-qtest-pci-$(CONFIG_VIRTIO) += $(check-qtest-virtio-y) check-qtest-pci-$(CONFIG_IPACK) += tests/tpci200-test$(EXESUF) check-qtest-pci-$(CONFIG_IPACK) += $(check-qtest-ipack-y) -check-qtest-pci-y += tests/display-vga-test$(EXESUF) +check-qtest-pci-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF) check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF) check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF) -check-qtest-pci-y += tests/megasas-test$(EXESUF) +check-qtest-pci-$(CONFIG_MEGASAS_SCSI_PCI) += tests/megasas-test$(EXESUF) check-qtest-i386-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) @@ -185,9 +185,9 @@ check-qtest-i386-y += tests/bios-tables-test$(EXESUF) check-qtest-i386-$(CONFIG_SGA) += tests/boot-serial-test$(EXESUF) check-qtest-i386-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) -check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-$(CONFIG_ISA_IPMI_KCS) += tests/ipmi-kcs-test$(EXESUF) # Disabled temporarily as it fails intermittently especially under NetBSD VM -# check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) +# check-qtest-i386-$(CONFIG_ISA_IPMI_BT) += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-i386-y += tests/drive_del-test$(EXESUF) @@ -250,22 +250,22 @@ check-qtest-ppc-y += tests/boot-order-test$(EXESUF) check-qtest-ppc-y += tests/prom-env-test$(EXESUF) check-qtest-ppc-y += tests/drive_del-test$(EXESUF) check-qtest-ppc-y += tests/boot-serial-test$(EXESUF) -check-qtest-ppc-y += tests/m48t59-test$(EXESUF) +check-qtest-ppc-$(CONFIG_M48T59) += tests/m48t59-test$(EXESUF) check-qtest-ppc64-y += $(check-qtest-ppc-y) -check-qtest-ppc64-y += tests/spapr-phb-test$(EXESUF) -check-qtest-ppc64-y += tests/pnv-xscom-test$(EXESUF) +check-qtest-ppc64-$(CONFIG_PSERIES) += tests/spapr-phb-test$(EXESUF) +check-qtest-ppc64-$(CONFIG_POWERNV) += tests/pnv-xscom-test$(EXESUF) check-qtest-ppc64-y += tests/migration-test$(EXESUF) -check-qtest-ppc64-y += tests/rtas-test$(EXESUF) +check-qtest-ppc64-$(CONFIG_PSERIES) += tests/rtas-test$(EXESUF) check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF) check-qtest-ppc64-$(CONFIG_USB_OHCI) += tests/usb-hcd-ohci-test$(EXESUF) check-qtest-ppc64-$(CONFIG_USB_UHCI) += tests/usb-hcd-uhci-test$(EXESUF) check-qtest-ppc64-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF) -check-qtest-ppc64-y += $(check-qtest-virtio-y) +check-qtest-ppc64-$(CONFIG_VIRTIO) += $(check-qtest-virtio-y) check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF) check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF) check-qtest-ppc64-$(CONFIG_RTL8139_PCI) += tests/test-filter-redirector$(EXESUF) -check-qtest-ppc64-y += tests/display-vga-test$(EXESUF) +check-qtest-ppc64-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF) check-qtest-ppc64-y += tests/numa-test$(EXESUF) check-qtest-ppc64-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF) check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF) @@ -748,7 +748,6 @@ tests/qom-test$(EXESUF): tests/qom-test.o tests/test-hmp$(EXESUF): tests/test-hmp.o tests/machine-none-test$(EXESUF): tests/machine-none-test.o tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-y) -tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) tests/nvme-test$(EXESUF): tests/nvme-test.o $(libqos-pc-obj-y) tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o tests/i82801b11-test$(EXESUF): tests/i82801b11-test.o diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index c60ebcf9d9..a725bce729 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -17,7 +17,7 @@ #include "standard-headers/linux/qemu_fw_cfg.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__)) typedef struct { const char *args; @@ -27,31 +27,30 @@ typedef struct { static void test_a_boot_order(const char *machine, const char *test_args, - uint64_t (*read_boot_order)(void), + uint64_t (*read_boot_order)(QTestState *), uint64_t expected_boot, uint64_t expected_reboot) { uint64_t actual; + QTestState *qts; - global_qtest = qtest_initf("-nodefaults%s%s %s", - machine ? " -M " : "", - machine ?: "", - test_args); - actual = read_boot_order(); + qts = qtest_initf("-nodefaults%s%s %s", machine ? " -M " : "", + machine ?: "", test_args); + actual = read_boot_order(qts); g_assert_cmphex(actual, ==, expected_boot); - qmp_discard_response("{ 'execute': 'system_reset' }"); + qmp_discard_response(qts, "{ 'execute': 'system_reset' }"); /* * system_reset only requests reset. We get a RESET event after * the actual reset completes. Need to wait for that. */ - qmp_eventwait("RESET"); - actual = read_boot_order(); + qtest_qmp_eventwait(qts, "RESET"); + actual = read_boot_order(qts); g_assert_cmphex(actual, ==, expected_reboot); - qtest_quit(global_qtest); + qtest_quit(qts); } static void test_boot_orders(const char *machine, - uint64_t (*read_boot_order)(void), + uint64_t (*read_boot_order)(QTestState *), const boot_order_test *tests) { int i; @@ -64,16 +63,16 @@ static void test_boot_orders(const char *machine, } } -static uint8_t read_mc146818(uint16_t port, uint8_t reg) +static uint8_t read_mc146818(QTestState *qts, uint16_t port, uint8_t reg) { - outb(port, reg); - return inb(port + 1); + qtest_outb(qts, port, reg); + return qtest_inb(qts, port + 1); } -static uint64_t read_boot_order_pc(void) +static uint64_t read_boot_order_pc(QTestState *qts) { - uint8_t b1 = read_mc146818(0x70, 0x38); - uint8_t b2 = read_mc146818(0x70, 0x3d); + uint8_t b1 = read_mc146818(qts, 0x70, 0x38); + uint8_t b2 = read_mc146818(qts, 0x70, 0x3d); return b1 | (b2 << 8); } @@ -109,16 +108,16 @@ static void test_pc_boot_order(void) test_boot_orders(NULL, read_boot_order_pc, test_cases_pc); } -static uint8_t read_m48t59(uint64_t addr, uint16_t reg) +static uint8_t read_m48t59(QTestState *qts, uint64_t addr, uint16_t reg) { - writeb(addr, reg & 0xff); - writeb(addr + 1, reg >> 8); - return readb(addr + 3); + qtest_writeb(qts, addr, reg & 0xff); + qtest_writeb(qts, addr + 1, reg >> 8); + return qtest_readb(qts, addr + 3); } -static uint64_t read_boot_order_prep(void) +static uint64_t read_boot_order_prep(QTestState *qts) { - return read_m48t59(0x80000000 + 0x74, 0x34); + return read_m48t59(qts, 0x80000000 + 0x74, 0x34); } static const boot_order_test test_cases_prep[] = { @@ -133,9 +132,9 @@ static void test_prep_boot_order(void) test_boot_orders("prep", read_boot_order_prep, test_cases_prep); } -static uint64_t read_boot_order_pmac(void) +static uint64_t read_boot_order_pmac(QTestState *qts) { - QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xf0000510); + QFWCFG *fw_cfg = mm_fw_cfg_init(qts, 0xf0000510); return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); } @@ -158,9 +157,9 @@ static void test_pmac_newworld_boot_order(void) test_boot_orders("mac99", read_boot_order_pmac, test_cases_fw_cfg); } -static uint64_t read_boot_order_sun4m(void) +static uint64_t read_boot_order_sun4m(QTestState *qts) { - QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xd00000510ULL); + QFWCFG *fw_cfg = mm_fw_cfg_init(qts, 0xd00000510ULL); return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); } @@ -170,9 +169,9 @@ static void test_sun4m_boot_order(void) test_boot_orders("SS-5", read_boot_order_sun4m, test_cases_fw_cfg); } -static uint64_t read_boot_order_sun4u(void) +static uint64_t read_boot_order_sun4u(QTestState *qts) { - QFWCFG *fw_cfg = io_fw_cfg_init(global_qtest, 0x510); + QFWCFG *fw_cfg = io_fw_cfg_init(qts, 0x510); return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); } diff --git a/tests/endianness-test.c b/tests/endianness-test.c index 48680cd131..58527952a5 100644 --- a/tests/endianness-test.c +++ b/tests/endianness-test.c @@ -48,65 +48,68 @@ static const TestCase test_cases[] = { {} }; -static uint8_t isa_inb(const TestCase *test, uint16_t addr) +static uint8_t isa_inb(QTestState *qts, const TestCase *test, uint16_t addr) { uint8_t value; if (test->isa_base == -1) { - value = inb(addr); + value = qtest_inb(qts, addr); } else { - value = readb(test->isa_base + addr); + value = qtest_readb(qts, test->isa_base + addr); } return value; } -static uint16_t isa_inw(const TestCase *test, uint16_t addr) +static uint16_t isa_inw(QTestState *qts, const TestCase *test, uint16_t addr) { uint16_t value; if (test->isa_base == -1) { - value = inw(addr); + value = qtest_inw(qts, addr); } else { - value = readw(test->isa_base + addr); + value = qtest_readw(qts, test->isa_base + addr); } return test->bswap ? bswap16(value) : value; } -static uint32_t isa_inl(const TestCase *test, uint16_t addr) +static uint32_t isa_inl(QTestState *qts, const TestCase *test, uint16_t addr) { uint32_t value; if (test->isa_base == -1) { - value = inl(addr); + value = qtest_inl(qts, addr); } else { - value = readl(test->isa_base + addr); + value = qtest_readl(qts, test->isa_base + addr); } return test->bswap ? bswap32(value) : value; } -static void isa_outb(const TestCase *test, uint16_t addr, uint8_t value) +static void isa_outb(QTestState *qts, const TestCase *test, uint16_t addr, + uint8_t value) { if (test->isa_base == -1) { - outb(addr, value); + qtest_outb(qts, addr, value); } else { - writeb(test->isa_base + addr, value); + qtest_writeb(qts, test->isa_base + addr, value); } } -static void isa_outw(const TestCase *test, uint16_t addr, uint16_t value) +static void isa_outw(QTestState *qts, const TestCase *test, uint16_t addr, + uint16_t value) { value = test->bswap ? bswap16(value) : value; if (test->isa_base == -1) { - outw(addr, value); + qtest_outw(qts, addr, value); } else { - writew(test->isa_base + addr, value); + qtest_writew(qts, test->isa_base + addr, value); } } -static void isa_outl(const TestCase *test, uint16_t addr, uint32_t value) +static void isa_outl(QTestState *qts, const TestCase *test, uint16_t addr, + uint32_t value) { value = test->bswap ? bswap32(value) : value; if (test->isa_base == -1) { - outl(addr, value); + qtest_outl(qts, addr, value); } else { - writel(test->isa_base + addr, value); + qtest_writel(qts, test->isa_base + addr, value); } } @@ -114,161 +117,161 @@ static void isa_outl(const TestCase *test, uint16_t addr, uint32_t value) static void test_endianness(gconstpointer data) { const TestCase *test = data; - - global_qtest = qtest_initf("-M %s%s%s -device pc-testdev", - test->machine, - test->superio ? " -device " : "", - test->superio ?: ""); - isa_outl(test, 0xe0, 0x87654321); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21); - - isa_outw(test, 0xe2, 0x8866); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21); - - isa_outw(test, 0xe0, 0x4422); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22); - - isa_outb(test, 0xe3, 0x87); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22); - - isa_outb(test, 0xe2, 0x65); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22); - - isa_outb(test, 0xe1, 0x43); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22); - - isa_outb(test, 0xe0, 0x21); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); - g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87); - g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65); - g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43); - g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21); - qtest_quit(global_qtest); + QTestState *qts; + + qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine, + test->superio ? " -device " : "", + test->superio ?: ""); + isa_outl(qts, test, 0xe0, 0x87654321); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21); + + isa_outw(qts, test, 0xe2, 0x8866); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21); + + isa_outw(qts, test, 0xe0, 0x4422); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22); + + isa_outb(qts, test, 0xe3, 0x87); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22); + + isa_outb(qts, test, 0xe2, 0x65); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22); + + isa_outb(qts, test, 0xe1, 0x43); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22); + + isa_outb(qts, test, 0xe0, 0x21); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321); + g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87); + g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65); + g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43); + g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21); + qtest_quit(qts); } static void test_endianness_split(gconstpointer data) { const TestCase *test = data; - - global_qtest = qtest_initf("-M %s%s%s -device pc-testdev", - test->machine, - test->superio ? " -device " : "", - test->superio ?: ""); - isa_outl(test, 0xe8, 0x87654321); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); - - isa_outw(test, 0xea, 0x8866); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); - - isa_outw(test, 0xe8, 0x4422); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422); - - isa_outb(test, 0xeb, 0x87); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766); - - isa_outb(test, 0xea, 0x65); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422); - - isa_outb(test, 0xe9, 0x43); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322); - - isa_outb(test, 0xe8, 0x21); - g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); - g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); - qtest_quit(global_qtest); + QTestState *qts; + + qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine, + test->superio ? " -device " : "", + test->superio ?: ""); + isa_outl(qts, test, 0xe8, 0x87654321); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321); + + isa_outw(qts, test, 0xea, 0x8866); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321); + + isa_outw(qts, test, 0xe8, 0x4422); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422); + + isa_outb(qts, test, 0xeb, 0x87); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766); + + isa_outb(qts, test, 0xea, 0x65); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422); + + isa_outb(qts, test, 0xe9, 0x43); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322); + + isa_outb(qts, test, 0xe8, 0x21); + g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321); + g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321); + qtest_quit(qts); } static void test_endianness_combine(gconstpointer data) { const TestCase *test = data; - - global_qtest = qtest_initf("-M %s%s%s -device pc-testdev", - test->machine, - test->superio ? " -device " : "", - test->superio ?: ""); - isa_outl(test, 0xe0, 0x87654321); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321); - - isa_outw(test, 0xe2, 0x8866); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x88664321); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8866); - g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321); - - isa_outw(test, 0xe0, 0x4422); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x88664422); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8866); - g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4422); - - isa_outb(test, 0xe3, 0x87); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87664422); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8766); - - isa_outb(test, 0xe2, 0x65); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654422); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4422); - - isa_outb(test, 0xe1, 0x43); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654322); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4322); - - isa_outb(test, 0xe0, 0x21); - g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321); - g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765); - g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321); - qtest_quit(global_qtest); + QTestState *qts; + + qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine, + test->superio ? " -device " : "", + test->superio ?: ""); + isa_outl(qts, test, 0xe0, 0x87654321); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321); + + isa_outw(qts, test, 0xe2, 0x8866); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664321); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866); + g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321); + + isa_outw(qts, test, 0xe0, 0x4422); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664422); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866); + g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422); + + isa_outb(qts, test, 0xe3, 0x87); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87664422); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8766); + + isa_outb(qts, test, 0xe2, 0x65); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654422); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422); + + isa_outb(qts, test, 0xe1, 0x43); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654322); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4322); + + isa_outb(qts, test, 0xe0, 0x21); + g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321); + g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765); + g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321); + qtest_quit(qts); } int main(int argc, char **argv) diff --git a/tests/hexloader-test.c b/tests/hexloader-test.c index 834ed52c22..8b7aa2d72d 100644 --- a/tests/hexloader-test.c +++ b/tests/hexloader-test.c @@ -23,7 +23,7 @@ static void hex_loader_test(void) const unsigned int base_addr = 0x00010000; QTestState *s = qtest_initf( - "-M vexpress-a9 -nographic -device loader,file=tests/data/hex-loader/test.hex"); + "-M vexpress-a9 -device loader,file=tests/data/hex-loader/test.hex"); for (i = 0; i < 256; ++i) { uint8_t val = qtest_readb(s, base_addr + i); diff --git a/tests/pnv-xscom-test.c b/tests/pnv-xscom-test.c index 70f4c84d1b..974f8da5b2 100644 --- a/tests/pnv-xscom-test.c +++ b/tests/pnv-xscom-test.c @@ -63,14 +63,15 @@ static uint64_t pnv_xscom_addr(const PnvChip *chip, uint32_t pcba) return addr; } -static uint64_t pnv_xscom_read(const PnvChip *chip, uint32_t pcba) +static uint64_t pnv_xscom_read(QTestState *qts, const PnvChip *chip, + uint32_t pcba) { - return readq(pnv_xscom_addr(chip, pcba)); + return qtest_readq(qts, pnv_xscom_addr(chip, pcba)); } -static void test_xscom_cfam_id(const PnvChip *chip) +static void test_xscom_cfam_id(QTestState *qts, const PnvChip *chip) { - uint64_t f000f = pnv_xscom_read(chip, 0xf000f); + uint64_t f000f = pnv_xscom_read(qts, chip, 0xf000f); g_assert_cmphex(f000f, ==, chip->cfam_id); } @@ -78,11 +79,11 @@ static void test_xscom_cfam_id(const PnvChip *chip) static void test_cfam_id(const void *data) { const PnvChip *chip = data; + QTestState *qts; - global_qtest = qtest_initf("-M powernv,accel=tcg -cpu %s", - chip->cpu_model); - test_xscom_cfam_id(chip); - qtest_quit(global_qtest); + qts = qtest_initf("-M powernv,accel=tcg -cpu %s", chip->cpu_model); + test_xscom_cfam_id(qts, chip); + qtest_quit(qts); } @@ -94,7 +95,7 @@ static void test_cfam_id(const void *data) #define PNV_XSCOM_EX_DTS_RESULT0 0x50000 -static void test_xscom_core(const PnvChip *chip) +static void test_xscom_core(QTestState *qts, const PnvChip *chip) { uint32_t first_core_dts0 = PNV_XSCOM_EX_DTS_RESULT0; uint64_t dts0; @@ -105,7 +106,7 @@ static void test_xscom_core(const PnvChip *chip) first_core_dts0 |= PNV_XSCOM_P9_EC_BASE(chip->first_core); } - dts0 = pnv_xscom_read(chip, first_core_dts0); + dts0 = pnv_xscom_read(qts, chip, first_core_dts0); g_assert_cmphex(dts0, ==, 0x26f024f023f0000ull); } @@ -113,11 +114,11 @@ static void test_xscom_core(const PnvChip *chip) static void test_core(const void *data) { const PnvChip *chip = data; + QTestState *qts; - global_qtest = qtest_initf("-M powernv,accel=tcg -cpu %s", - chip->cpu_model); - test_xscom_core(chip); - qtest_quit(global_qtest); + qts = qtest_initf("-M powernv,accel=tcg -cpu %s", chip->cpu_model); + test_xscom_core(qts, chip); + qtest_quit(qts); } static void add_test(const char *name, void (*test)(const void *data)) diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223 index 773892dbe6..f120a01646 100755 --- a/tests/qemu-iotests/223 +++ b/tests/qemu-iotests/223 @@ -127,6 +127,7 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start", _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start", "arguments":{"addr":{"type":"unix", "data":{"path":"'"$TEST_DIR/nbd"1'"}}}}' "error" # Attempt second server +$QEMU_NBD_PROG -L -k "$TEST_DIR/nbd" _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", "arguments":{"device":"n", "bitmap":"b"}}' "return" _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", @@ -142,6 +143,7 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writable":true, "bitmap":"b2"}}' "return" +$QEMU_NBD_PROG -L -k "$TEST_DIR/nbd" echo echo "=== Contrast normal status to large granularity dirty-bitmap ===" diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out index 0de5240a75..6476b77ba2 100644 --- a/tests/qemu-iotests/223.out +++ b/tests/qemu-iotests/223.out @@ -30,12 +30,32 @@ wrote 2097152/2097152 bytes at offset 2097152 {"error": {"class": "GenericError", "desc": "NBD server not running"}} {"return": {}} {"error": {"class": "GenericError", "desc": "NBD server already running"}} +exports available: 0 {"return": {}} {"error": {"class": "GenericError", "desc": "Cannot find device=nosuch nor node_name=nosuch"}} {"error": {"class": "GenericError", "desc": "NBD server already has export named 'n'"}} {"error": {"class": "GenericError", "desc": "Enabled bitmap 'b2' incompatible with readonly export"}} {"error": {"class": "GenericError", "desc": "Bitmap 'b3' is not found"}} {"return": {}} +exports available: 2 + export: 'n' + size: 4194304 + flags: 0x4ef ( readonly flush fua trim zeroes df cache ) + min block: 512 + opt block: 4096 + max block: 33554432 + available meta contexts: 2 + base:allocation + qemu:dirty-bitmap:b + export: 'n2' + size: 4194304 + flags: 0x4ed ( flush fua trim zeroes df cache ) + min block: 512 + opt block: 4096 + max block: 33554432 + available meta contexts: 2 + base:allocation + qemu:dirty-bitmap:b2 === Contrast normal status to large granularity dirty-bitmap === diff --git a/tests/qemu-iotests/233 b/tests/qemu-iotests/233 index 1814efe333..fc345a1a46 100755 --- a/tests/qemu-iotests/233 +++ b/tests/qemu-iotests/233 @@ -2,7 +2,7 @@ # # Test NBD TLS certificate / authorization integration # -# Copyright (C) 2018 Red Hat, Inc. +# Copyright (C) 2018-2019 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ _cleanup() { nbd_server_stop _cleanup_test_img + rm -f "$TEST_DIR/server.log" tls_x509_cleanup } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -66,12 +67,14 @@ $QEMU_IO -c 'w -P 0x11 1m 1m' "$TEST_IMG" | _filter_qemu_io echo echo "== check TLS client to plain server fails ==" -nbd_server_start_tcp_socket -f $IMGFMT "$TEST_IMG" +nbd_server_start_tcp_socket -f $IMGFMT "$TEST_IMG" 2> "$TEST_DIR/server.log" -$QEMU_IMG info --image-opts \ - --object tls-creds-x509,dir=${tls_dir}/client1,endpoint=client,id=tls0 \ +obj=tls-creds-x509,dir=${tls_dir}/client1,endpoint=client,id=tls0 +$QEMU_IMG info --image-opts --object $obj \ driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 \ 2>&1 | sed "s/$nbd_tcp_port/PORT/g" +$QEMU_NBD_PROG -L -b $nbd_tcp_addr -p $nbd_tcp_port --object $obj \ + --tls-creds=tls0 nbd_server_stop @@ -81,23 +84,28 @@ echo "== check plain client to TLS server fails ==" nbd_server_start_tcp_socket \ --object tls-creds-x509,dir=${tls_dir}/server1,endpoint=server,id=tls0,verify-peer=yes \ --tls-creds tls0 \ - -f $IMGFMT "$TEST_IMG" + -f $IMGFMT "$TEST_IMG" 2>> "$TEST_DIR/server.log" $QEMU_IMG info nbd://localhost:$nbd_tcp_port 2>&1 | sed "s/$nbd_tcp_port/PORT/g" +$QEMU_NBD_PROG -L -b $nbd_tcp_addr -p $nbd_tcp_port echo echo "== check TLS works ==" -$QEMU_IMG info --image-opts \ - --object tls-creds-x509,dir=${tls_dir}/client1,endpoint=client,id=tls0 \ +obj=tls-creds-x509,dir=${tls_dir}/client1,endpoint=client,id=tls0 +$QEMU_IMG info --image-opts --object $obj \ driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 \ 2>&1 | sed "s/$nbd_tcp_port/PORT/g" +$QEMU_NBD_PROG -L -b $nbd_tcp_addr -p $nbd_tcp_port --object $obj \ + --tls-creds=tls0 echo echo "== check TLS with different CA fails ==" -$QEMU_IMG info --image-opts \ - --object tls-creds-x509,dir=${tls_dir}/client2,endpoint=client,id=tls0 \ +obj=tls-creds-x509,dir=${tls_dir}/client2,endpoint=client,id=tls0 +$QEMU_IMG info --image-opts --object $obj \ driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 \ 2>&1 | sed "s/$nbd_tcp_port/PORT/g" +$QEMU_NBD_PROG -L -b $nbd_tcp_addr -p $nbd_tcp_port --object $obj \ + --tls-creds=tls0 echo echo "== perform I/O over TLS ==" @@ -109,6 +117,10 @@ $QEMU_IO -c 'r -P 0x11 1m 1m' -c 'w -P 0x22 1m 1m' --image-opts \ $QEMU_IO -f $IMGFMT -r -U -c 'r -P 0x22 1m 1m' "$TEST_IMG" | _filter_qemu_io +echo +echo "== final server log ==" +cat "$TEST_DIR/server.log" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/233.out b/tests/qemu-iotests/233.out index 5f416721b0..6d45f3b230 100644 --- a/tests/qemu-iotests/233.out +++ b/tests/qemu-iotests/233.out @@ -15,20 +15,33 @@ wrote 1048576/1048576 bytes at offset 1048576 == check TLS client to plain server fails == qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Denied by server for option 5 (starttls) server reported: TLS not configured +qemu-nbd: Denied by server for option 5 (starttls) +server reported: TLS not configured == check plain client to TLS server fails == qemu-img: Could not open 'nbd://localhost:PORT': TLS negotiation required before option 8 (structured reply) server reported: Option 0x8 not permitted before TLS +qemu-nbd: TLS negotiation required before option 8 (structured reply) +server reported: Option 0x8 not permitted before TLS == check TLS works == image: nbd://127.0.0.1:PORT file format: nbd virtual size: 64M (67108864 bytes) disk size: unavailable +exports available: 1 + export: '' + size: 67108864 + flags: 0x4ed ( flush fua trim zeroes df cache ) + min block: 512 + opt block: 4096 + max block: 33554432 + available meta contexts: 1 + base:allocation == check TLS with different CA fails == -qemu-nbd: option negotiation failed: Verify failed: No certificate was found. qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': The certificate hasn't got a known issuer +qemu-nbd: The certificate hasn't got a known issuer == perform I/O over TLS == read 1048576/1048576 bytes at offset 1048576 @@ -37,4 +50,8 @@ wrote 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== final server log == +qemu-nbd: option negotiation failed: Verify failed: No certificate was found. +qemu-nbd: option negotiation failed: Verify failed: No certificate was found. *** done |