qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for-2.4 v5 5/7] tests: test-x86-cpu: Add TCG feature


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH for-2.4 v5 5/7] tests: test-x86-cpu: Add TCG feature bit initialization test
Date: Mon, 23 Mar 2015 16:37:10 -0300

Signed-off-by: Eduardo Habkost <address@hidden>
---
 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 1ce7e1d..a0923e7 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;
+        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_abort);
+
+        for (w = 0; w < FEATURE_WORDS; w++) {
+            uint32_t expected = def->features[w] | default_features_all[w];
+            uint32_t actual = cpu->env.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();
 
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]