summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-06-05 21:52:37 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-06-05 21:52:37 +0100
commit26edf8cc08e2ec15d9e65bb0dd4fbac22edd730b (patch)
treea010815e0435a73d2a6347b5b75ee3f6ece1c788 /tests
parent31e25e3e5701607a2a88b5b6c5fb1057b20941fd (diff)
parent711e2f1e9ecad845e142fdddbbf1e8037bce902b (diff)
downloadqemu-26edf8cc08e2ec15d9e65bb0dd4fbac22edd730b.tar.gz
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc,pci,virtio,qdev fixes, tests new tests for SMBIOS SMBIOS fixes pc, pci fixes qdev patches stayed on list for a month with no review, as I told people on KVM forum I'm merging stuch patches if they look fine. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * remotes/mst/tags/for_upstream: qdev: Add test of qdev_prop_check_global qdev: Display warning about unused -global tests: add smbios testing tests: rename acpi-test to bios-tables-test virtio-balloon: return empty data when no stats are available pcie_host: Turn pcie_host_init() into an instance_init SMBIOS: Fix type 17 field sizes SMBIOS: Update Type 0 struct generator for machines >= 2.1 SMBIOS: Fix endian-ness when populating multi-byte fields serial-pci: Set prog interface field of pci config to 16550 compatible Conflicts: include/hw/i386/pc.h [PMM: fixed trivial conflict in pc.h] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile4
-rw-r--r--tests/bios-tables-test.c (renamed from tests/acpi-test.c)126
-rw-r--r--tests/test-qdev-global-props.c4
3 files changed, 132 insertions, 2 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 6b294a7dbc..361bb7b6e3 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -133,7 +133,7 @@ check-qtest-i386-y += tests/ide-test$(EXESUF)
check-qtest-i386-y += tests/hd-geo-test$(EXESUF)
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/bios-tables-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)
@@ -290,7 +290,7 @@ tests/fdc-test$(EXESUF): tests/fdc-test.o
tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
-tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y)
+tests/bios-tables-test$(EXESUF): tests/bios-tables-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)
diff --git a/tests/acpi-test.c b/tests/bios-tables-test.c
index 76fbccfa4b..62771f7608 100644
--- a/tests/acpi-test.c
+++ b/tests/bios-tables-test.c
@@ -18,6 +18,8 @@
#include "libqtest.h"
#include "qemu/compiler.h"
#include "hw/i386/acpi-defs.h"
+#include "hw/i386/smbios.h"
+#include "qemu/bitmap.h"
#define MACHINE_PC "pc"
#define MACHINE_Q35 "q35"
@@ -46,6 +48,8 @@ typedef struct {
uint32_t *rsdt_tables_addr;
int rsdt_tables_nr;
GArray *tables;
+ uint32_t smbios_ep_addr;
+ struct smbios_entry_point smbios_ep_table;
} test_data;
#define LOW(x) ((x) & 0xff)
@@ -581,6 +585,124 @@ static void test_acpi_asl(test_data *data)
free_test_data(&exp_data);
}
+static void test_smbios_ep_address(test_data *data)
+{
+ uint32_t off;
+
+ /* find smbios entry point structure */
+ for (off = 0xf0000; off < 0x100000; off += 0x10) {
+ uint8_t sig[] = "_SM_";
+ int i;
+
+ for (i = 0; i < sizeof sig - 1; ++i) {
+ sig[i] = readb(off + i);
+ }
+
+ if (!memcmp(sig, "_SM_", sizeof sig)) {
+ break;
+ }
+ }
+
+ g_assert_cmphex(off, <, 0x100000);
+ data->smbios_ep_addr = off;
+}
+
+static void test_smbios_ep_table(test_data *data)
+{
+ struct smbios_entry_point *ep_table = &data->smbios_ep_table;
+ uint32_t addr = data->smbios_ep_addr;
+
+ ACPI_READ_ARRAY(ep_table->anchor_string, addr);
+ g_assert(!memcmp(ep_table->anchor_string, "_SM_", 4));
+ ACPI_READ_FIELD(ep_table->checksum, addr);
+ ACPI_READ_FIELD(ep_table->length, addr);
+ ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
+ ACPI_READ_FIELD(ep_table->smbios_minor_version, addr);
+ ACPI_READ_FIELD(ep_table->max_structure_size, addr);
+ ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
+ ACPI_READ_ARRAY(ep_table->formatted_area, addr);
+ ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
+ g_assert(!memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5));
+ ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
+ ACPI_READ_FIELD(ep_table->structure_table_length, addr);
+ g_assert_cmpuint(ep_table->structure_table_length, >, 0);
+ ACPI_READ_FIELD(ep_table->structure_table_address, addr);
+ ACPI_READ_FIELD(ep_table->number_of_structures, addr);
+ g_assert_cmpuint(ep_table->number_of_structures, >, 0);
+ ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
+ g_assert(!acpi_checksum((uint8_t *)ep_table, sizeof *ep_table));
+ g_assert(!acpi_checksum((uint8_t *)ep_table + 0x10,
+ sizeof *ep_table - 0x10));
+}
+
+static inline bool smbios_single_instance(uint8_t type)
+{
+ switch (type) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 16:
+ case 32:
+ case 127:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static void test_smbios_structs(test_data *data)
+{
+ DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
+ struct smbios_entry_point *ep_table = &data->smbios_ep_table;
+ uint32_t addr = ep_table->structure_table_address;
+ int i, len, max_len = 0;
+ uint8_t type, prv, crt;
+ uint8_t required_struct_types[] = {0, 1, 3, 4, 16, 17, 19, 32, 127};
+
+ /* walk the smbios tables */
+ for (i = 0; i < ep_table->number_of_structures; i++) {
+
+ /* grab type and formatted area length from struct header */
+ type = readb(addr);
+ g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
+ len = readb(addr + 1);
+
+ /* single-instance structs must not have been encountered before */
+ if (smbios_single_instance(type)) {
+ g_assert(!test_bit(type, struct_bitmap));
+ }
+ set_bit(type, struct_bitmap);
+
+ /* seek to end of unformatted string area of this struct ("\0\0") */
+ prv = crt = 1;
+ while (prv || crt) {
+ prv = crt;
+ crt = readb(addr + len);
+ len++;
+ }
+
+ /* keep track of max. struct size */
+ if (max_len < len) {
+ max_len = len;
+ g_assert_cmpuint(max_len, <=, ep_table->max_structure_size);
+ }
+
+ /* start of next structure */
+ addr += len;
+ }
+
+ /* total table length and max struct size must match entry point values */
+ g_assert_cmpuint(ep_table->structure_table_length, ==,
+ addr - ep_table->structure_table_address);
+ g_assert_cmpuint(ep_table->max_structure_size, ==, max_len);
+
+ /* required struct types must all be present */
+ for (i = 0; i < ARRAY_SIZE(required_struct_types); i++) {
+ g_assert(test_bit(required_struct_types[i], struct_bitmap));
+ }
+}
+
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
@@ -633,6 +755,10 @@ static void test_acpi_one(const char *params, test_data *data)
}
}
+ test_smbios_ep_address(data);
+ test_smbios_ep_table(data);
+ test_smbios_structs(data);
+
qtest_quit(global_qtest);
g_free(args);
}
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index e4ad173d72..2bef04c76f 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -150,8 +150,10 @@ static void test_dynamic_globalprop(void)
static GlobalProperty props[] = {
{ TYPE_DYNAMIC_PROPS, "prop1", "101" },
{ TYPE_DYNAMIC_PROPS, "prop2", "102" },
+ { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true },
{}
};
+ int all_used;
qdev_prop_register_global_list(props);
@@ -160,6 +162,8 @@ static void test_dynamic_globalprop(void)
g_assert_cmpuint(mt->prop1, ==, 101);
g_assert_cmpuint(mt->prop2, ==, 102);
+ all_used = qdev_prop_check_global();
+ g_assert_cmpuint(all_used, ==, 1);
}
int main(int argc, char **argv)