qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gal Hammer <ghammer@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gal Hammer <ghammer@redhat.com>, imammedo@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH V15 5/5] tests: add a unit test for the vmgenid device.
Date: Mon, 27 Apr 2015 14:19:51 +0300	[thread overview]
Message-ID: <1430133591-6197-6-git-send-email-ghammer@redhat.com> (raw)
In-Reply-To: <1430133591-6197-1-git-send-email-ghammer@redhat.com>

Signed-off-by: Gal Hammer <ghammer@redhat.com>
---
 tests/Makefile       |  2 ++
 tests/vmgenid-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 tests/vmgenid-test.c

diff --git a/tests/Makefile b/tests/Makefile
index 55aa745..6e4905c 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -175,6 +175,7 @@ check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-xhci.c
 check-qtest-i386-y += tests/pc-cpu-test$(EXESUF)
 check-qtest-i386-$(CONFIG_LINUX) += tests/vhost-user-test$(EXESUF)
+check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
 check-qtest-x86_64-y = $(check-qtest-i386-y)
 gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
 gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
@@ -369,6 +370,7 @@ tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o
 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/test-write-threshold$(EXESUF): tests/test-write-threshold.o $(block-obj-y) 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..abb7974
--- /dev/null
+++ b/tests/vmgenid-test.c
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+    /* Skip the ACPI ADDR method and read the GUID directly from memory. */
+    for (i = 0; i < 16; i++) {
+        guid[i] = readb(0xfedf0000 + 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

  parent reply	other threads:[~2015-04-27 11:20 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 11:19 [Qemu-devel] [PATCH V15 0/5] Virtual Machine Generation ID Gal Hammer
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 1/5] docs: vm generation id device's description Gal Hammer
2015-04-27 13:42   ` Michael S. Tsirkin
2015-04-27 13:55   ` Michael S. Tsirkin
2015-04-28 14:20     ` Gal Hammer
2015-04-27 14:56   ` Eric Blake
2015-04-28 14:38     ` Gal Hammer
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 2/5] acpi: add a vm_generation_id_changed method Gal Hammer
2015-04-27 14:57   ` Eric Blake
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 3/5] aml: implement a 32-bit fixed memory range descriptor Gal Hammer
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 4/5] i386: add a Virtual Machine Generation ID device Gal Hammer
2015-04-27 13:38   ` Michael S. Tsirkin
2015-04-29 12:46     ` Gal Hammer
2015-04-27 14:59   ` Eric Blake
2015-05-28 10:25   ` Paolo Bonzini
2015-05-28 11:49     ` Michael S. Tsirkin
2015-05-28 11:59     ` Gal Hammer
2015-05-28 12:21       ` Michael S. Tsirkin
2015-05-28 13:00         ` Paolo Bonzini
2015-05-28 13:24           ` Michael S. Tsirkin
2015-05-28 13:35             ` Paolo Bonzini
2015-05-29 11:46   ` Igor Mammedov
2015-06-03 16:32     ` Michael S. Tsirkin
2015-06-03 16:37   ` Paolo Bonzini
2015-06-08 13:42     ` Gal Hammer
2015-06-08 13:43       ` Paolo Bonzini
2015-06-08 13:52         ` Gal Hammer
2015-06-08 13:55           ` Paolo Bonzini
2015-06-08 13:58             ` Daniel P. Berrange
2015-06-08 14:05               ` Gal Hammer
2015-06-08 15:01               ` Michael S. Tsirkin
2015-06-08 15:17                 ` Paolo Bonzini
2015-06-08 15:22                   ` Michael S. Tsirkin
2015-06-08 15:28                     ` Gal Hammer
2015-06-08 15:32                       ` Michael S. Tsirkin
2015-06-08 15:33                     ` Paolo Bonzini
2015-06-08 15:41                       ` Michael S. Tsirkin
2015-06-08 15:43                         ` Paolo Bonzini
2015-06-08 14:00             ` Gal Hammer
2015-06-08 13:59               ` Paolo Bonzini
2015-04-27 11:19 ` Gal Hammer [this message]
2015-04-27 15:01   ` [Qemu-devel] [PATCH V15 5/5] tests: add a unit test for the vmgenid device Eric Blake
2015-04-27 16:17     ` 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=1430133591-6197-6-git-send-email-ghammer@redhat.com \
    --to=ghammer@redhat.com \
    --cc=imammedo@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).