From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z50UT-0003vJ-97 for qemu-devel@nongnu.org; Tue, 16 Jun 2015 19:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z50UN-0002P5-K4 for qemu-devel@nongnu.org; Tue, 16 Jun 2015 19:42:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z50UN-0002Ox-CF for qemu-devel@nongnu.org; Tue, 16 Jun 2015 19:41:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id BB93BB8BC8 for ; Tue, 16 Jun 2015 23:41:54 +0000 (UTC) Date: Wed, 17 Jun 2015 01:41:48 +0200 From: Igor Mammedov Message-ID: <20150617014148.09e1e017@igors-macbook-pro.local> In-Reply-To: <1434463863-26560-5-git-send-email-ghammer@redhat.com> References: <1434463863-26560-1-git-send-email-ghammer@redhat.com> <1434463863-26560-5-git-send-email-ghammer@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V16 4/4] tests: add a unit test for the vmgenid device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gal Hammer Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, mst@redhat.com On Tue, 16 Jun 2015 17:11:03 +0300 Gal Hammer wrote: > Signed-off-by: Gal Hammer > --- > 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 c5e4744..3608068 100644 > --- a/tests/Makefile > +++ b/tests/Makefile > @@ -177,6 +177,7 @@ check-qtest-i386-y += tests/pc-cpu-test$(EXESUF) > check-qtest-i386-y += tests/q35-test$(EXESUF) > gcov-files-i386-y += hw/pci-host/q35.c > 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)) @@ -396,6 +397,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..dad1f1b > --- /dev/null > +++ b/tests/vmgenid-test.c > @@ -0,0 +1,44 @@ > +/* > + * QTest testcase for VM Generation ID > + * > + * Copyright (c) 2015 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 > +#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); get address from vmgidid.addr property > + } > + > + 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("-device > vmgenid,uuid=324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"); add case for non default addr value, BTW if board would use default mapping addr then it should also set vmgenid.addr to it so that introspection tools would see actual mapped addr. > + ret = g_test_run(); > + > + qtest_end(); > + > + return ret; > +}