From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0ag3-0002N3-1Q for qemu-devel@nongnu.org; Mon, 15 Dec 2014 13:47:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0afw-0004ad-SG for qemu-devel@nongnu.org; Mon, 15 Dec 2014 13:47:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0afw-0004aW-Kd for qemu-devel@nongnu.org; Mon, 15 Dec 2014 13:47:20 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBFIlKDW029746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 15 Dec 2014 13:47:20 -0500 From: Eduardo Habkost Date: Mon, 15 Dec 2014 16:44:58 -0200 Message-Id: <1418669099-30322-6-git-send-email-ehabkost@redhat.com> In-Reply-To: <1418669099-30322-1-git-send-email-ehabkost@redhat.com> References: <1418669099-30322-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH v4 5/6] tests: test-x86-cpu: Add TCG feature bit initialization test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Igor Mammedov Signed-off-by: Eduardo Habkost --- tests/test-x86-cpu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test-x86-cpu.c b/tests/test-x86-cpu.c index b6e4382..fb3de05 100644 --- a/tests/test-x86-cpu.c +++ b/tests/test-x86-cpu.c @@ -54,6 +54,30 @@ static void test_cpu_creation(void) } } +static void test_cpu_features_tcg(void) +{ + int i; + for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); ++i) { + FeatureWord w; + ObjectClass *oc; + X86CPU *cpu; + Error *error = NULL; + X86CPUDefinition *def = &builtin_x86_defs[i]; + char features[] = ""; + + oc = x86_cpu_class_by_name(def->name); + cpu = X86_CPU(object_new(object_class_get_name(oc))); + x86_cpu_parse_featurestr(CPU(cpu), features, &error); + + for (w = 0; w < FEATURE_WORDS; w++) { + uint32_t expected = def->features[w] | default_features_all[w]; + uint32_t actual = cpu->env.features[w] | cpu->filtered_features[w]; + g_assert_cmpint(actual, ==, expected); + } + object_unref(OBJECT(cpu)); + } +} + int main(int argc, char *argv[]) { module_call_init(MODULE_INIT_QOM); @@ -61,6 +85,7 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); g_test_add_func("/cpu/x86/creation", test_cpu_creation); + g_test_add_func("/cpu/x86/features/tcg", test_cpu_features_tcg); g_test_run(); -- 1.9.3