diff options
Diffstat (limited to 'tests')
118 files changed, 2260 insertions, 495 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index 1aed2249ff..9ba9d96b6b 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -4,6 +4,7 @@ check-qint check-qjson check-qlist check-qstring +check-qom-interface test-aio test-bitops test-throttle diff --git a/tests/Makefile b/tests/Makefile index fd36eee641..b17d41e4e2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,9 @@ export SRC_PATH +# Get the list of all supported sysemu targets +SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \ + $(wildcard $(SRC_PATH)/default-configs/*-softmmu.mak))) + check-unit-y = tests/check-qdict$(EXESUF) gcov-files-check-qdict-y = qobject/qdict.c check-unit-y += tests/check-qfloat$(EXESUF) @@ -60,64 +64,78 @@ check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh # All QTests for now are POSIX-only, but the dependencies are # really in libqtest, not in the testcases themselves. + +gcov-files-ipack-y += hw/ipack/ipack.c +check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF) +gcov-files-ipack-y += hw/char/ipoctal232.c + +gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c +check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c + +check-qtest-pci-y += tests/e1000-test$(EXESUF) +gcov-files-pci-y += hw/net/e1000.c +check-qtest-pci-y += tests/rtl8139-test$(EXESUF) +gcov-files-pci-y += hw/net/rtl8139.c +check-qtest-pci-y += tests/pcnet-test$(EXESUF) +gcov-files-pci-y += hw/net/pcnet.c +gcov-files-pci-y += hw/net/pcnet-pci.c +check-qtest-pci-y += tests/eepro100-test$(EXESUF) +gcov-files-pci-y += hw/net/eepro100.c +check-qtest-pci-y += tests/ne2000-test$(EXESUF) +gcov-files-pci-y += hw/net/ne2000.c +check-qtest-pci-y += $(check-qtest-virtio-y) +gcov-files-pci-y += $(gcov-files-virtio-y) hw/virtio/virtio-pci.c +check-qtest-pci-y += tests/tpci200-test$(EXESUF) +gcov-files-pci-y += hw/char/tpci200.c +check-qtest-pci-y += $(check-qtest-ipack-y) +gcov-files-pci-y += $(gcov-files-ipack-y) hw/ipack/tpci200.c + check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) -gcov-files-i386-y = hw/fdc.c +gcov-files-i386-y = hw/block/fdc.c check-qtest-i386-y += tests/ide-test$(EXESUF) check-qtest-i386-y += tests/hd-geo-test$(EXESUF) -gcov-files-i386-y += hw/hd-geometry.c +gcov-files-i386-y += hw/block/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/acpi-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) -check-qtest-i386-y += tests/qom-test$(EXESUF) check-qtest-i386-y += tests/blockdev-test$(EXESUF) check-qtest-i386-y += tests/qdev-monitor-test$(EXESUF) +check-qtest-i386-y += $(check-qtest-pci-y) +gcov-files-i386-y += $(gcov-files-pci-y) +check-qtest-i386-y += tests/vmxnet3-test$(EXESUF) +gcov-files-i386-y += hw/net/vmxnet3.c +gcov-files-i386-y += hw/net/vmxnet_rx_pkt.c +gcov-files-i386-y += hw/net/vmxnet_tx_pkt.c check-qtest-x86_64-y = $(check-qtest-i386-y) -gcov-files-i386-y += i386-softmmu/hw/mc146818rtc.c +gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y)) check-qtest-mips-y = tests/endianness-test$(EXESUF) check-qtest-mips64-y = tests/endianness-test$(EXESUF) check-qtest-mips64el-y = tests/endianness-test$(EXESUF) -check-qtest-mips-y += tests/qom-test$(EXESUF) -check-qtest-mipsel-y += tests/qom-test$(EXESUF) -check-qtest-mips64-y += tests/qom-test$(EXESUF) -check-qtest-mips64el-y += tests/qom-test$(EXESUF) check-qtest-ppc-y = tests/endianness-test$(EXESUF) check-qtest-ppc64-y = tests/endianness-test$(EXESUF) check-qtest-sh4-y = tests/endianness-test$(EXESUF) check-qtest-sh4eb-y = tests/endianness-test$(EXESUF) -check-qtest-sh4-y += tests/qom-test$(EXESUF) -check-qtest-sh4eb-y += tests/qom-test$(EXESUF) check-qtest-sparc64-y = tests/endianness-test$(EXESUF) #check-qtest-sparc-y = tests/m48t59-test$(EXESUF) #check-qtest-sparc64-y += tests/m48t59-test$(EXESUF) -gcov-files-sparc-y += hw/m48t59.c -gcov-files-sparc64-y += hw/m48t59.c -check-qtest-sparc-y += tests/qom-test$(EXESUF) -check-qtest-sparc64-y += tests/qom-test$(EXESUF) +gcov-files-sparc-y += hw/timer/m48t59.c +gcov-files-sparc64-y += hw/timer/m48t59.c check-qtest-arm-y = tests/tmp105-test$(EXESUF) -gcov-files-arm-y += hw/tmp105.c -check-qtest-arm-y += tests/qom-test$(EXESUF) +gcov-files-arm-y += hw/misc/tmp105.c check-qtest-ppc-y += tests/boot-order-test$(EXESUF) check-qtest-ppc64-y += tests/boot-order-test$(EXESUF) -check-qtest-ppc-y += tests/qom-test$(EXESUF) -check-qtest-ppc64-y += tests/qom-test$(EXESUF) -check-qtest-ppcemb-y += tests/qom-test$(EXESUF) -check-qtest-alpha-y += tests/qom-test$(EXESUF) -check-qtest-cris-y += tests/qom-test$(EXESUF) -check-qtest-lm32-y += tests/qom-test$(EXESUF) -check-qtest-m68k-y += tests/qom-test$(EXESUF) -check-qtest-microblaze-y += tests/qom-test$(EXESUF) check-qtest-microblazeel-y = $(check-qtest-microblaze-y) -check-qtest-moxie-y += tests/qom-test$(EXESUF) -check-qtest-or32-y += tests/qom-test$(EXESUF) -check-qtest-s390x-y += tests/qom-test$(EXESUF) -check-qtest-unicore32-y += tests/qom-test$(EXESUF) -check-qtest-xtensa-y += tests/qom-test$(EXESUF) check-qtest-xtensaeb-y = $(check-qtest-xtensa-y) +# qom-test works for all sysemu architectures: +$(foreach target,$(SYSEMU_TARGET_LIST), \ + $(eval check-qtest-$(target)-y += tests/qom-test$(EXESUF))) + check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ comments.json empty.json funny-char.json indented-expr.json \ missing-colon.json missing-comma-list.json \ @@ -163,7 +181,7 @@ tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o xbzrle.o page_cache.o libqemuuti tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o tests/test-int128$(EXESUF): tests/test-int128.o tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ - hw/core/qdev.o hw/core/qdev-properties.o \ + hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\ hw/core/irq.o \ $(qom-core-obj) \ $(test-qapi-obj-y) \ @@ -211,6 +229,15 @@ tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) +tests/e1000-test$(EXESUF): tests/e1000-test.o +tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o +tests/pcnet-test$(EXESUF): tests/pcnet-test.o +tests/eepro100-test$(EXESUF): tests/eepro100-test.o +tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o +tests/ne2000-test$(EXESUF): tests/ne2000-test.o +tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o +tests/tpci200-test$(EXESUF): tests/tpci200-test.o +tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) diff --git a/tests/acpi-test-data/pc/APIC b/tests/acpi-test-data/pc/APIC Binary files differnew file mode 100644 index 0000000000..84509e0ae4 --- /dev/null +++ b/tests/acpi-test-data/pc/APIC diff --git a/tests/acpi-test-data/pc/DSDT b/tests/acpi-test-data/pc/DSDT Binary files differnew file mode 100644 index 0000000000..fbf1c3e6e8 --- /dev/null +++ b/tests/acpi-test-data/pc/DSDT diff --git a/tests/acpi-test-data/pc/FACP b/tests/acpi-test-data/pc/FACP Binary files differnew file mode 100644 index 0000000000..0639999ed1 --- /dev/null +++ b/tests/acpi-test-data/pc/FACP diff --git a/tests/acpi-test-data/pc/FACS b/tests/acpi-test-data/pc/FACS Binary files differnew file mode 100644 index 0000000000..fc67ecc407 --- /dev/null +++ b/tests/acpi-test-data/pc/FACS diff --git a/tests/acpi-test-data/pc/HPET b/tests/acpi-test-data/pc/HPET Binary files differnew file mode 100644 index 0000000000..df689b8f99 --- /dev/null +++ b/tests/acpi-test-data/pc/HPET diff --git a/tests/acpi-test-data/pc/SSDT b/tests/acpi-test-data/pc/SSDT Binary files differnew file mode 100644 index 0000000000..a51c68e21b --- /dev/null +++ b/tests/acpi-test-data/pc/SSDT diff --git a/tests/acpi-test-data/q35/APIC b/tests/acpi-test-data/q35/APIC Binary files differnew file mode 100644 index 0000000000..84509e0ae4 --- /dev/null +++ b/tests/acpi-test-data/q35/APIC diff --git a/tests/acpi-test-data/q35/DSDT b/tests/acpi-test-data/q35/DSDT Binary files differnew file mode 100644 index 0000000000..5086b839a6 --- /dev/null +++ b/tests/acpi-test-data/q35/DSDT diff --git a/tests/acpi-test-data/q35/FACP b/tests/acpi-test-data/q35/FACP Binary files differnew file mode 100644 index 0000000000..19f3ac3ce6 --- /dev/null +++ b/tests/acpi-test-data/q35/FACP diff --git a/tests/acpi-test-data/q35/FACS b/tests/acpi-test-data/q35/FACS Binary files differnew file mode 100644 index 0000000000..fc67ecc407 --- /dev/null +++ b/tests/acpi-test-data/q35/FACS diff --git a/tests/acpi-test-data/q35/HPET b/tests/acpi-test-data/q35/HPET Binary files differnew file mode 100644 index 0000000000..df689b8f99 --- /dev/null +++ b/tests/acpi-test-data/q35/HPET diff --git a/tests/acpi-test-data/q35/MCFG b/tests/acpi-test-data/q35/MCFG Binary files differnew file mode 100644 index 0000000000..79ceb27a03 --- /dev/null +++ b/tests/acpi-test-data/q35/MCFG diff --git a/tests/acpi-test-data/q35/SSDT b/tests/acpi-test-data/q35/SSDT Binary files differnew file mode 100644 index 0000000000..9c6cad8b0b --- /dev/null +++ b/tests/acpi-test-data/q35/SSDT diff --git a/tests/acpi-test-data/rebuild-expected-aml.sh b/tests/acpi-test-data/rebuild-expected-aml.sh new file mode 100755 index 0000000000..ab98498884 --- /dev/null +++ b/tests/acpi-test-data/rebuild-expected-aml.sh @@ -0,0 +1,36 @@ +#! /bin/bash + +# +# Rebuild expected AML files for acpi unit-test +# +# Copyright (c) 2013 Red Hat Inc. +# +# Authors: +# Marcel Apfelbaum <marcel.a@redhat.com> +# +# This work is licensed under the terms of the GNU GPLv2. +# See the COPYING.LIB file in the top-level directory. + +qemu= + +if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then + qemu="x86_64-softmmu/qemu-system-x86_64" +elif [ -e i386-softmmu/qemu-system-i386 ]; then + qemu="i386-softmmu/qemu-system-i386" +else + echo "Run 'make' to build the qemu exectutable!" + echo "Run this script from the build directory." + exit 1; +fi + +if [ ! -e "tests/acpi-test" ]; then + echo "Test: acpi-test is required! Run make check before this script." + echo "Run this script from the build directory." + exit 1; +fi + +TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/acpi-test + +echo "The files were rebuilt and can be added to git." +echo "However, if new files were created, please copy them manually" \ + "to tests/acpi-test-data/pc/ or tests/acpi-test-data/q35/ ." diff --git a/tests/acpi-test.c b/tests/acpi-test.c index df1af83158..31f5359787 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -13,19 +13,32 @@ #include <string.h> #include <stdio.h> #include <glib.h> +#include <glib/gstdio.h> #include "qemu-common.h" #include "libqtest.h" #include "qemu/compiler.h" #include "hw/i386/acpi-defs.h" +#define MACHINE_PC "pc" +#define MACHINE_Q35 "q35" + +#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" +#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */ + /* DSDT and SSDTs format */ typedef struct { AcpiTableHeader header; - uint8_t *aml; - int aml_len; -} AcpiSdtTable; + gchar *aml; /* aml bytecode from guest */ + gsize aml_len; + gchar *aml_file; + gchar *asl; /* asl code generated from aml */ + gsize asl_len; + gchar *asl_file; + bool asl_file_retain; /* do not delete the temp asl */ +} QEMU_PACKED AcpiSdtTable; typedef struct { + const char *machine; uint32_t rsdp_addr; AcpiRsdpDescriptor rsdp_table; AcpiRsdtDescriptorRev1 rsdt_table; @@ -33,8 +46,7 @@ typedef struct { AcpiFacsDescriptorRev1 facs_table; uint32_t *rsdt_tables_addr; int rsdt_tables_nr; - AcpiSdtTable dsdt_table; - GArray *ssdt_tables; + GArray *tables; } test_data; #define LOW(x) ((x) & 0xff) @@ -51,13 +63,13 @@ typedef struct { field = readb(addr); \ break; \ case 2: \ - field = le16_to_cpu(readw(addr)); \ + field = readw(addr); \ break; \ case 4: \ - field = le32_to_cpu(readl(addr)); \ + field = readl(addr); \ break; \ case 8: \ - field = le64_to_cpu(readq(addr)); \ + field = readq(addr); \ break; \ default: \ g_assert(false); \ @@ -91,8 +103,10 @@ typedef struct { /* Boot sector code: write SIGNATURE into memory, * then halt. + * Q35 machine requires a minimum 0x7e000 bytes disk. + * (bug or feature?) */ -static uint8_t boot_sector[0x200] = { +static uint8_t boot_sector[0x7e000] = { /* 7c00: mov $0xdead,%ax */ [0x00] = 0xb8, [0x01] = LOW(SIGNATURE), @@ -117,17 +131,45 @@ static uint8_t boot_sector[0x200] = { }; static const char *disk = "tests/acpi-test-disk.raw"; +static const char *data_dir = "tests/acpi-test-data"; +#ifdef CONFIG_IASL +static const char *iasl = stringify(CONFIG_IASL); +#else +static const char *iasl; +#endif static void free_test_data(test_data *data) { + AcpiSdtTable *temp; int i; - g_free(data->rsdt_tables_addr); - for (i = 0; i < data->ssdt_tables->len; ++i) { - g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml); + if (data->rsdt_tables_addr) { + g_free(data->rsdt_tables_addr); + } + + for (i = 0; i < data->tables->len; ++i) { + temp = &g_array_index(data->tables, AcpiSdtTable, i); + if (temp->aml) { + g_free(temp->aml); + } + if (temp->aml_file) { + if (g_strstr_len(temp->aml_file, -1, "aml-")) { + unlink(temp->aml_file); + } + g_free(temp->aml_file); + } + if (temp->asl) { + g_free(temp->asl); + } + if (temp->asl_file) { + if (!temp->asl_file_retain) { + unlink(temp->asl_file); + } + g_free(temp->asl_file); + } } - g_array_free(data->ssdt_tables, false); - g_free(data->dsdt_table.aml); + + g_array_free(data->tables, false); } static uint8_t acpi_checksum(const uint8_t *data, int len) @@ -292,34 +334,219 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr) ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr); checksum = acpi_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) + - acpi_checksum(sdt_table->aml, sdt_table->aml_len); + acpi_checksum((uint8_t *)sdt_table->aml, sdt_table->aml_len); g_assert(!checksum); } static void test_acpi_dsdt_table(test_data *data) { - AcpiSdtTable *dsdt_table = &data->dsdt_table; + AcpiSdtTable dsdt_table; uint32_t addr = data->fadt_table.dsdt; - test_dst_table(dsdt_table, addr); - g_assert_cmphex(dsdt_table->header.signature, ==, ACPI_DSDT_SIGNATURE); + memset(&dsdt_table, 0, sizeof(dsdt_table)); + data->tables = g_array_new(false, true, sizeof(AcpiSdtTable)); + + test_dst_table(&dsdt_table, addr); + g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE); + + /* Place DSDT first */ + g_array_append_val(data->tables, dsdt_table); } -static void test_acpi_ssdt_tables(test_data *data) +static void test_acpi_tables(test_data *data) { - GArray *ssdt_tables; - int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */ + int tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */ int i; - ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable), - ssdt_tables_nr); - for (i = 0; i < ssdt_tables_nr; i++) { + for (i = 0; i < tables_nr; i++) { AcpiSdtTable ssdt_table; + + memset(&ssdt_table, 0 , sizeof(ssdt_table)); uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */ test_dst_table(&ssdt_table, addr); - g_array_append_val(ssdt_tables, ssdt_table); + g_array_append_val(data->tables, ssdt_table); + } +} + +static void dump_aml_files(test_data *data, bool rebuild) +{ + AcpiSdtTable *sdt; + GError *error = NULL; + gchar *aml_file = NULL; + gint fd; + ssize_t ret; + int i; + + for (i = 0; i < data->tables->len; ++i) { + sdt = &g_array_index(data->tables, AcpiSdtTable, i); + g_assert(sdt->aml); + + if (rebuild) { + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine, + (gchar *)&sdt->header.signature); + fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); + } else { + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error); + g_assert_no_error(error); + } + g_assert(fd >= 0); + + ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader)); + g_assert(ret == sizeof(AcpiTableHeader)); + ret = qemu_write_full(fd, sdt->aml, sdt->aml_len); + g_assert(ret == sdt->aml_len); + + close(fd); + + if (aml_file) { + g_free(aml_file); + } + } +} + +static bool compare_signature(AcpiSdtTable *sdt, uint32_t signature) +{ + return sdt->header.signature == signature; +} + +static void load_asl(GArray *sdts, AcpiSdtTable *sdt) +{ + AcpiSdtTable *temp; + GError *error = NULL; + GString *command_line = g_string_new(iasl); + gint fd; + gchar *out, *out_err; + gboolean ret; + int i; + + fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error); + g_assert_no_error(error); + close(fd); + + /* build command line */ + g_string_append_printf(command_line, " -p %s ", sdt->asl_file); + if (compare_signature(sdt, ACPI_DSDT_SIGNATURE) || + compare_signature(sdt, ACPI_SSDT_SIGNATURE)) { + for (i = 0; i < sdts->len; ++i) { + temp = &g_array_index(sdts, AcpiSdtTable, i); + if (compare_signature(temp, ACPI_DSDT_SIGNATURE) || + compare_signature(temp, ACPI_SSDT_SIGNATURE)) { + g_string_append_printf(command_line, "-e %s ", temp->aml_file); + } + } } - data->ssdt_tables = ssdt_tables; + g_string_append_printf(command_line, "-d %s", sdt->aml_file); + + /* pass 'out' and 'out_err' in order to be redirected */ + g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error); + g_assert_no_error(error); + + ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl, + &sdt->asl_len, &error); + g_assert(ret); + g_assert_no_error(error); + g_assert(sdt->asl_len); + + g_free(out); + g_free(out_err); + g_string_free(command_line, true); +} + +#define COMMENT_END "*/" +#define DEF_BLOCK "DefinitionBlock (" +#define BLOCK_NAME_END ".aml" + +static GString *normalize_asl(gchar *asl_code) +{ + GString *asl = g_string_new(asl_code); + gchar *comment, *block_name; + + /* strip comments (different generation days) */ + comment = g_strstr_len(asl->str, asl->len, COMMENT_END); + if (comment) { + asl = g_string_erase(asl, 0, comment + sizeof(COMMENT_END) - asl->str); + } + + /* strip def block name (it has file path in it) */ + if (g_str_has_prefix(asl->str, DEF_BLOCK)) { + block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END); + g_assert(block_name); + asl = g_string_erase(asl, 0, + block_name + sizeof(BLOCK_NAME_END) - asl->str); + } + + return asl; +} + +static GArray *load_expected_aml(test_data *data) +{ + int i; + AcpiSdtTable *sdt; + gchar *aml_file; + GError *error = NULL; + gboolean ret; + + GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable)); + for (i = 0; i < data->tables->len; ++i) { + AcpiSdtTable exp_sdt; + sdt = &g_array_index(data->tables, AcpiSdtTable, i); + + memset(&exp_sdt, 0, sizeof(exp_sdt)); + exp_sdt.header.signature = sdt->header.signature; + + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine, + (gchar *)&exp_sdt.header.signature); + exp_sdt.aml_file = aml_file; + g_assert(g_file_test(aml_file, G_FILE_TEST_EXISTS)); + ret = g_file_get_contents(aml_file, &exp_sdt.aml, + &exp_sdt.aml_len, &error); + g_assert(ret); + g_assert_no_error(error); + g_assert(exp_sdt.aml); + g_assert(exp_sdt.aml_len); + + g_array_append_val(exp_tables, exp_sdt); + } + + return exp_tables; +} + +static void test_acpi_asl(test_data *data) +{ + int i; + AcpiSdtTable *sdt, *exp_sdt; + test_data exp_data; + + memset(&exp_data, 0, sizeof(exp_data)); + exp_data.tables = load_expected_aml(data); + dump_aml_files(data, false); + for (i = 0; i < data->tables->len; ++i) { + GString *asl, *exp_asl; + + sdt = &g_array_index(data->tables, AcpiSdtTable, i); + exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i); + + load_asl(data->tables, sdt); + asl = normalize_asl(sdt->asl); + + load_asl(exp_data.tables, exp_sdt); + exp_asl = normalize_asl(exp_sdt->asl); + + if (g_strcmp0(asl->str, exp_asl->str)) { + sdt->asl_file_retain = true; + exp_sdt->asl_file_retain = true; + fprintf(stderr, + "acpi-test: Warning! %.4s mismatch. " + "Orig asl: %s, expected asl %s.\n", + (gchar *)&exp_sdt->header.signature, + sdt->asl_file, exp_sdt->asl_file); + } + g_string_free(asl, true); + g_string_free(exp_asl, true); + } + + free_test_data(&exp_data); } static void test_acpi_one(const char *params, test_data *data) @@ -329,10 +556,14 @@ static void test_acpi_one(const char *params, test_data *data) uint8_t signature_high; uint16_t signature; int i; + const char *device = ""; + + if (!g_strcmp0(data->machine, MACHINE_Q35)) { + device = ",id=hd -device ide-hd,drive=hd"; + } - memset(data, 0, sizeof(*data)); - args = g_strdup_printf("-net none -display none %s %s", - params ? params : "", disk); + args = g_strdup_printf("-net none -display none %s -drive file=%s%s,", + params ? params : "", disk, device); qtest_start(args); /* Wait at most 1 minute */ @@ -360,7 +591,15 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_fadt_table(data); test_acpi_facs_table(data); test_acpi_dsdt_table(data); - test_acpi_ssdt_tables(data); + test_acpi_tables(data); + + if (iasl) { + if (getenv(ACPI_REBUILD_EXPECTED_AML)) { + dump_aml_files(data, true); + } else { + test_acpi_asl(data); + } + } qtest_quit(global_qtest); g_free(args); @@ -373,8 +612,14 @@ static void test_acpi_tcg(void) /* Supplying -machine accel argument overrides the default (qtest). * This is to make guest actually run. */ + memset(&data, 0, sizeof(data)); + data.machine = MACHINE_PC; test_acpi_one("-machine accel=tcg", &data); + free_test_data(&data); + memset(&data, 0, sizeof(data)); + data.machine = MACHINE_Q35; + test_acpi_one("-machine q35,accel=tcg", &data); free_test_data(&data); } diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 7a7461b0b2..2ad0f7827e 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -306,6 +306,7 @@ static void qdict_array_split_test(void) { QDict *test_dict = qdict_new(); QDict *dict1, *dict2; + QInt *int1; QList *test_list; /* @@ -313,10 +314,11 @@ static void qdict_array_split_test(void) * * { * "1.x": 0, - * "3.y": 1, + * "4.y": 1, * "0.a": 42, * "o.o": 7, - * "0.b": 23 + * "0.b": 23, + * "2": 66 * } * * to @@ -328,13 +330,14 @@ static void qdict_array_split_test(void) * }, * { * "x": 0 - * } + * }, + * 66 * ] * * and * * { - * "3.y": 1, + * "4.y": 1, * "o.o": 7 * } * @@ -344,18 +347,21 @@ static void qdict_array_split_test(void) */ qdict_put(test_dict, "1.x", qint_from_int(0)); - qdict_put(test_dict, "3.y", qint_from_int(1)); + qdict_put(test_dict, "4.y", qint_from_int(1)); qdict_put(test_dict, "0.a", qint_from_int(42)); qdict_put(test_dict, "o.o", qint_from_int(7)); qdict_put(test_dict, "0.b", qint_from_int(23)); + qdict_put(test_dict, "2", qint_from_int(66)); qdict_array_split(test_dict, &test_list); dict1 = qobject_to_qdict(qlist_pop(test_list)); dict2 = qobject_to_qdict(qlist_pop(test_list)); + int1 = qobject_to_qint(qlist_pop(test_list)); g_assert(dict1); g_assert(dict2); + g_assert(int1); g_assert(qlist_empty(test_list)); QDECREF(test_list); @@ -373,12 +379,69 @@ static void qdict_array_split_test(void) QDECREF(dict2); - g_assert(qdict_get_int(test_dict, "3.y") == 1); + g_assert(qint_get_int(int1) == 66); + + QDECREF(int1); + + g_assert(qdict_get_int(test_dict, "4.y") == 1); g_assert(qdict_get_int(test_dict, "o.o") == 7); g_assert(qdict_size(test_dict) == 2); QDECREF(test_dict); + + + /* + * Test the split of + * + * { + * "0": 42, + * "1": 23, + * "1.x": 84 + * } + * + * to + * + * [ + * 42 + * ] + * + * and + * + * { + * "1": 23, + * "1.x": 84 + * } + * + * That is, test whether splitting stops if there is both an entry with key + * of "%u" and other entries with keys prefixed "%u." for the same index. + */ + + test_dict = qdict_new(); + + qdict_put(test_dict, "0", qint_from_int(42)); + qdict_put(test_dict, "1", qint_from_int(23)); + qdict_put(test_dict, "1.x", qint_from_int(84)); + + qdict_array_split(test_dict, &test_list); + + int1 = qobject_to_qint(qlist_pop(test_list)); + + g_assert(int1); + g_assert(qlist_empty(test_list)); + + QDECREF(test_list); + + g_assert(qint_get_int(int1) == 42); + + QDECREF(int1); + + g_assert(qdict_get_int(test_dict, "1") == 23); + g_assert(qdict_get_int(test_dict, "1.x") == 84); + + g_assert(qdict_size(test_dict) == 2); + + QDECREF(test_dict); } /* diff --git a/tests/e1000-test.c b/tests/e1000-test.c new file mode 100644 index 0000000000..a8ba2fc0a8 --- /dev/null +++ b/tests/e1000-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for e1000 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/e1000/nop", nop); + + qtest_start("-device e1000"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c new file mode 100644 index 0000000000..bf8252627e --- /dev/null +++ b/tests/eepro100-test.c @@ -0,0 +1,63 @@ +/* + * QTest testcase for eepro100 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +static void test_device(gconstpointer data) +{ + const char *model = data; + QTestState *s; + char *args; + + args = g_strdup_printf("-device %s", model); + s = qtest_start(args); + + /* Tests only initialization so far. TODO: Implement functional tests */ + + if (s) { + qtest_quit(s); + } + g_free(args); +} + +static const char *models[] = { + "i82550", + "i82551", + "i82557a", + "i82557b", + "i82557c", + "i82558a", + "i82558b", + "i82559a", + "i82559b", + "i82559c", + "i82559er", + "i82562", + "i82801", +}; + +int main(int argc, char **argv) +{ + int i; + + g_test_init(&argc, &argv, NULL); + + for (i = 0; i < ARRAY_SIZE(models); i++) { + char *path; + + path = g_strdup_printf("/%s/eepro100/%s", + qtest_get_arch(), models[i]); + g_test_add_data_func(path, models[i], test_device); + } + + return g_test_run(); +} diff --git a/tests/endianness-test.c b/tests/endianness-test.c index 646df7d8da..92e17d251a 100644 --- a/tests/endianness-test.c +++ b/tests/endianness-test.c @@ -10,7 +10,6 @@ * See the COPYING file in the top-level directory. * */ -#include "libqtest.h" #include <glib.h> #include <stdio.h> @@ -18,6 +17,7 @@ #include <stdlib.h> #include <unistd.h> +#include "libqtest.h" #include "qemu/bswap.h" typedef struct TestCase TestCase; diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index e4f355ce3f..5c8f8d6c24 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -10,15 +10,14 @@ * See the COPYING file in the top-level directory. */ -#define NO_QEMU_PROTOS +#include <string.h> +#include <glib.h> #include "libqtest.h" +#define NO_QEMU_PROTOS #include "hw/nvram/fw_cfg.h" #include "libqos/fw_cfg.h" -#include <string.h> -#include <glib.h> - static uint64_t ram_size = 128 << 20; static uint16_t nb_cpus = 1; static uint16_t max_cpus = 1; diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index fa3e3d6b87..ad232b561c 100644 --- a/tests/i440fx-test.c +++ b/tests/i440fx-test.c @@ -12,12 +12,6 @@ * See the COPYING file in the top-level directory. */ -#include "libqos/pci.h" -#include "libqos/pci-pc.h" -#include "libqtest.h" - -#include "hw/pci/pci_regs.h" - #include <glib.h> #include <string.h> #include <stdio.h> @@ -26,6 +20,11 @@ #include <sys/mman.h> #include <stdlib.h> +#include "libqtest.h" +#include "libqos/pci.h" +#include "libqos/pci-pc.h" +#include "hw/pci/pci_regs.h" + #define BROKEN 1 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) @@ -350,7 +349,7 @@ static void test_i440fx_firmware(FirmwareTestFixture *fixture, qtest_start(cmdline); g_free(cmdline); - /* Qemu has loaded the firmware (because qtest_start() only returns after + /* QEMU has loaded the firmware (because qtest_start() only returns after * the QMP handshake completes). We must unlink the firmware blob right * here, because any assertion firing below would leak it in the * filesystem. This is also the reason why we recreate the blob every time diff --git a/tests/ipoctal232-test.c b/tests/ipoctal232-test.c new file mode 100644 index 0000000000..3ac1714b48 --- /dev/null +++ b/tests/ipoctal232-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for IndustryPack Octal-RS232 + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/ipoctal232/tpci200/nop", nop); + + qtest_start("-device tpci200,id=ipack0 -device ipoctal232,bus=ipack0.0"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/libqtest.c b/tests/libqtest.c index 359d571a06..f587d36176 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -43,9 +43,8 @@ struct QTestState int qmp_fd; bool irq_level[MAX_IRQ]; GString *rx; - gchar *pid_file; /* QEMU PID file */ - int child_pid; /* Child process created to execute QEMU */ - char *socket_path, *qmp_socket_path; + pid_t qemu_pid; /* our child QEMU process */ + struct sigaction sigact_old; /* restored on exit */ }; #define g_assert_no_errno(ret) do { \ @@ -90,54 +89,58 @@ static int socket_accept(int sock) return ret; } -static pid_t qtest_qemu_pid(QTestState *s) +static void kill_qemu(QTestState *s) { - FILE *f; - char buffer[1024]; - pid_t pid = -1; - - f = fopen(s->pid_file, "r"); - if (f) { - if (fgets(buffer, sizeof(buffer), f)) { - pid = atoi(buffer); - } - fclose(f); + if (s->qemu_pid != -1) { + kill(s->qemu_pid, SIGTERM); + waitpid(s->qemu_pid, NULL, 0); } - return pid; +} + +static void sigabrt_handler(int signo) +{ + kill_qemu(global_qtest); } QTestState *qtest_init(const char *extra_args) { QTestState *s; int sock, qmpsock, i; - gchar *pid_file; + gchar *socket_path; + gchar *qmp_socket_path; gchar *command; const char *qemu_binary; - pid_t pid; + struct sigaction sigact; qemu_binary = getenv("QTEST_QEMU_BINARY"); g_assert(qemu_binary != NULL); s = g_malloc(sizeof(*s)); - s->socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); - s->qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); - pid_file = g_strdup_printf("/tmp/qtest-%d.pid", getpid()); + socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); + qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); + + sock = init_socket(socket_path); + qmpsock = init_socket(qmp_socket_path); - sock = init_socket(s->socket_path); - qmpsock = init_socket(s->qmp_socket_path); + /* Catch SIGABRT to clean up on g_assert() failure */ + sigact = (struct sigaction){ + .sa_handler = sigabrt_handler, + .sa_flags = SA_RESETHAND, + }; + sigemptyset(&sigact.sa_mask); + sigaction(SIGABRT, &sigact, &s->sigact_old); - pid = fork(); - if (pid == 0) { - command = g_strdup_printf("%s " + s->qemu_pid = fork(); + if (s->qemu_pid == 0) { + command = g_strdup_printf("exec %s " "-qtest unix:%s,nowait " "-qtest-log /dev/null " "-qmp unix:%s,nowait " - "-pidfile %s " "-machine accel=qtest " "-display none " - "%s", qemu_binary, s->socket_path, - s->qmp_socket_path, pid_file, + "%s", qemu_binary, socket_path, + qmp_socket_path, extra_args ?: ""); execlp("/bin/sh", "sh", "-c", command, NULL); exit(1); @@ -145,10 +148,12 @@ QTestState *qtest_init(const char *extra_args) s->fd = socket_accept(sock); s->qmp_fd = socket_accept(qmpsock); + unlink(socket_path); + unlink(qmp_socket_path); + g_free(socket_path); + g_free(qmp_socket_path); s->rx = g_string_new(""); - s->pid_file = pid_file; - s->child_pid = pid; for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; } @@ -158,7 +163,7 @@ QTestState *qtest_init(const char *extra_args) qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }"); if (getenv("QTEST_STOP")) { - kill(qtest_qemu_pid(s), SIGSTOP); + kill(s->qemu_pid, SIGSTOP); } return s; @@ -166,23 +171,12 @@ QTestState *qtest_init(const char *extra_args) void qtest_quit(QTestState *s) { - int status; - - pid_t pid = qtest_qemu_pid(s); - if (pid != -1) { - kill(pid, SIGTERM); - waitpid(pid, &status, 0); - } + sigaction(SIGABRT, &s->sigact_old, NULL); + kill_qemu(s); close(s->fd); close(s->qmp_fd); g_string_free(s->rx, true); - unlink(s->pid_file); - unlink(s->socket_path); - unlink(s->qmp_socket_path); - g_free(s->pid_file); - g_free(s->socket_path); - g_free(s->qmp_socket_path); g_free(s); } diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c index 6abc4c8bf0..71b4f28052 100644 --- a/tests/m48t59-test.c +++ b/tests/m48t59-test.c @@ -11,7 +11,6 @@ * See the COPYING file in the top-level directory. * */ -#include "libqtest.h" #include <glib.h> #include <stdio.h> @@ -19,6 +18,8 @@ #include <stdlib.h> #include <unistd.h> +#include "libqtest.h" + #define RTC_SECONDS 0x9 #define RTC_MINUTES 0xa #define RTC_HOURS 0xb diff --git a/tests/ne2000-test.c b/tests/ne2000-test.c new file mode 100644 index 0000000000..61a678ad30 --- /dev/null +++ b/tests/ne2000-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for ne2000 NIC + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/ne2000/pci/nop", pci_nop); + + qtest_start("-device ne2k_pci"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c new file mode 100644 index 0000000000..84af4f327a --- /dev/null +++ b/tests/pcnet-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for PC-Net NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/pcnet/pci/nop", pci_nop); + + qtest_start("-device pcnet"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 index 9abcb84e4b..ba1236dfbf 100755 --- a/tests/qemu-iotests/005 +++ b/tests/qemu-iotests/005 @@ -44,6 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt generic _supported_proto generic _supported_os Linux +_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ + "subformat=twoGbMaxExtentSparse" # vpc is limited to 127GB, so we can't test it here if [ "$IMGFMT" = "vpc" ]; then diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013 index 389f4b8156..ea3cab91d6 100755 --- a/tests/qemu-iotests/013 +++ b/tests/qemu-iotests/013 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # much of this could be generic for any format supporting compression. _supported_fmt qcow qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux TEST_OFFSETS="0 4294967296" diff --git a/tests/qemu-iotests/014 b/tests/qemu-iotests/014 index 0edeb4b6f5..b23c2db9b6 100755 --- a/tests/qemu-iotests/014 +++ b/tests/qemu-iotests/014 @@ -43,7 +43,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # much of this could be generic for any format supporting snapshots _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux TEST_OFFSETS="0 4294967296" diff --git a/tests/qemu-iotests/016 b/tests/qemu-iotests/016 index b87a32bc27..7ea9e94b5d 100755 --- a/tests/qemu-iotests/016 +++ b/tests/qemu-iotests/016 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt raw -_supported_proto file sheepdog +_supported_proto file sheepdog nfs _supported_os Linux diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 index 6f7f0545d0..d8a7d435ab 100755 --- a/tests/qemu-iotests/018 +++ b/tests/qemu-iotests/018 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Any format supporting backing files _supported_fmt qcow qcow2 vmdk qed -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 index b43e70f3cb..e67445c754 100755 --- a/tests/qemu-iotests/019 +++ b/tests/qemu-iotests/019 @@ -45,7 +45,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Any format supporting backing files _supported_fmt qcow qcow2 vmdk qed -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" \ "subformat=twoGbMaxExtentFlat" \ diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 index 73a0429481..2f258dc6e9 100755 --- a/tests/qemu-iotests/020 +++ b/tests/qemu-iotests/020 @@ -49,6 +49,11 @@ _unsupported_imgopts "subformat=monolithicFlat" \ "subformat=twoGbMaxExtentFlat" \ "subformat=twoGbMaxExtentSparse" +# NFS does not support bdrv_reopen_prepare thus qemu-img commit fails. +if [ "$IMGPROTO" = "nfs" ]; then + _notrun "image protocol $IMGPROTO does not support bdrv_commit" +fi + TEST_OFFSETS="0 4294967296" _make_test_img 6G diff --git a/tests/qemu-iotests/023 b/tests/qemu-iotests/023 index 090ed23dec..9ad06b990e 100755 --- a/tests/qemu-iotests/023 +++ b/tests/qemu-iotests/023 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # much of this could be generic for any format supporting compression. _supported_fmt qcow qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux TEST_OFFSETS="0 4294967296" diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024 index be974f02a2..9bf99e198a 100755 --- a/tests/qemu-iotests/024 +++ b/tests/qemu-iotests/024 @@ -43,7 +43,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Currently only qcow2 and qed support rebasing _supported_fmt qcow2 qed -_supported_proto generic +_supported_proto file _supported_os Linux CLUSTER_SIZE=65536 diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025 index 9426c93bd0..a5f45b454c 100755 --- a/tests/qemu-iotests/025 +++ b/tests/qemu-iotests/025 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.pattern _supported_fmt raw qcow2 qed -_supported_proto file sheepdog rbd +_supported_proto file sheepdog rbd nfs _supported_os Linux echo "=== Creating image" diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index c9c5f83936..df2884ba51 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Currently only qcow2 supports rebasing _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux _default_cache_mode "writethrough" _supported_cache_modes "writethrough" "none" diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 index 93a9fa6e83..a99e4fa2bd 100755 --- a/tests/qemu-iotests/028 +++ b/tests/qemu-iotests/028 @@ -45,7 +45,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Any format supporting backing files except vmdk and qcow which do not support # smaller backing files. _supported_fmt qcow2 qed -_supported_proto generic +_supported_proto file _supported_os Linux # Choose a size that is not necessarily a cluster size multiple for image diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 index c9070b0513..1d920ea87a 100755 --- a/tests/qemu-iotests/031 +++ b/tests/qemu-iotests/031 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux CLUSTER_SIZE=65536 diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034 index 7349789583..69c7858586 100755 --- a/tests/qemu-iotests/034 +++ b/tests/qemu-iotests/034 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt qcow qcow2 vmdk qed -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" \ "subformat=twoGbMaxExtentFlat" \ diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 index e049a645e7..03b6aa9de7 100755 --- a/tests/qemu-iotests/036 +++ b/tests/qemu-iotests/036 @@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux # Only qcow2v3 and later supports feature bits diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037 index e444349e6d..9171d8c8a6 100755 --- a/tests/qemu-iotests/037 +++ b/tests/qemu-iotests/037 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt qcow qcow2 vmdk qed -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" \ "subformat=twoGbMaxExtentFlat" \ diff --git a/tests/qemu-iotests/038 b/tests/qemu-iotests/038 index 7bb7906e7f..cfaf00a783 100755 --- a/tests/qemu-iotests/038 +++ b/tests/qemu-iotests/038 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt qcow2 qed -_supported_proto generic +_supported_proto file _supported_os Linux CLUSTER_SIZE=2M diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 6abf47267f..9b355c0977 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux _default_cache_mode "writethrough" _supported_cache_modes "writethrough" diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 72eaad5b08..734b6a6bb4 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -35,12 +35,8 @@ test_img = os.path.join(iotests.test_dir, 'test.img') class ImageCommitTestCase(iotests.QMPTestCase): '''Abstract base class for image commit test cases''' - def assert_no_active_commit(self): - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return', []) - def run_commit_test(self, top, base): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top=top, base=base) self.assert_qmp(result, 'return', {}) @@ -59,7 +55,7 @@ class ImageCommitTestCase(iotests.QMPTestCase): self.assert_qmp(event, 'data/len', self.image_len) self.vm.qmp('block-job-complete', device='drive0') - self.assert_no_active_commit() + self.assert_no_active_block_jobs() self.vm.shutdown() class TestSingleDrive(ImageCommitTestCase): @@ -91,19 +87,19 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_qmp(result, 'error/class', 'DeviceNotFound') def test_top_same_base(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % backing_img, base='%s' % backing_img) self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % backing_img) def test_top_invalid(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='badfile', base='%s' % backing_img) self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Top image file badfile not found') def test_base_invalid(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % mid_img, base='badfile') self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found') @@ -114,13 +110,13 @@ class TestSingleDrive(ImageCommitTestCase): self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed")) def test_top_and_base_reversed(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % backing_img, base='%s' % mid_img) self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % mid_img) def test_top_omitted(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0') self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', "Parameter 'top' is missing") @@ -181,19 +177,19 @@ class TestRelativePaths(ImageCommitTestCase): self.assert_qmp(result, 'error/class', 'DeviceNotFound') def test_top_same_base(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img, base='%s' % self.mid_img) self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % self.mid_img) def test_top_invalid(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='badfile', base='%s' % self.backing_img) self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Top image file badfile not found') def test_base_invalid(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img, base='badfile') self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found') @@ -204,7 +200,7 @@ class TestRelativePaths(ImageCommitTestCase): self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed")) def test_top_and_base_reversed(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.backing_img, base='%s' % self.mid_img) self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % self.mid_img) @@ -229,7 +225,7 @@ class TestSetSpeed(ImageCommitTestCase): os.remove(backing_img) def test_set_speed(self): - self.assert_no_active_commit() + self.assert_no_active_block_jobs() self.vm.pause_drive('drive0') result = self.vm.qmp('block-commit', device='drive0', top=mid_img, speed=1024 * 1024) diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043 index d7f12319b3..b316b97c0c 100755 --- a/tests/qemu-iotests/043 +++ b/tests/qemu-iotests/043 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Any format supporting backing files _supported_fmt qcow2 qed -_supported_proto generic +_supported_proto file _supported_os Linux diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index 3f17ceb1b9..e0be46cf2b 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux CLUSTER_SIZE=64k @@ -193,6 +193,16 @@ echo "== Verify image content ==" function verify_io() { + if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep "compat: 0.10" > /dev/null); then + # For v2 images, discarded clusters are read from the backing file + # Keep the variable empty so that the backing file value can be used as + # the default below + discarded= + else + # Discarded clusters are zeroed for v3 or later + discarded=0 + fi + echo read -P 0 0 0x10000 echo read -P 1 0x10000 0x2000 @@ -221,16 +231,16 @@ function verify_io() echo read -P 70 0x78000 0x6000 echo read -P 7 0x7e000 0x2000 - echo read -P 8 0x80000 0x6000 + echo read -P ${discarded:-8} 0x80000 0x6000 echo read -P 80 0x86000 0x2000 - echo read -P 8 0x88000 0x2000 + echo read -P ${discarded:-8} 0x88000 0x2000 echo read -P 81 0x8a000 0xe000 echo read -P 90 0x98000 0x6000 echo read -P 9 0x9e000 0x2000 - echo read -P 10 0xa0000 0x6000 + echo read -P ${discarded:-10} 0xa0000 0x6000 echo read -P 100 0xa6000 0x2000 - echo read -P 10 0xa8000 0x2000 + echo read -P ${discarded:-10} 0xa8000 0x2000 echo read -P 101 0xaa000 0xe000 echo read -P 110 0xb8000 0x8000 diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 index b23d91b6f0..46345fb155 100755 --- a/tests/qemu-iotests/051 +++ b/tests/qemu-iotests/051 @@ -172,6 +172,18 @@ run_qemu -drive file="$TEST_IMG",file.driver=file run_qemu -drive file="$TEST_IMG",file.driver=qcow2 echo +echo === Leaving out required options === +echo + +run_qemu -drive driver=file +run_qemu -drive driver=nbd +run_qemu -drive driver=raw +run_qemu -drive file.driver=file +run_qemu -drive file.driver=nbd +run_qemu -drive file.driver=raw +run_qemu -drive foo=bar + +echo echo === Parsing protocol from file name === echo diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index d0c5173626..7de18704f8 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -225,6 +225,30 @@ Testing: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device '' doesn't support the option 'filename' +=== Leaving out required options === + +Testing: -drive driver=file +QEMU_PROG: -drive driver=file: could not open disk image ide0-hd0: The 'file' block driver requires a file name + +Testing: -drive driver=nbd +QEMU_PROG: -drive driver=nbd: could not open disk image ide0-hd0: one of path and host must be specified. + +Testing: -drive driver=raw +QEMU_PROG: -drive driver=raw: could not open disk image ide0-hd0: Can't use 'raw' as a block driver for the protocol level + +Testing: -drive file.driver=file +QEMU_PROG: -drive file.driver=file: could not open disk image ide0-hd0: The 'file' block driver requires a file name + +Testing: -drive file.driver=nbd +QEMU_PROG: -drive file.driver=nbd: could not open disk image ide0-hd0: one of path and host must be specified. + +Testing: -drive file.driver=raw +QEMU_PROG: -drive file.driver=raw: could not open disk image ide0-hd0: Can't use 'raw' as a block driver for the protocol level + +Testing: -drive foo=bar +QEMU_PROG: -drive foo=bar: could not open disk image ide0-hd0: Must specify either driver or file + + === Parsing protocol from file name === Testing: -hda foo:bar diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 index 4d4e411339..6bdae92780 100755 --- a/tests/qemu-iotests/052 +++ b/tests/qemu-iotests/052 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt generic -_supported_proto generic +_supported_proto file _supported_os Linux _default_cache_mode "writethrough" _supported_cache_modes "writethrough" diff --git a/tests/qemu-iotests/054 b/tests/qemu-iotests/054 index 5a0d1b16c2..c8b7082b4e 100755 --- a/tests/qemu-iotests/054 +++ b/tests/qemu-iotests/054 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux echo diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 index 2d604d3a91..ca5aa16ff7 100755 --- a/tests/qemu-iotests/059 +++ b/tests/qemu-iotests/059 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests vmdk-specific low-level functionality _supported_fmt vmdk -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" \ "subformat=twoGbMaxExtentFlat" \ diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out index 4ffeb54710..3371c867bb 100644 --- a/tests/qemu-iotests/059.out +++ b/tests/qemu-iotests/059.out @@ -7,8 +7,7 @@ no file open, try 'help open' === Testing too big L2 table size === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -L2 table size too big -qemu-io: can't open device TEST_DIR/t.vmdk: Could not open 'TEST_DIR/t.vmdk': Wrong medium type +qemu-io: can't open device TEST_DIR/t.vmdk: L2 table size too big no file open, try 'help open' === Testing too big L1 table size === @@ -2045,8 +2044,7 @@ RW 12582912 VMFS "dummy.IMGFMT" 1 === Testing truncated sparse === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 -qemu-img: File truncated, expecting at least 13172736 bytes -qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'TEST_DIR/t.IMGFMT': Wrong medium type +qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes === Testing version 3 === image: TEST_DIR/iotest-version3.IMGFMT diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index bbb19090a1..af8ed9f39a 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux rt_offset=65536 # 0x10000 (XXX: just an assumption) diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index e42f9bd5e8..d3a6b388b5 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux echo diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 index 77503a2984..a47493a076 100755 --- a/tests/qemu-iotests/063 +++ b/tests/qemu-iotests/063 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.pattern _supported_fmt qcow qcow2 vmdk qed raw -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" \ "subformat=twoGbMaxExtentFlat" \ diff --git a/tests/qemu-iotests/069 b/tests/qemu-iotests/069 index 50347d91d2..e661598c4a 100755 --- a/tests/qemu-iotests/069 +++ b/tests/qemu-iotests/069 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt cow qed qcow qcow2 vmdk -_supported_proto generic +_supported_proto file _supported_os Linux _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" diff --git a/tests/qemu-iotests/070 b/tests/qemu-iotests/070 index 41bf100701..ce71fa4a22 100755 --- a/tests/qemu-iotests/070 +++ b/tests/qemu-iotests/070 @@ -56,11 +56,22 @@ _use_sample_img iotest-dirtylog-10G-4M.vhdx.bz2 echo echo "=== Verify open image read-only fails, due to dirty log ===" -$QEMU_IO -r -c "read -pP 0xa5 0 18M" "$TEST_IMG" 2>&1 | grep -o "Permission denied" +$QEMU_IO -r -c "read -pP 0xa5 0 18M" "$TEST_IMG" 2>&1 | _filter_testdir \ + | _filter_qemu_io echo "=== Verify open image replays log ===" $QEMU_IO -c "read -pP 0xa5 0 18M" "$TEST_IMG" | _filter_qemu_io +# extract fresh sample image again +_use_sample_img iotest-dirtylog-10G-4M.vhdx.bz2 + +echo "=== Verify qemu-img check -r all replays log ===" +$QEMU_IMG check -r all "$TEST_IMG" 2>&1 | _filter_testdir | _filter_qemu + +echo "=== Verify open image read-only succeeds after log replay ===" +$QEMU_IO -r -c "read -pP 0xa5 0 18M" "$TEST_IMG" 2>&1 | _filter_testdir \ + | _filter_qemu_io + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/070.out b/tests/qemu-iotests/070.out index 9db8ff2650..922d62cb51 100644 --- a/tests/qemu-iotests/070.out +++ b/tests/qemu-iotests/070.out @@ -1,8 +1,21 @@ QA output created by 070 === Verify open image read-only fails, due to dirty log === -Permission denied +qemu-io: can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed. To replay the log, execute: + qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx': Operation not permitted + no file open, try 'help open' === Verify open image replays log === read 18874368/18874368 bytes at offset 0 18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=== Verify qemu-img check -r all replays log === +The following inconsistencies were found and repaired: + + 0 leaked clusters + 1 corruptions + +Double checking the fixed image now... +No errors were found on the image. +=== Verify open image read-only succeeds after log replay === +read 18874368/18874368 bytes at offset 0 +18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 index 2a22546e1a..3924e51f51 100755 --- a/tests/qemu-iotests/071 +++ b/tests/qemu-iotests/071 @@ -38,8 +38,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.rc . ./common.filter -_supported_fmt generic -_supported_proto generic +_supported_fmt qcow2 +_supported_proto file _supported_os Linux function do_run_qemu() diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 index a3876c2161..58faa8b5a7 100755 --- a/tests/qemu-iotests/072 +++ b/tests/qemu-iotests/072 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow cow -_supported_proto generic +_supported_proto file _supported_os Linux IMG_SIZE=64M diff --git a/tests/qemu-iotests/077 b/tests/qemu-iotests/077 index bbf7b5145a..4dd1bdde20 100755 --- a/tests/qemu-iotests/077 +++ b/tests/qemu-iotests/077 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.rc . ./common.filter -_supported_fmt generic +_supported_fmt raw _supported_proto generic _supported_os Linux diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079 new file mode 100755 index 0000000000..2142bbb377 --- /dev/null +++ b/tests/qemu-iotests/079 @@ -0,0 +1,63 @@ +#!/bin/bash +# +# Test qcow2 preallocation with different cluster_sizes +# +# Copyright (C) 2014 Fujitsu. +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner=hutao@cn.fujitsu.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +function test_qemu_img() +{ + echo qemu-img "$@" | _filter_testdir + $QEMU_IMG "$@" 2>&1 | _filter_testdir + echo +} + +echo "=== Check option preallocation and cluster_size ===" +echo +cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304" + +for s in $cluster_sizes; do + test_qemu_img create -f $IMGFMT -o preallocation=metadata,cluster_size=$s "$TEST_IMG" 4G +done + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/079.out b/tests/qemu-iotests/079.out new file mode 100644 index 0000000000..ef4b8c9117 --- /dev/null +++ b/tests/qemu-iotests/079.out @@ -0,0 +1,32 @@ +QA output created by 079 +=== Check option preallocation and cluster_size === + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=16384 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=16384 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=32768 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=32768 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=65536 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=65536 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=131072 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=131072 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=262144 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=262144 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=524288 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=524288 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=1048576 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=1048576 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=2097152 TEST_DIR/t.qcow2 4G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=2097152 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=4194304 TEST_DIR/t.qcow2 4G +qemu-img: TEST_DIR/t.qcow2: Cluster size must be a power of two between 512 and 2048k +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=4194304 preallocation='metadata' lazy_refcounts=off + +*** done diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 new file mode 100755 index 0000000000..f053f11942 --- /dev/null +++ b/tests/qemu-iotests/081 @@ -0,0 +1,146 @@ +#!/bin/bash +# +# Test Quorum block driver +# +# Copyright (C) 2013 Nodalink, SARL. +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner=benoit@irqsave.net + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + rm -rf $TEST_DIR/1.raw + rm -rf $TEST_DIR/2.raw + rm -rf $TEST_DIR/3.raw +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto generic +_supported_os Linux + +function do_run_qemu() +{ + echo Testing: "$@" | _filter_imgfmt + $QEMU -nographic -qmp stdio -serial none "$@" + echo +} + +function run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu_io +} + +quorum="file.driver=quorum,file.children.0.file.filename=$TEST_DIR/1.raw" +quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" +quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw,file.vote-threshold=2" + +echo +echo "== creating quorum files ==" + +size=10M + +TEST_IMG="$TEST_DIR/1.raw" _make_test_img $size +TEST_IMG="$TEST_DIR/2.raw" _make_test_img $size +TEST_IMG="$TEST_DIR/3.raw" _make_test_img $size + +echo +echo "== writing images ==" + +$QEMU_IO -c "open -o $quorum" -c "write -P 0x32 0 $size" | _filter_qemu_io + +echo +echo "== checking quorum write ==" + +$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io +$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io +$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/3.raw" | _filter_qemu_io + +echo +echo "== corrupting image ==" + +$QEMU_IO -c "write -P 0x42 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io + +echo +echo "== checking quorum correction ==" + +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io + +echo +echo "== checking mixed reference/option specification ==" + +run_qemu -drive "file=$TEST_DIR/2.raw,format=$IMGFMT,if=none,id=drive2" <<EOF +{ "execute": "qmp_capabilities" } +{ "execute": "blockdev-add", + "arguments": { + "options": { + "driver": "quorum", + "id": "drive0-quorum", + "vote-threshold": 2, + "children": [ + { + "driver": "raw", + "file": { + "driver": "file", + "filename": "$TEST_DIR/1.raw" + } + }, + "drive2", + { + "driver": "raw", + "file": { + "driver": "file", + "filename": "$TEST_DIR/3.raw" + } + } + ] + } + } +} +{ "execute": "human-monitor-command", + "arguments": { + "command-line": 'qemu-io drive0-quorum "read -P 0x32 0 $size"' + } +} +{ "execute": "quit" } +EOF + +echo +echo "== breaking quorum ==" + +$QEMU_IO -c "write -P 0x41 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io +echo +echo "== checking that quorum is broken ==" + +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io + + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out new file mode 100644 index 0000000000..4fe2f95f63 --- /dev/null +++ b/tests/qemu-iotests/081.out @@ -0,0 +1,49 @@ +QA output created by 081 + +== creating quorum files == +Formatting 'TEST_DIR/1.IMGFMT', fmt=IMGFMT size=10485760 +Formatting 'TEST_DIR/2.IMGFMT', fmt=IMGFMT size=10485760 +Formatting 'TEST_DIR/3.IMGFMT', fmt=IMGFMT size=10485760 + +== writing images == +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking quorum write == +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== corrupting image == +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking quorum correction == +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking mixed reference/option specification == +Testing: -drive file=TEST_DIR/2.IMGFMT,format=IMGFMT,if=none,id=drive2 +QMP_VERSION +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "QUORUM_REPORT_BAD", "data": {"node-name": "", "ret": 0, "sectors-count": 20480, "sector-num": 0}} +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +{"return": ""} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} + + +== breaking quorum == +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking that quorum is broken == +qemu-io: can't open device (null): Could not read image for determining its format: Input/output error +*** done diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082 new file mode 100755 index 0000000000..f6eb75f624 --- /dev/null +++ b/tests/qemu-iotests/082 @@ -0,0 +1,208 @@ +#!/bin/bash +# +# Test qemu-img command line parsing +# +# Copyright (C) 2014 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner=kwolf@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +function run_qemu_img() +{ + echo + echo Testing: "$@" | _filter_testdir + "$QEMU_IMG" "$@" 2>&1 | _filter_testdir +} + +size=128M + +echo +echo === create: Options specified more than once === + +# Last -f should win +run_qemu_img create -f foo -f $IMGFMT "$TEST_IMG" $size +run_qemu_img info "$TEST_IMG" + +# Multiple -o should be merged +run_qemu_img create -f $IMGFMT -o cluster_size=4k -o lazy_refcounts=on "$TEST_IMG" $size +run_qemu_img info "$TEST_IMG" + +# If the same -o key is specified more than once, the last one wins +run_qemu_img create -f $IMGFMT -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k "$TEST_IMG" $size +run_qemu_img info "$TEST_IMG" +run_qemu_img create -f $IMGFMT -o cluster_size=4k,cluster_size=8k "$TEST_IMG" $size +run_qemu_img info "$TEST_IMG" + +echo +echo === create: help for -o === + +# Adding the help option to a command without other -o options +run_qemu_img create -f $IMGFMT -o help "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o \? "$TEST_IMG" $size + +# Adding the help option to the same -o option +run_qemu_img create -f $IMGFMT -o cluster_size=4k,help "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o cluster_size=4k,\? "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o help,cluster_size=4k "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o \?,cluster_size=4k "$TEST_IMG" $size + +# Adding the help option to a separate -o option +run_qemu_img create -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" $size + +# Looks like a help option, but is part of the backing file name +run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size + +# Try to trick qemu-img into creating escaped commas +run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG" -o ,help "$TEST_IMG" $size +run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_IMG" $size + +# Leave out everything that isn't needed +run_qemu_img create -f $IMGFMT -o help +run_qemu_img create -o help + +echo +echo === convert: Options specified more than once === + +# We need a valid source image +run_qemu_img create -f $IMGFMT "$TEST_IMG" $size + +# Last -f should win +run_qemu_img convert -f foo -f $IMGFMT "$TEST_IMG" "$TEST_IMG".base +run_qemu_img info "$TEST_IMG".base + +# Last -O should win +run_qemu_img convert -O foo -O $IMGFMT "$TEST_IMG" "$TEST_IMG".base +run_qemu_img info "$TEST_IMG".base + +# Multiple -o should be merged +run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o lazy_refcounts=on "$TEST_IMG" "$TEST_IMG".base +run_qemu_img info "$TEST_IMG".base + +# If the same -o key is specified more than once, the last one wins +run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k "$TEST_IMG" "$TEST_IMG".base +run_qemu_img info "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o cluster_size=4k,cluster_size=8k "$TEST_IMG" "$TEST_IMG".base +run_qemu_img info "$TEST_IMG".base + +echo +echo === convert: help for -o === + +# Adding the help option to a command without other -o options +run_qemu_img convert -O $IMGFMT -o help "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o \? "$TEST_IMG" "$TEST_IMG".base + +# Adding the help option to the same -o option +run_qemu_img convert -O $IMGFMT -o cluster_size=4k,help "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o cluster_size=4k,\? "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o help,cluster_size=4k "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o \?,cluster_size=4k "$TEST_IMG" "$TEST_IMG".base + +# Adding the help option to a separate -o option +run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" "$TEST_IMG".base + +# Looks like a help option, but is part of the backing file name +run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG" "$TEST_IMG".base + +# Try to trick qemu-img into creating escaped commas +run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG" -o ,help "$TEST_IMG" "$TEST_IMG".base +run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_IMG" "$TEST_IMG".base + +# Leave out everything that isn't needed +run_qemu_img convert -O $IMGFMT -o help +run_qemu_img convert -o help + +echo +echo === amend: Options specified more than once === + +# Last -f should win +run_qemu_img amend -f foo -f $IMGFMT -o lazy_refcounts=on "$TEST_IMG" +run_qemu_img info "$TEST_IMG" + +# Multiple -o should be merged +run_qemu_img amend -f $IMGFMT -o size=130M -o lazy_refcounts=off "$TEST_IMG" +run_qemu_img info "$TEST_IMG" + +# If the same -o key is specified more than once, the last one wins +run_qemu_img amend -f $IMGFMT -o size=8M -o lazy_refcounts=on -o size=132M "$TEST_IMG" +run_qemu_img info "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o size=4M,size=148M "$TEST_IMG" +run_qemu_img info "$TEST_IMG" + +echo +echo === amend: help for -o === + +# Adding the help option to a command without other -o options +run_qemu_img amend -f $IMGFMT -o help "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o \? "$TEST_IMG" + +# Adding the help option to the same -o option +run_qemu_img amend -f $IMGFMT -o cluster_size=4k,help "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o cluster_size=4k,\? "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o help,cluster_size=4k "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o \?,cluster_size=4k "$TEST_IMG" + +# Adding the help option to a separate -o option +run_qemu_img amend -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" + +# Looks like a help option, but is part of the backing file name +run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG" +run_qemu_img rebase -u -b "" -f $IMGFMT "$TEST_IMG" + +run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG" +run_qemu_img rebase -u -b "" -f $IMGFMT "$TEST_IMG" + +# Try to trick qemu-img into creating escaped commas +run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG" -o ,help "$TEST_IMG" +run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_IMG" + +# Leave out everything that isn't needed +run_qemu_img amend -f $IMGFMT -o help +run_qemu_img convert -o help + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out new file mode 100644 index 0000000000..28309a0327 --- /dev/null +++ b/tests/qemu-iotests/082.out @@ -0,0 +1,529 @@ +QA output created by 082 + +=== create: Options specified more than once === + +Testing: create -f foo -f qcow2 TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off cluster_size=65536 lazy_refcounts=off + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 196K +cluster_size: 65536 +Format specific information: + compat: 1.1 + lazy refcounts: false + +Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off cluster_size=4096 lazy_refcounts=on + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 16K +cluster_size: 4096 +Format specific information: + compat: 1.1 + lazy refcounts: true + +Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off cluster_size=8192 lazy_refcounts=on + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 28K +cluster_size: 8192 +Format specific information: + compat: 1.1 + lazy refcounts: true + +Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off cluster_size=8192 lazy_refcounts=off + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 28K +cluster_size: 8192 +Format specific information: + compat: 1.1 + lazy refcounts: false + +=== create: help for -o === + +Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 128M +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2,help' encryption=off cluster_size=65536 lazy_refcounts=off + +Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2,?' encryption=off cluster_size=65536 lazy_refcounts=off + +Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 128M +qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2, + +Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,help TEST_DIR/t.qcow2 128M +qemu-img: Invalid option list: ,help + +Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/t.qcow2 128M +qemu-img: Invalid option list: ,, + +Testing: create -f qcow2 -o help +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: create -o help +Supported options: +size Virtual disk size + +=== convert: Options specified more than once === + +Testing: create -f qcow2 TEST_DIR/t.qcow2 128M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off cluster_size=65536 lazy_refcounts=off + +Testing: convert -f foo -f qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base + +Testing: info TEST_DIR/t.qcow2.base +image: TEST_DIR/t.qcow2.base +file format: raw +virtual size: 128M (134217728 bytes) +disk size: 0 + +Testing: convert -O foo -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base + +Testing: info TEST_DIR/t.qcow2.base +image: TEST_DIR/t.qcow2.base +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 196K +cluster_size: 65536 +Format specific information: + compat: 1.1 + lazy refcounts: false + +Testing: convert -O qcow2 -o cluster_size=4k -o lazy_refcounts=on TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base + +Testing: info TEST_DIR/t.qcow2.base +image: TEST_DIR/t.qcow2.base +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 16K +cluster_size: 4096 +Format specific information: + compat: 1.1 + lazy refcounts: true + +Testing: convert -O qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base + +Testing: info TEST_DIR/t.qcow2.base +image: TEST_DIR/t.qcow2.base +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 28K +cluster_size: 8192 +Format specific information: + compat: 1.1 + lazy refcounts: true + +Testing: convert -O qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base + +Testing: info TEST_DIR/t.qcow2.base +image: TEST_DIR/t.qcow2.base +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 28K +cluster_size: 8192 +Format specific information: + compat: 1.1 + lazy refcounts: false + +=== convert: help for -o === + +Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory + +Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,?': No such file or directory + +Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2, + +Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +qemu-img: Invalid option list: ,help + +Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base +qemu-img: Invalid option list: ,, + +Testing: convert -O qcow2 -o help +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -o help +Supported options: +size Virtual disk size + +=== amend: Options specified more than once === + +Testing: amend -f foo -f qcow2 -o lazy_refcounts=on TEST_DIR/t.qcow2 + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 128M (134217728 bytes) +disk size: 196K +cluster_size: 65536 +Format specific information: + compat: 1.1 + lazy refcounts: true + +Testing: amend -f qcow2 -o size=130M -o lazy_refcounts=off TEST_DIR/t.qcow2 + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 130M (136314880 bytes) +disk size: 196K +cluster_size: 65536 +Format specific information: + compat: 1.1 + lazy refcounts: false + +Testing: amend -f qcow2 -o size=8M -o lazy_refcounts=on -o size=132M TEST_DIR/t.qcow2 + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 132M (138412032 bytes) +disk size: 196K +cluster_size: 65536 +Format specific information: + compat: 1.1 + lazy refcounts: true + +Testing: amend -f qcow2 -o size=4M,size=148M TEST_DIR/t.qcow2 + +Testing: info TEST_DIR/t.qcow2 +image: TEST_DIR/t.qcow2 +file format: qcow2 +virtual size: 148M (155189248 bytes) +disk size: 196K +cluster_size: 65536 +Format specific information: + compat: 1.1 + lazy refcounts: true + +=== amend: help for -o === + +Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 + +Testing: rebase -u -b -f qcow2 TEST_DIR/t.qcow2 + +Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 + +Testing: rebase -u -b -f qcow2 TEST_DIR/t.qcow2 + +Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 +qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2, + +Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,help TEST_DIR/t.qcow2 +qemu-img: Invalid option list: ,help + +Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/t.qcow2 +qemu-img: Invalid option list: ,, + +Testing: amend -f qcow2 -o help +Supported options: +size Virtual disk size +compat Compatibility level (0.10 or 1.1) +backing_file File name of a base image +backing_fmt Image format of the base image +encryption Encrypt the image +cluster_size qcow2 cluster size +preallocation Preallocation mode (allowed values: off, metadata) +lazy_refcounts Postpone refcount updates + +Testing: convert -o help +Supported options: +size Virtual disk size +*** done diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common index 8b4e22c856..5795358924 100644 --- a/tests/qemu-iotests/common +++ b/tests/qemu-iotests/common @@ -144,10 +144,12 @@ check options -vpc test vpc -vhdx test vhdx -vmdk test vmdk + -file test file (default) -rbd test rbd -sheepdog test sheepdog -nbd test nbd -ssh test ssh + -nfs test nfs -xdiff graphical mode diff -nocache use O_DIRECT on backing file -misalign misalign memory allocations @@ -211,22 +213,36 @@ testlist options xpand=false ;; + -file) + IMGPROTO=file + xpand=false + ;; + -rbd) IMGPROTO=rbd xpand=false ;; + -sheepdog) IMGPROTO=sheepdog xpand=false ;; + -nbd) IMGPROTO=nbd xpand=false ;; + -ssh) IMGPROTO=ssh xpand=false ;; + + -nfs) + IMGPROTO=nfs + xpand=false + ;; + -nocache) CACHEMODE="none" CACHEMODE_IS_DEFAULT=false @@ -238,10 +254,10 @@ testlist options xpand=false ;; - -valgrind) - valgrind=true + -valgrind) + valgrind=true xpand=false - ;; + ;; -g) # -g group ... pick from group file group=true diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 0f68156400..71e9a7462d 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -61,6 +61,9 @@ elif [ "$IMGPROTO" = "nbd" ]; then elif [ "$IMGPROTO" = "ssh" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE" +elif [ "$IMGPROTO" = "nfs" ]; then + TEST_DIR="nfs://127.0.0.1/$TEST_DIR" + TEST_IMG=$TEST_DIR/t.$IMGFMT else TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT fi diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 03c762fb4f..db127d924d 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -82,3 +82,6 @@ 073 rw auto 074 rw auto 077 rw auto +079 rw auto +081 rw auto +082 rw auto quick diff --git a/tests/qom-test.c b/tests/qom-test.c index 5e5af7a50f..b6671fbec3 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -6,250 +6,94 @@ * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ -#include "libqtest.h" #include <glib.h> #include <string.h> + +#include "libqtest.h" #include "qemu/osdep.h" +#include "qapi/qmp/types.h" + +static const char *blacklist_x86[] = { + "xenfv", "xenpv", NULL +}; + +static const struct { + const char *arch; + const char **machine; +} blacklists[] = { + { "i386", blacklist_x86 }, + { "x86_64", blacklist_x86 }, +}; -static void test_nop(gconstpointer data) +static bool is_blacklisted(const char *arch, const char *mach) +{ + int i; + const char **p; + + for (i = 0; i < ARRAY_SIZE(blacklists); i++) { + if (!strcmp(blacklists[i].arch, arch)) { + for (p = blacklists[i].machine; *p; p++) { + if (!strcmp(*p, mach)) { + return true; + } + } + } + } + return false; +} + +static void test_machine(gconstpointer data) { - QTestState *s; const char *machine = data; char *args; + QDict *response; args = g_strdup_printf("-machine %s", machine); - s = qtest_start(args); - if (s) { - qtest_quit(s); - } + qtest_start(args); + response = qmp("{ 'execute': 'quit' }"); + g_assert(qdict_haskey(response, "return")); + qtest_end(); g_free(args); } -static const char *x86_machines[] = { - "pc", - "isapc", - "q35", -}; - -static const char *alpha_machines[] = { - "clipper", -}; - -static const char *arm_machines[] = { - "integratorcp", - "versatilepb", - "versatileab", - "lm3s811evb", - "lm3s6965evb", - "collie", - "akita", - "spitz", - "borzoi", - "terrier", - "tosa", - "cheetah", - "sx1-v1", - "sx1", - "realview-eb", - "realview-eb-mpcore", - "realview-pb-a8", - "realview-pbx-a9", - "musicpal", - "mainstone", - "connex", - "verdex", - "z2", - "n800", - "n810", - "kzm", - "vexpress-a9", - "vexpress-a15", - "smdkc210", - "nuri", - "xilinx-zynq-a9", - "highbank", - "midway", - "canon-a1100", - "cubieboard", -}; - -static const char *cris_machines[] = { - "axis-dev88", -}; - -static const char *lm32_machines[] = { - "lm32-evr", - "lm32-uclinux", - "milkymist", -}; - -static const char *m68k_machines[] = { - "mcf5208evb", - "an5206", - "dummy", -}; - -static const char *microblaze_machines[] = { - "petalogix-ml605", - "petalogix-s3adsp1800", -}; - -static const char *mips_machines[] = { - "malta", - "magnum", - "mips", - "mipssim", - "pica61", -}; - -static const char *moxie_machines[] = { - "moxiesim", -}; - -static const char *openrisc_machines[] = { - "or32-sim", -}; - -static const char *ppc_machines[] = { - "g3beige", - "mac99", - "prep", - "mpc8544ds", - "ppce500", -}; - -static const char *ppc64_machines[] = { - "pseries", -}; - -static const char *ppc405_machines[] = { - "ref405ep", - "taihu", -}; - -static const char *ppc440_machines[] = { - "bamboo", - "virtex-ml507", -}; - -static const char *s390_machines[] = { - "s390-virtio", - "s390-ccw-virtio", -}; - -static const char *superh_machines[] = { - "r2d", - "shix", -}; - -static const char *sparc_machines[] = { - "SS-4", - "SS-5", - "SS-10", - "SS-20", - "SS-600MP", - "LX", - "SPARCClassic", - "SPARCbook", - "leon3_generic", -}; - -static const char *sparc64_machines[] = { - "sun4u", - "sun4v", - "Niagara", -}; - -static const char *unicore32_machines[] = { - "puv3", -}; - -static const char *xtensa_machines[] = { - "sim", - "lx60", - "lx200", -}; - -static void add_test_cases(const char *arch, const char *machine) +static void add_machine_test_cases(void) { - char *path; - path = g_strdup_printf("/%s/qom/%s", arch, machine); - g_test_add_data_func(path, machine, test_nop); + const char *arch = qtest_get_arch(); + QDict *response, *minfo; + QList *list; + const QListEntry *p; + QObject *qobj; + QString *qstr; + const char *mname, *path; + + qtest_start("-machine none"); + response = qmp("{ 'execute': 'query-machines' }"); + g_assert(response); + list = qdict_get_qlist(response, "return"); + g_assert(list); + + for (p = qlist_first(list); p; p = qlist_next(p)) { + minfo = qobject_to_qdict(qlist_entry_obj(p)); + g_assert(minfo); + qobj = qdict_get(minfo, "name"); + g_assert(qobj); + qstr = qobject_to_qstring(qobj); + g_assert(qstr); + mname = qstring_get_str(qstr); + if (!is_blacklisted(arch, mname)) { + path = g_strdup_printf("/%s/qom/%s", arch, mname); + g_test_add_data_func(path, mname, test_machine); + } + } + qtest_end(); } -#define ADD_MACHINE_TESTS(arch, array) do { \ - int i; \ - for (i = 0; i < ARRAY_SIZE(array); i++) { \ - add_test_cases((arch), (array)[i]); \ - } \ -} while (false) - int main(int argc, char **argv) { - const char *arch = qtest_get_arch(); - g_test_init(&argc, &argv, NULL); - add_test_cases(arch, "none"); - - if (strcmp(arch, "i386") == 0 || - strcmp(arch, "x86_64") == 0) { - ADD_MACHINE_TESTS(arch, x86_machines); - } else if (strcmp(arch, "alpha") == 0) { - ADD_MACHINE_TESTS(arch, alpha_machines); - } else if (strcmp(arch, "arm") == 0) { - ADD_MACHINE_TESTS(arch, arm_machines); - } else if (strcmp(arch, "cris") == 0) { - ADD_MACHINE_TESTS(arch, cris_machines); - } else if (strcmp(arch, "lm32") == 0) { - ADD_MACHINE_TESTS(arch, lm32_machines); - } else if (strcmp(arch, "m68k") == 0) { - ADD_MACHINE_TESTS(arch, m68k_machines); - } else if (strcmp(arch, "microblaze") == 0 || - strcmp(arch, "microblazeel") == 0) { - ADD_MACHINE_TESTS(arch, microblaze_machines); - } else if (strcmp(arch, "mips") == 0 || - strcmp(arch, "mipsel") == 0 || - strcmp(arch, "mips64") == 0) { - ADD_MACHINE_TESTS(arch, mips_machines); - } else if (strcmp(arch, "mips64el") == 0) { - ADD_MACHINE_TESTS(arch, mips_machines); - add_test_cases(arch, "fulong2e"); - } else if (strcmp(arch, "moxie") == 0) { - ADD_MACHINE_TESTS(arch, moxie_machines); - } else if (strcmp(arch, "or32") == 0) { - ADD_MACHINE_TESTS(arch, openrisc_machines); - } else if (strcmp(arch, "ppcemb") == 0) { -#if 0 - /* XXX Available in ppcemb but don't work */ - ADD_MACHINE_TESTS(arch, ppc405_machines); -#endif - ADD_MACHINE_TESTS(arch, ppc440_machines); - } else if (strcmp(arch, "ppc") == 0) { - ADD_MACHINE_TESTS(arch, ppc405_machines); - ADD_MACHINE_TESTS(arch, ppc440_machines); - ADD_MACHINE_TESTS(arch, ppc_machines); - } else if (strcmp(arch, "ppc64") == 0) { - ADD_MACHINE_TESTS(arch, ppc405_machines); - ADD_MACHINE_TESTS(arch, ppc440_machines); - ADD_MACHINE_TESTS(arch, ppc_machines); - ADD_MACHINE_TESTS(arch, ppc64_machines); - } else if (strcmp(arch, "s390x") == 0) { - ADD_MACHINE_TESTS(arch, s390_machines); - } else if (strcmp(arch, "sh4") == 0 || - strcmp(arch, "sh4eb") == 0) { - ADD_MACHINE_TESTS(arch, superh_machines); - } else if (strcmp(arch, "sparc") == 0) { - ADD_MACHINE_TESTS(arch, sparc_machines); - } else if (strcmp(arch, "sparc64") == 0) { - ADD_MACHINE_TESTS(arch, sparc64_machines); - } else if (strcmp(arch, "unicore32") == 0) { - ADD_MACHINE_TESTS(arch, unicore32_machines); - } else if (strcmp(arch, "xtensa") == 0 || - strcmp(arch, "xtensaeb") == 0) { - ADD_MACHINE_TESTS(arch, xtensa_machines); - } + add_machine_test_cases(); return g_test_run(); } diff --git a/tests/rtc-test.c b/tests/rtc-test.c index f1b123fae1..4243624de6 100644 --- a/tests/rtc-test.c +++ b/tests/rtc-test.c @@ -10,8 +10,6 @@ * See the COPYING file in the top-level directory. * */ -#include "libqtest.h" -#include "hw/timer/mc146818rtc_regs.h" #include <glib.h> #include <stdio.h> @@ -19,6 +17,9 @@ #include <stdlib.h> #include <unistd.h> +#include "libqtest.h" +#include "hw/timer/mc146818rtc_regs.h" + static uint8_t base = 0x70; static int bcd2dec(int value) diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c new file mode 100644 index 0000000000..f6a1be3fac --- /dev/null +++ b/tests/rtl8139-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for Realtek 8139 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/rtl8139/nop", nop); + + qtest_start("-device rtl8139"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/tcg/lm32/Makefile b/tests/tcg/lm32/Makefile index 9a00ef7ea9..8e5d405459 100644 --- a/tests/tcg/lm32/Makefile +++ b/tests/tcg/lm32/Makefile @@ -96,10 +96,10 @@ all: build build: $(CRT) $(TESTCASES) -check: $(CRT) $(SYS) $(TESTCASES) - @for case in $(TESTCASES); do \ - $(SIM) $(SIMFLAGS) ./$$case; \ - done +check: $(TESTCASES:test_%.tst=check_%) + +check_%: test_%.tst $(CRT) $(SYS) + $(SIM) $(SIMFLAGS) $< clean: $(RM) -fr $(TESTCASES) $(CRT) diff --git a/tests/tcg/xtensa/Makefile b/tests/tcg/xtensa/Makefile index 1b519cae45..a70c92be7e 100644 --- a/tests/tcg/xtensa/Makefile +++ b/tests/tcg/xtensa/Makefile @@ -1,10 +1,11 @@ -include ../../../config-host.mak -CROSS=xtensa-dc232b-elf- +CORE=dc232b +CROSS=xtensa-$(CORE)-elf- ifndef XT SIM = ../../../xtensa-softmmu/qemu-system-xtensa -SIMFLAGS = -M sim -cpu dc232b -nographic -semihosting $(EXTFLAGS) -kernel +SIMFLAGS = -M sim -cpu $(CORE) -nographic -semihosting $(EXTFLAGS) -kernel SIMDEBUG = -s -S else SIM = xt-run @@ -17,6 +18,8 @@ AS = $(CROSS)gcc -x assembler-with-cpp LD = $(CROSS)ld XTENSA_SRC_PATH = $(SRC_PATH)/tests/tcg/xtensa +INCLUDE_DIRS = $(XTENSA_SRC_PATH) $(SRC_PATH)/target-xtensa/core-$(CORE) +XTENSA_INC = $(addprefix -I,$(INCLUDE_DIRS)) LDFLAGS = -T$(XTENSA_SRC_PATH)/linker.ld @@ -27,6 +30,7 @@ TESTCASES += test_bi.tst #TESTCASES += test_boolean.tst TESTCASES += test_break.tst TESTCASES += test_bz.tst +TESTCASES += test_cache.tst TESTCASES += test_clamps.tst TESTCASES += test_extui.tst TESTCASES += test_fail.tst @@ -56,10 +60,10 @@ TESTCASES += test_windowed.tst all: build %.o: $(XTENSA_SRC_PATH)/%.c - $(CC) -I$(XTENSA_SRC_PATH) $(CFLAGS) -c $< -o $@ + $(CC) $(XTENSA_INC) $(CFLAGS) -c $< -o $@ %.o: $(XTENSA_SRC_PATH)/%.S - $(AS) -Wa,-I,$(XTENSA_SRC_PATH) $(ASFLAGS) -c $< -o $@ + $(CC) $(XTENSA_INC) $(ASFLAGS) -c $< -o $@ %.tst: %.o $(XTENSA_SRC_PATH)/macros.inc $(CRT) Makefile $(LD) $(LDFLAGS) $(NOSTDFLAGS) $(CRT) $< -o $@ diff --git a/tests/tcg/xtensa/macros.inc b/tests/tcg/xtensa/macros.inc index c9be1ce516..4ebd30ab86 100644 --- a/tests/tcg/xtensa/macros.inc +++ b/tests/tcg/xtensa/macros.inc @@ -1,3 +1,5 @@ +#include "core-isa.h" + .macro test_suite name .data status: .word result @@ -43,8 +45,12 @@ main: simcall .endm +.macro test_init +.endm + .macro test name //print test_\name + test_init test_\name: .global test_\name .endm diff --git a/tests/tcg/xtensa/test_b.S b/tests/tcg/xtensa/test_b.S index 6cbe5f1fca..8e81f956df 100644 --- a/tests/tcg/xtensa/test_b.S +++ b/tests/tcg/xtensa/test_b.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite b diff --git a/tests/tcg/xtensa/test_bi.S b/tests/tcg/xtensa/test_bi.S index 6a5f1dffc9..4f94c0c7e6 100644 --- a/tests/tcg/xtensa/test_bi.S +++ b/tests/tcg/xtensa/test_bi.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite bi diff --git a/tests/tcg/xtensa/test_boolean.S b/tests/tcg/xtensa/test_boolean.S index 50e6d2c22a..eac40e0973 100644 --- a/tests/tcg/xtensa/test_boolean.S +++ b/tests/tcg/xtensa/test_boolean.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite boolean diff --git a/tests/tcg/xtensa/test_break.S b/tests/tcg/xtensa/test_break.S index 7574cbefc8..775cd7c260 100644 --- a/tests/tcg/xtensa/test_break.S +++ b/tests/tcg/xtensa/test_break.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" #define debug_level 6 #define debug_vector level6 diff --git a/tests/tcg/xtensa/test_bz.S b/tests/tcg/xtensa/test_bz.S index f9ba6e22e8..b68135011e 100644 --- a/tests/tcg/xtensa/test_bz.S +++ b/tests/tcg/xtensa/test_bz.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite bz diff --git a/tests/tcg/xtensa/test_cache.S b/tests/tcg/xtensa/test_cache.S new file mode 100644 index 0000000000..6b2df9734b --- /dev/null +++ b/tests/tcg/xtensa/test_cache.S @@ -0,0 +1,97 @@ +#include "macros.inc" + +.purgem test_init +.macro test_init + call0 cache_unlock_invalidate +.endm + +test_suite cache + +.macro pf_op op + \op a2, 0 + \op a3, 0 + \op a4, 0 +.endm + +test prefetch + movi a2, 0xd0000000 /* cacheable */ + movi a3, 0xd8000000 /* non-cacheable */ + movi a4, 0x00001235 /* unmapped */ + + pf_op dpfr + pf_op dpfro + pf_op dpfw + pf_op dpfwo + pf_op ipf + + dpfl a2, 0 + ipfl a2, 0 +test_end + +.macro cache_fault op, addr, exc_code + set_vector kernel, 2f + + movi a4, \addr +1: + \op a4, 0 + test_fail +2: + rsr a2, epc1 + movi a3, 1b + assert eq, a2, a3 + rsr a2, excvaddr + assert eq, a2, a4 + rsr a2, exccause + movi a3, \exc_code + assert eq, a2, a3 +.endm + +test dpfl_tlb_miss + cache_fault dpfl, 0x00002345, 24 +test_end + +test dhwb_tlb_miss + cache_fault dhwb, 0x00002345, 24 +test_end + +test dhwbi_tlb_miss + cache_fault dhwbi, 0x00002345, 24 +test_end + +test dhi_tlb_miss + cache_fault dhi, 0x00002345, 24 +test_end + +test dhu_tlb_miss + cache_fault dhu, 0x00002345, 24 +test_end + + +test ipfl_tlb_miss + cache_fault ipfl, 0x00002345, 16 +test_end + +test ihu_tlb_miss + cache_fault ihu, 0x00002345, 16 +test_end + +test ihi_tlb_miss + cache_fault ihi, 0x00002345, 16 +test_end + +test_suite_end + +.macro cache_all op1, op2, size, linesize + movi a2, 0 + movi a3, \size +1: + \op1 a2, 0 + \op2 a2, 0 + addi a2, a2, \linesize + bltu a2, a3, 1b +.endm + +cache_unlock_invalidate: + cache_all diu, dii, XCHAL_DCACHE_SIZE, XCHAL_DCACHE_LINESIZE + cache_all iiu, iii, XCHAL_ICACHE_SIZE, XCHAL_ICACHE_LINESIZE + ret diff --git a/tests/tcg/xtensa/test_clamps.S b/tests/tcg/xtensa/test_clamps.S index c186cc98d8..3efabfd9d3 100644 --- a/tests/tcg/xtensa/test_clamps.S +++ b/tests/tcg/xtensa/test_clamps.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite clamps diff --git a/tests/tcg/xtensa/test_extui.S b/tests/tcg/xtensa/test_extui.S index 5d55451704..c32bb824df 100644 --- a/tests/tcg/xtensa/test_extui.S +++ b/tests/tcg/xtensa/test_extui.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite extui diff --git a/tests/tcg/xtensa/test_fail.S b/tests/tcg/xtensa/test_fail.S index e8d1b425bc..1c26d50790 100644 --- a/tests/tcg/xtensa/test_fail.S +++ b/tests/tcg/xtensa/test_fail.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite fail diff --git a/tests/tcg/xtensa/test_interrupt.S b/tests/tcg/xtensa/test_interrupt.S index 68b3ee1492..334ddab287 100644 --- a/tests/tcg/xtensa/test_interrupt.S +++ b/tests/tcg/xtensa/test_interrupt.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite interrupt diff --git a/tests/tcg/xtensa/test_loop.S b/tests/tcg/xtensa/test_loop.S index 1c240e8e9b..5755578d01 100644 --- a/tests/tcg/xtensa/test_loop.S +++ b/tests/tcg/xtensa/test_loop.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite loop diff --git a/tests/tcg/xtensa/test_mac16.S b/tests/tcg/xtensa/test_mac16.S index 5ddd160ffc..512025d842 100644 --- a/tests/tcg/xtensa/test_mac16.S +++ b/tests/tcg/xtensa/test_mac16.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite mac16 diff --git a/tests/tcg/xtensa/test_max.S b/tests/tcg/xtensa/test_max.S index 2534c9d90b..3caa207ea5 100644 --- a/tests/tcg/xtensa/test_max.S +++ b/tests/tcg/xtensa/test_max.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite max diff --git a/tests/tcg/xtensa/test_min.S b/tests/tcg/xtensa/test_min.S index 6d9ddeb1ac..551cf591e5 100644 --- a/tests/tcg/xtensa/test_min.S +++ b/tests/tcg/xtensa/test_min.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite min diff --git a/tests/tcg/xtensa/test_mmu.S b/tests/tcg/xtensa/test_mmu.S index 5d87fbb703..099031fd14 100644 --- a/tests/tcg/xtensa/test_mmu.S +++ b/tests/tcg/xtensa/test_mmu.S @@ -1,10 +1,10 @@ -.include "macros.inc" +#include "macros.inc" test_suite mmu -.purgem test +.purgem test_init -.macro test name +.macro test_init movi a2, 0x00000004 idtlb a2 movi a2, 0x00100004 diff --git a/tests/tcg/xtensa/test_mul16.S b/tests/tcg/xtensa/test_mul16.S index bf94376649..98fa7042b5 100644 --- a/tests/tcg/xtensa/test_mul16.S +++ b/tests/tcg/xtensa/test_mul16.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite mul16 diff --git a/tests/tcg/xtensa/test_mul32.S b/tests/tcg/xtensa/test_mul32.S index fdaf57331b..b288ead9f6 100644 --- a/tests/tcg/xtensa/test_mul32.S +++ b/tests/tcg/xtensa/test_mul32.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite mul32 diff --git a/tests/tcg/xtensa/test_nsa.S b/tests/tcg/xtensa/test_nsa.S index a5fe5debe4..479b2e2429 100644 --- a/tests/tcg/xtensa/test_nsa.S +++ b/tests/tcg/xtensa/test_nsa.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite nsa diff --git a/tests/tcg/xtensa/test_pipeline.S b/tests/tcg/xtensa/test_pipeline.S index 6be6085fc3..f418c11974 100644 --- a/tests/tcg/xtensa/test_pipeline.S +++ b/tests/tcg/xtensa/test_pipeline.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" .purgem test .macro test name diff --git a/tests/tcg/xtensa/test_quo.S b/tests/tcg/xtensa/test_quo.S index 12debf1fe0..5b3ae383d0 100644 --- a/tests/tcg/xtensa/test_quo.S +++ b/tests/tcg/xtensa/test_quo.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite quo diff --git a/tests/tcg/xtensa/test_rem.S b/tests/tcg/xtensa/test_rem.S index bb0d5fe202..6357e520d9 100644 --- a/tests/tcg/xtensa/test_rem.S +++ b/tests/tcg/xtensa/test_rem.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite rem diff --git a/tests/tcg/xtensa/test_rst0.S b/tests/tcg/xtensa/test_rst0.S index 3eda565e8a..a73366b120 100644 --- a/tests/tcg/xtensa/test_rst0.S +++ b/tests/tcg/xtensa/test_rst0.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite rst0 diff --git a/tests/tcg/xtensa/test_s32c1i.S b/tests/tcg/xtensa/test_s32c1i.S index 4536015a84..93b575db95 100644 --- a/tests/tcg/xtensa/test_s32c1i.S +++ b/tests/tcg/xtensa/test_s32c1i.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite s32c1i diff --git a/tests/tcg/xtensa/test_sar.S b/tests/tcg/xtensa/test_sar.S index 40c649ffb8..b615a55767 100644 --- a/tests/tcg/xtensa/test_sar.S +++ b/tests/tcg/xtensa/test_sar.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite sar diff --git a/tests/tcg/xtensa/test_sext.S b/tests/tcg/xtensa/test_sext.S index 04dc6500c1..087a6333a4 100644 --- a/tests/tcg/xtensa/test_sext.S +++ b/tests/tcg/xtensa/test_sext.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite sext diff --git a/tests/tcg/xtensa/test_shift.S b/tests/tcg/xtensa/test_shift.S index a8e43645b7..5df9ed4b1e 100644 --- a/tests/tcg/xtensa/test_shift.S +++ b/tests/tcg/xtensa/test_shift.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite shift diff --git a/tests/tcg/xtensa/test_sr.S b/tests/tcg/xtensa/test_sr.S index 470c03dae2..4fac46e80f 100644 --- a/tests/tcg/xtensa/test_sr.S +++ b/tests/tcg/xtensa/test_sr.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite sr diff --git a/tests/tcg/xtensa/test_timer.S b/tests/tcg/xtensa/test_timer.S index 1041cc6658..f8c6f7423a 100644 --- a/tests/tcg/xtensa/test_timer.S +++ b/tests/tcg/xtensa/test_timer.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite timer diff --git a/tests/tcg/xtensa/test_windowed.S b/tests/tcg/xtensa/test_windowed.S index cb2d39e1fd..3de6d3763a 100644 --- a/tests/tcg/xtensa/test_windowed.S +++ b/tests/tcg/xtensa/test_windowed.S @@ -1,4 +1,4 @@ -.include "macros.inc" +#include "macros.inc" test_suite windowed diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c index 6f68963a3d..38bdf5ec7c 100644 --- a/tests/test-qmp-input-strict.c +++ b/tests/test-qmp-input-strict.c @@ -92,7 +92,7 @@ static void test_validate_struct(TestInputVisitorData *data, v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); visit_type_TestStruct(v, &p, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_free(p->string); g_free(p); } @@ -107,7 +107,7 @@ static void test_validate_struct_nested(TestInputVisitorData *data, v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string' }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); qapi_free_UserDefNested(udp); } @@ -121,7 +121,7 @@ static void test_validate_list(TestInputVisitorData *data, v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]"); visit_type_UserDefOneList(v, &head, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); qapi_free_UserDefOneList(head); } @@ -135,7 +135,7 @@ static void test_validate_union(TestInputVisitorData *data, v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }"); visit_type_UserDefUnion(v, &tmp, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); qapi_free_UserDefUnion(tmp); } @@ -149,7 +149,7 @@ static void test_validate_fail_struct(TestInputVisitorData *data, v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }"); visit_type_TestStruct(v, &p, NULL, &errp); - g_assert(error_is_set(&errp)); + g_assert(errp); if (p) { g_free(p->string); } @@ -166,7 +166,7 @@ static void test_validate_fail_struct_nested(TestInputVisitorData *data, v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &errp); - g_assert(error_is_set(&errp)); + g_assert(errp); qapi_free_UserDefNested(udp); } @@ -180,7 +180,7 @@ static void test_validate_fail_list(TestInputVisitorData *data, v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]"); visit_type_UserDefOneList(v, &head, NULL, &errp); - g_assert(error_is_set(&errp)); + g_assert(errp); qapi_free_UserDefOneList(head); } @@ -194,7 +194,7 @@ static void test_validate_fail_union(TestInputVisitorData *data, v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 }, 'extra': 'yyy' }"); visit_type_UserDefUnion(v, &tmp, NULL, &errp); - g_assert(error_is_set(&errp)); + g_assert(errp); qapi_free_UserDefUnion(tmp); } diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index 1e1c6fa0c2..6eb7dc5bcf 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -96,7 +96,7 @@ static void test_visitor_in_int(TestInputVisitorData *data, v = visitor_input_test_init(data, "%" PRId64, value); visit_type_int(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, value); } @@ -114,7 +114,7 @@ static void test_visitor_in_int_overflow(TestInputVisitorData *data, v = visitor_input_test_init(data, "%f", DBL_MAX); visit_type_int(v, &res, NULL, &errp); - g_assert(error_is_set(&errp)); + g_assert(errp); error_free(errp); } @@ -128,7 +128,7 @@ static void test_visitor_in_bool(TestInputVisitorData *data, v = visitor_input_test_init(data, "true"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, true); } @@ -142,7 +142,7 @@ static void test_visitor_in_number(TestInputVisitorData *data, v = visitor_input_test_init(data, "%f", value); visit_type_number(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpfloat(res, ==, value); } @@ -156,7 +156,7 @@ static void test_visitor_in_string(TestInputVisitorData *data, v = visitor_input_test_init(data, "%s", value); visit_type_str(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpstr(res, ==, value); g_free(res); @@ -175,7 +175,7 @@ static void test_visitor_in_enum(TestInputVisitorData *data, v = visitor_input_test_init(data, "%s", EnumOne_lookup[i]); visit_type_EnumOne(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(i, ==, res); visitor_input_teardown(data, NULL); @@ -223,7 +223,7 @@ static void test_visitor_in_struct(TestInputVisitorData *data, v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); visit_type_TestStruct(v, &p, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(p->integer, ==, -42); g_assert(p->boolean == true); g_assert_cmpstr(p->string, ==, "foo"); @@ -248,7 +248,7 @@ static void test_visitor_in_struct_nested(TestInputVisitorData *data, v = visitor_input_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string' }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); check_and_free_str(udp->string0, "string0"); check_and_free_str(udp->dict1.string1, "string1"); @@ -272,7 +272,7 @@ static void test_visitor_in_list(TestInputVisitorData *data, v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]"); visit_type_UserDefOneList(v, &head, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert(head != NULL); for (i = 0, item = head; item; item = item->next, i++) { @@ -601,7 +601,7 @@ static void test_visitor_in_errors(TestInputVisitorData *data, v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', 'string': -42 }"); visit_type_TestStruct(v, &p, NULL, &errp); - g_assert(error_is_set(&errp)); + g_assert(errp); g_assert(p->string == NULL); error_free(errp); diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index e073d833bf..f31d168d63 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -49,7 +49,7 @@ static void test_visitor_out_int(TestOutputVisitorData *data, QObject *obj; visit_type_int(data->ov, &value, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -67,7 +67,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data, QObject *obj; visit_type_bool(data->ov, &value, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -85,7 +85,7 @@ static void test_visitor_out_number(TestOutputVisitorData *data, QObject *obj; visit_type_number(data->ov, &value, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -103,7 +103,7 @@ static void test_visitor_out_string(TestOutputVisitorData *data, QObject *obj; visit_type_str(data->ov, &string, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -122,7 +122,7 @@ static void test_visitor_out_no_string(TestOutputVisitorData *data, /* A null string should return "" */ visit_type_str(data->ov, &string, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -141,7 +141,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, for (i = 0; i < ENUM_ONE_MAX; i++) { visit_type_EnumOne(data->ov, &i, "unused", &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -161,7 +161,7 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data, for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { errp = NULL; visit_type_EnumOne(data->ov, &bad_values[i], "unused", &errp); - g_assert(error_is_set(&errp) == true); + g_assert(errp); error_free(errp); } } @@ -198,7 +198,7 @@ static void test_visitor_out_struct(TestOutputVisitorData *data, QDict *qdict; visit_type_TestStruct(data->ov, &p, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -241,7 +241,7 @@ static void test_visitor_out_struct_nested(TestOutputVisitorData *data, ud2->dict1.dict3.string3 = g_strdup(strings[3]); visit_type_UserDefNested(data->ov, &ud2, "unused", &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); @@ -288,7 +288,7 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data, u.has_enum1 = true; u.enum1 = bad_values[i]; visit_type_UserDefOne(data->ov, &pu, "unused", &errp); - g_assert(error_is_set(&errp) == true); + g_assert(errp); error_free(errp); } } @@ -343,7 +343,7 @@ static void test_visitor_out_list(TestOutputVisitorData *data, } visit_type_TestStructList(data->ov, &head, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c index 5989f8118e..d406263aee 100644 --- a/tests/test-string-input-visitor.c +++ b/tests/test-string-input-visitor.c @@ -60,7 +60,7 @@ static void test_visitor_in_int(TestInputVisitorData *data, v = visitor_input_test_init(data, "-42"); visit_type_int(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, value); } @@ -74,42 +74,42 @@ static void test_visitor_in_bool(TestInputVisitorData *data, v = visitor_input_test_init(data, "true"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, true); visitor_input_teardown(data, unused); v = visitor_input_test_init(data, "yes"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, true); visitor_input_teardown(data, unused); v = visitor_input_test_init(data, "on"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, true); visitor_input_teardown(data, unused); v = visitor_input_test_init(data, "false"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, false); visitor_input_teardown(data, unused); v = visitor_input_test_init(data, "no"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, false); visitor_input_teardown(data, unused); v = visitor_input_test_init(data, "off"); visit_type_bool(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(res, ==, false); } @@ -123,7 +123,7 @@ static void test_visitor_in_number(TestInputVisitorData *data, v = visitor_input_test_init(data, "3.14"); visit_type_number(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpfloat(res, ==, value); } @@ -137,7 +137,7 @@ static void test_visitor_in_string(TestInputVisitorData *data, v = visitor_input_test_init(data, value); visit_type_str(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpstr(res, ==, value); g_free(res); @@ -156,7 +156,7 @@ static void test_visitor_in_enum(TestInputVisitorData *data, v = visitor_input_test_init(data, EnumOne_lookup[i]); visit_type_EnumOne(v, &res, NULL, &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); g_assert_cmpint(i, ==, res); visitor_input_teardown(data, NULL); diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c index 79d815f888..22363d100f 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -26,7 +26,7 @@ typedef struct TestOutputVisitorData { static void visitor_output_setup(TestOutputVisitorData *data, const void *unused) { - data->sov = string_output_visitor_new(); + data->sov = string_output_visitor_new(false); g_assert(data->sov != NULL); data->ov = string_output_get_visitor(data->sov); @@ -49,7 +49,7 @@ static void test_visitor_out_int(TestOutputVisitorData *data, char *str; visit_type_int(data->ov, &value, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); str = string_output_get_string(data->sov); g_assert(str != NULL); @@ -65,7 +65,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data, char *str; visit_type_bool(data->ov, &value, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); str = string_output_get_string(data->sov); g_assert(str != NULL); @@ -81,7 +81,7 @@ static void test_visitor_out_number(TestOutputVisitorData *data, char *str; visit_type_number(data->ov, &value, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); str = string_output_get_string(data->sov); g_assert(str != NULL); @@ -97,7 +97,7 @@ static void test_visitor_out_string(TestOutputVisitorData *data, char *str; visit_type_str(data->ov, &string, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); str = string_output_get_string(data->sov); g_assert(str != NULL); @@ -114,7 +114,7 @@ static void test_visitor_out_no_string(TestOutputVisitorData *data, /* A null string should return "" */ visit_type_str(data->ov, &string, NULL, &errp); - g_assert(error_is_set(&errp) == 0); + g_assert(!errp); str = string_output_get_string(data->sov); g_assert(str != NULL); @@ -131,7 +131,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, for (i = 0; i < ENUM_ONE_MAX; i++) { visit_type_EnumOne(data->ov, &i, "unused", &errp); - g_assert(!error_is_set(&errp)); + g_assert(!errp); str = string_output_get_string(data->sov); g_assert(str != NULL); @@ -149,7 +149,7 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data, for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { errp = NULL; visit_type_EnumOne(data->ov, &bad_values[i], "unused", &errp); - g_assert(error_is_set(&errp) == true); + g_assert(errp); error_free(errp); } } diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index 9aaa5872e5..6bff950eb6 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -1083,7 +1083,7 @@ static void string_serialize(void *native_in, void **datap, { StringSerializeData *d = g_malloc0(sizeof(*d)); - d->sov = string_output_visitor_new(); + d->sov = string_output_visitor_new(false); visit(string_output_get_visitor(d->sov), &native_in, errp); *datap = d; } diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index 5ac48e2f5c..0834219e35 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -6,12 +6,13 @@ * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ + +#include <glib.h> + #include "libqtest.h" #include "libqos/i2c.h" #include "hw/misc/tmp105_regs.h" -#include <glib.h> - #define OMAP2_I2C_1_BASE 0x48070000 #define N8X0_ADDR 0x48 diff --git a/tests/tpci200-test.c b/tests/tpci200-test.c new file mode 100644 index 0000000000..9ae01277ee --- /dev/null +++ b/tests/tpci200-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for tpci200 PCI-IndustryPack bridge + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/tpci200/nop", nop); + + qtest_start("-device tpci200"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c new file mode 100644 index 0000000000..df99343238 --- /dev/null +++ b/tests/virtio-net-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for VirtIO NIC + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/net/pci/nop", pci_nop); + + qtest_start("-device virtio-net-pci"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} diff --git a/tests/vmxnet3-test.c b/tests/vmxnet3-test.c new file mode 100644 index 0000000000..a2ebed39cc --- /dev/null +++ b/tests/vmxnet3-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for vmxnet3 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/vmxnet3/nop", nop); + + qtest_start("-device vmxnet3"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} |