From: "Andreas Färber" <afaerber@suse.de>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Markus Armbruster <armbru@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test
Date: Sat, 19 Oct 2013 02:13:44 +0200 [thread overview]
Message-ID: <5261CEB8.1050108@suse.de> (raw)
In-Reply-To: <1382046646-20263-2-git-send-email-mst@redhat.com>
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
next prev parent reply other threads:[~2013-10-19 0:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 21:52 [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Michael S. Tsirkin
2013-10-17 21:52 ` [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test Michael S. Tsirkin
2013-10-18 5:30 ` Markus Armbruster
2013-10-18 6:36 ` Paolo Bonzini
2013-10-18 11:43 ` Markus Armbruster
2013-10-18 11:20 ` Michael S. Tsirkin
2013-10-19 0:13 ` Andreas Färber [this message]
2013-10-19 1:25 ` Anthony Liguori
2013-10-19 17:27 ` Michael S. Tsirkin
2013-10-18 11:51 ` [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Paolo Bonzini
2013-10-18 12:13 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5261CEB8.1050108@suse.de \
--to=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=armbru@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.