From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXKB7-000629-Ve for qemu-devel@nongnu.org; Fri, 18 Oct 2013 20:14:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXKAx-0004Ir-3c for qemu-devel@nongnu.org; Fri, 18 Oct 2013 20:14:01 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45168 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXKAw-0004IW-QJ for qemu-devel@nongnu.org; Fri, 18 Oct 2013 20:13:51 -0400 Message-ID: <5261CEB8.1050108@suse.de> Date: Sat, 19 Oct 2013 02:13:44 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1382046646-20263-1-git-send-email-mst@redhat.com> <1382046646-20263-2-git-send-email-mst@redhat.com> In-Reply-To: <1382046646-20263-2-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Markus Armbruster , Anthony Liguori 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 =3D 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 =3D 0; i < TEST_CYCLES; ++i) { > + signature_low =3D readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET= ); > + signature_high =3D readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSE= T + 1); > + signature =3D (signature_high << 8) | signature_low; > + if (signature =3D=3D SIGNATURE) { > + break; > + } > + g_usleep(TEST_DELAY); > + } > + g_assert_cmphex(signature, =3D=3D, 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 =3D 0xf0000; off < 0x100000; off +=3D 0x10) > + { > + uint8_t sig[] =3D "RSD PTR "; > + int i; > + > + for (i =3D 0; i < sizeof sig - 1; ++i) { > + sig[i] =3D 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=3Dtcg"); > +} > + > +static void test_acpi_kvm(void) > +{ > + test_acpi_one("-enable-kvm -machine accel=3Dkvm"); > +} > + > +int main(int argc, char *argv[]) > +{ > + const char *arch =3D qtest_get_arch(); > + FILE *f =3D fopen(disk, "w"); > + fwrite(boot_sector, 1, sizeof boot_sector, f); > + fclose(f); > + > + g_test_init(&argc, &argv, NULL); > + > + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D= 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] --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg