Am 17.10.2013 23:52, schrieb Michael S. Tsirkin: > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > new file mode 100644 > index 0000000..42de248 > --- /dev/null > +++ b/tests/acpi-test.c [...] > +static void test_acpi_one(const char *params) > +{ > + char *args; > + uint8_t signature_low; > + uint8_t signature_high; > + uint16_t signature; > + int i; > + uint32_t off; > + > + > + args = g_strdup_printf("-net none -display none %s %s", > + params ? params : "", disk); > + qtest_start(args); > + > + /* Wait at most 1 minute */ > +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) > +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) > + > + 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);
Might be a good safety precaution to use QEMU_BUG_ON() or MIN(..., 1) for TEST_CYCLES to assure signature gets initialized before comparison. > + > + /* OK, now find RSDP */ > + for (off = 0xf0000; off < 0x100000; off += 0x10) > + { > + uint8_t sig[] = "RSD PTR "; > + int i; > + > + for (i = 0; i < sizeof sig - 1; ++i) { > + sig[i] = readb(off + i); > + } > + > + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { > + break; > + } > + } > + > + g_assert_cmphex(off, <, 0x100000); > + > + qtest_quit(global_qtest); > + g_free(args); > +} > + > +static void test_acpi_tcg(void) > +{ > + test_acpi_one("-machine accel=tcg"); > +} > + > +static void test_acpi_kvm(void) > +{ > + test_acpi_one("-enable-kvm -machine accel=kvm"); > +} > + > +int main(int argc, char *argv[]) > +{ > + const char *arch = qtest_get_arch(); > + FILE *f = fopen(disk, "w"); > + fwrite(boot_sector, 1, sizeof boot_sector, f); > + fclose(f); > + > + g_test_init(&argc, &argv, NULL); > + > + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > + qtest_add_func("acpi/tcg", test_acpi_tcg); > + qtest_add_func("acpi/kvm", test_acpi_kvm); Sorry, while the intention is good, this is a no-go. Not only will make check fail on KVM-incompatible x86 hosts (including insufficient permissions for /dev/kvm), it will also fail on ppc or arm hosts since we are testing the target architecture here. Regards, Andreas > + } > + return g_test_run(); > +} [snip] -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg