summaryrefslogtreecommitdiff
path: root/tests/bios-tables-test.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-02-19 10:50:37 +0000
committerPeter Maydell <peter.maydell@linaro.org>2016-02-19 10:50:37 +0000
commit09125c5e76923aa22a72f43cb34b6e74ae7fe17f (patch)
treef396e1b2e8c350741b88632c1700658c422bda15 /tests/bios-tables-test.c
parentdd5e38b19d7cb07d317e1285941d8245c01da540 (diff)
parenta28c393cc261afeb4863b05d7c33c2a5fc55ef38 (diff)
downloadqemu-09125c5e76923aa22a72f43cb34b6e74ae7fe17f.tar.gz
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
vhost, virtio, pci, pxe Fixes all over the place. New tests for pxe. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Thu 18 Feb 2016 15:46:39 GMT using RSA key ID D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" * remotes/mst/tags/for_upstream: tests/vhost-user-bridge: add scattering of incoming packets vhost-user interrupt management fixes rules: filter out irrelevant files change type of pci_bridge_initfn() to void dec: convert to realize() tests: add pxe e1000 and virtio-pci tests msix: fix msix_vector_masked virtio: optimize virtio_access_is_big_endian() for little-endian targets vhost: simplify vhost_needs_vring_endian() vhost: move virtio 1.0 check to cross-endian helper virtio: move cross-endian helper to vhost vhost-net: revert support of cross-endian vnet headers virtio-net: use the backend cross-endian capabilities Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/bios-tables-test.c')
-rw-r--r--tests/bios-tables-test.c72
1 files changed, 6 insertions, 66 deletions
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 7155fecdbf..0a80ddf04b 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -18,6 +18,7 @@
#include "hw/acpi/acpi-defs.h"
#include "hw/smbios/smbios.h"
#include "qemu/bitmap.h"
+#include "boot-sector.h"
#define MACHINE_PC "pc"
#define MACHINE_Q35 "q35"
@@ -51,13 +52,6 @@ typedef struct {
struct smbios_21_entry_point smbios_ep_table;
} test_data;
-#define LOW(x) ((x) & 0xff)
-#define HIGH(x) ((x) >> 8)
-
-#define SIGNATURE 0xdead
-#define SIGNATURE_OFFSET 0x10
-#define BOOT_SECTOR_ADDRESS 0x7c00
-
#define ACPI_READ_FIELD(field, addr) \
do { \
switch (sizeof(field)) { \
@@ -117,35 +111,6 @@ typedef struct {
g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
} while (0)
-/* 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[0x7e000] = {
- /* 7c00: mov $0xdead,%ax */
- [0x00] = 0xb8,
- [0x01] = LOW(SIGNATURE),
- [0x02] = HIGH(SIGNATURE),
- /* 7c03: mov %ax,0x7c10 */
- [0x03] = 0xa3,
- [0x04] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
- [0x05] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
- /* 7c06: cli */
- [0x06] = 0xfa,
- /* 7c07: hlt */
- [0x07] = 0xf4,
- /* 7c08: jmp 0x7c07=0x7c0a-3 */
- [0x08] = 0xeb,
- [0x09] = LOW(-3),
- /* We mov 0xdead here: set value to make debugging easier */
- [SIGNATURE_OFFSET] = LOW(0xface),
- [SIGNATURE_OFFSET + 1] = HIGH(0xface),
- /* End of boot sector marker */
- [0x1FE] = 0x55,
- [0x1FF] = 0xAA,
-};
-
static const char *disk = "tests/acpi-test-disk.raw";
static const char *data_dir = "tests/acpi-test-data";
#ifdef CONFIG_IASL
@@ -737,10 +702,6 @@ static void test_smbios_structs(test_data *data)
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
- uint8_t signature_low;
- uint8_t signature_high;
- uint16_t signature;
- int i;
args = g_strdup_printf("-net none -display none %s "
"-drive id=hd0,if=none,file=%s,format=raw "
@@ -749,24 +710,7 @@ static void test_acpi_one(const char *params, test_data *data)
qtest_start(args);
- /* Wait at most 1 minute */
-#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
-#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)
-
- /* Poll until code has run and modified memory. Once it has we know BIOS
- * initialization is done. TODO: check that IP reached the halt
- * instruction.
- */
- for (i = 0; i < TEST_CYCLES; ++i) {
- signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
- signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
- signature = (signature_high << 8) | signature_low;
- if (signature == SIGNATURE) {
- break;
- }
- g_usleep(TEST_DELAY);
- }
- g_assert_cmphex(signature, ==, SIGNATURE);
+ boot_sector_test();
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
@@ -840,15 +784,11 @@ static void test_acpi_q35_tcg_bridge(void)
int main(int argc, char *argv[])
{
const char *arch = qtest_get_arch();
- FILE *f = fopen(disk, "w");
int ret;
- if (!f) {
- fprintf(stderr, "Couldn't open \"%s\": %s", disk, strerror(errno));
- return 1;
- }
- fwrite(boot_sector, 1, sizeof boot_sector, f);
- fclose(f);
+ ret = boot_sector_init(disk);
+ if(ret)
+ return ret;
g_test_init(&argc, &argv, NULL);
@@ -859,6 +799,6 @@ int main(int argc, char *argv[])
qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge);
}
ret = g_test_run();
- unlink(disk);
+ boot_sector_cleanup(disk);
return ret;
}