From: Gal Hammer <ghammer@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gal Hammer <ghammer@redhat.com>, mst@redhat.com
Subject: [Qemu-devel] [PATCH V11 3/3] tests: add a unit test for the vmgenid device.
Date: Tue, 16 Dec 2014 17:50:44 +0200 [thread overview]
Message-ID: <1418745044-3986-4-git-send-email-ghammer@redhat.com> (raw)
In-Reply-To: <1418745044-3986-1-git-send-email-ghammer@redhat.com>
Signed-off-by: Gal Hammer <ghammer@redhat.com>
---
tests/Makefile | 2 ++
tests/vmgenid-test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100644 tests/vmgenid-test.c
diff --git a/tests/Makefile b/tests/Makefile
index 16f0e4c..612441a 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -64,6 +64,7 @@ gcov-files-check-qom-interface-y = qom/object.c
check-unit-$(CONFIG_POSIX) += tests/test-vmstate$(EXESUF)
check-unit-y += tests/test-qemu-opts$(EXESUF)
gcov-files-test-qemu-opts-y = qom/test-qemu-opts.c
+check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
@@ -351,6 +352,7 @@ tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y)
tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a
+tests/vmgenid-test$(EXESUF): tests/vmgenid-test.o
ifeq ($(CONFIG_POSIX),y)
LIBS += -lutil
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
new file mode 100644
index 0000000..d9c3e29
--- /dev/null
+++ b/tests/vmgenid-test.c
@@ -0,0 +1,48 @@
+/*
+ * QTest testcase for VM Generation ID
+ *
+ * Copyright (c) 2014 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <string.h>
+#include "libqtest.h"
+
+static void vmgenid_test(void)
+{
+ static const uint8_t expected[16] = {
+ 0x32, 0x4e, 0x6e, 0xaf, 0xd1, 0xd1, 0x4b, 0xf6,
+ 0xbf, 0x41, 0xb9, 0xbb, 0x6c, 0x91, 0xfb, 0x87
+ };
+ uint8_t guid[16];
+ uint32_t i;
+
+ // Emulate the ACPI _INI method (tells the device where the physical
+ // memory was "allocated".
+ writel(0xfedf0000, 0x0001f000);
+
+ // Skip the ACPI ADDR method and read the GUID directly from memory.
+ for (i = 0; i < 16; i++) {
+ guid[i] = readb(0x0001f000 + i);
+ }
+
+ g_assert_cmpuint(sizeof(guid), ==, sizeof(expected));
+ g_assert(memcmp(guid, expected, sizeof(guid)) == 0);
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ g_test_init(&argc, &argv, NULL);
+ qtest_add_func("/vmgenid/vmgenid", vmgenid_test);
+
+ qtest_start("-global vmgenid.uuid=324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87");
+ ret = g_test_run();
+
+ qtest_end();
+
+ return ret;
+}
--
2.1.0
prev parent reply other threads:[~2014-12-16 15:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 15:50 [Qemu-devel] [PATCH V11 0/3] Virtual Machine Generation ID Gal Hammer
2014-12-16 15:50 ` [Qemu-devel] [PATCH V11 1/3] docs: vm generation id device's description Gal Hammer
2014-12-16 15:50 ` [Qemu-devel] [PATCH V11 2/3] i386: Add a Virtual Machine Generation ID device Gal Hammer
2015-01-22 13:52 ` Igor Mammedov
2015-01-22 21:21 ` Michael S. Tsirkin
2015-02-01 12:56 ` Gal Hammer
2015-02-02 12:46 ` Igor Mammedov
2015-02-02 13:13 ` Gal Hammer
2015-02-02 13:55 ` Igor Mammedov
2015-02-04 15:09 ` Gal Hammer
2015-02-04 15:53 ` Igor Mammedov
2015-02-04 16:07 ` Michael S. Tsirkin
2014-12-16 15:50 ` Gal Hammer [this message]
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=1418745044-3986-4-git-send-email-ghammer@redhat.com \
--to=ghammer@redhat.com \
--cc=mst@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).