[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 10/10] tests: test-x86-cpu: Add KVM feature bit initia
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC 10/10] tests: test-x86-cpu: Add KVM feature bit initialization test |
Date: |
Thu, 25 Sep 2014 17:18:29 -0300 |
Signed-off-by: Eduardo Habkost <address@hidden>
---
tests/test-x86-cpu.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tests/test-x86-cpu.c b/tests/test-x86-cpu.c
index e8e9a74..afd5088 100644
--- a/tests/test-x86-cpu.c
+++ b/tests/test-x86-cpu.c
@@ -54,6 +54,33 @@ static void test_cpu_features_tcg(void)
}
}
+static void test_cpu_features_kvm(void)
+{
+ int i;
+ kvm_allowed = true;
+ 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];
+ expected |= kvm_default_features[w];
+ expected &= ~kvm_default_unset_features[w];
+ g_assert_cmpint(actual, ==, expected);
+ }
+ object_unref(OBJECT(cpu));
+ }
+}
+
int main(int argc, char *argv[])
{
module_call_init(MODULE_INIT_QOM);
@@ -62,6 +89,7 @@ int main(int argc, char *argv[])
g_test_add_func("/cpu/x86/creation", test_cpu_creation);
g_test_add_func("/cpu/x86/features/tcg", test_cpu_features_tcg);
+ g_test_add_func("/cpu/x86/features/kvm", test_cpu_features_kvm);
g_test_run();
--
1.9.3
- [Qemu-devel] [RFC 00/10] Target-specific unit test support, add unit tests for target-i386/cpu.c code, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 01/10] tests: Add missing include to test-bitops.c, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 02/10] bitops.h: Don't include qemu-common.h, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 03/10] bitmap.h: Don't include qemu-common.h, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 04/10] tests: Move fake yield_until_fd_readable() to coroutine-stub.c, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 05/10] tests: Support target-specific unit tests, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 07/10] tests: Add unit test for X86CPU code, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 08/10] target-i386: Isolate enabled-by-default features to a separate array, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 06/10] tests: Make test-x86-cpuid target-specific, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 09/10] tests: test-x86-cpu: Add TCG feature bit initialization test, Eduardo Habkost, 2014/09/25
- [Qemu-devel] [RFC 10/10] tests: test-x86-cpu: Add KVM feature bit initialization test,
Eduardo Habkost <=
- Re: [Qemu-devel] [RFC 00/10] Target-specific unit test support, add unit tests for target-i386/cpu.c code, Paolo Bonzini, 2014/09/26