[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 3/4] topo unit-test: update Unit tests to test-x8
From: |
Chen Fan |
Subject: |
[Qemu-devel] [PATCH v1 3/4] topo unit-test: update Unit tests to test-x86-cpuid.c |
Date: |
Wed, 19 Mar 2014 16:53:42 +0800 |
remove redundant x86_apicid_from_cpu_idx() tests.
add tests to check x86_topo_ids_from_apic_id() and
x86_topo_ids_from_apic_id() output.
Signed-off-by: Chen Fan <address@hidden>
---
tests/test-x86-cpuid.c | 165 ++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 129 insertions(+), 36 deletions(-)
diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c
index 8d9f96a..4f33ecb 100644
--- a/tests/test-x86-cpuid.c
+++ b/tests/test-x86-cpuid.c
@@ -32,11 +32,36 @@ static void test_topo_bits(void)
g_assert_cmpuint(apicid_smt_width(1, 1), ==, 0);
g_assert_cmpuint(apicid_core_width(1, 1), ==, 0);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 0), ==, 0);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1), ==, 1);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 2), ==, 2);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 3), ==, 3);
-
+ X86CPUTopoInfo topo = {0};
+
+ x86_topo_ids_from_idx(1, 1, 0, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 0);
+ x86_topo_ids_from_idx(1, 1, 1, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 1);
+ x86_topo_ids_from_idx(1, 1, 2, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 2);
+ x86_topo_ids_from_idx(1, 1, 3, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 3);
+
+ x86_topo_ids_from_apic_id(1, 1, 0, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+
+ x86_topo_ids_from_apic_id(1, 1, 1, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 1);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+
+ x86_topo_ids_from_apic_id(1, 1, 2, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 2);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+
+ x86_topo_ids_from_apic_id(1, 1, 3, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 3);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
/* Test field width calculation for multiple values
*/
@@ -65,37 +90,105 @@ static void test_topo_bits(void)
g_assert_cmpuint(apicid_core_width(6, 3), ==, 3);
g_assert_cmpuint(apicid_pkg_offset(6, 3), ==, 5);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 0), ==, 0);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1), ==, 1);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2), ==, 2);
-
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 3 + 0), ==,
- (1 << 2) | 0);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 3 + 1), ==,
- (1 << 2) | 1);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 3 + 2), ==,
- (1 << 2) | 2);
-
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2 * 3 + 0), ==,
- (2 << 2) | 0);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2 * 3 + 1), ==,
- (2 << 2) | 1);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2 * 3 + 2), ==,
- (2 << 2) | 2);
-
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 5 * 3 + 0), ==,
- (5 << 2) | 0);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 5 * 3 + 1), ==,
- (5 << 2) | 1);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 5 * 3 + 2), ==,
- (5 << 2) | 2);
-
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 6 * 3 + 0 * 3 + 0), ==,
- (1 << 5));
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 6 * 3 + 1 * 3 + 1), ==,
- (1 << 5) | (1 << 2) | 1);
- g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 3 * 6 * 3 + 5 * 3 + 2), ==,
- (3 << 5) | (5 << 2) | 2);
+ x86_topo_ids_from_idx(6, 3, 0, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 0);
+ x86_topo_ids_from_idx(6, 3, 1, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 1);
+ x86_topo_ids_from_idx(6, 3, 2, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, 2);
+
+ x86_topo_ids_from_idx(6, 3, 1 * 3 + 0, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (1 << 2) | 0);
+ x86_topo_ids_from_idx(6, 3, 1 * 3 + 1, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (1 << 2) | 1);
+ x86_topo_ids_from_idx(6, 3, 1 * 3 + 2, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (1 << 2) | 2);
+
+ x86_topo_ids_from_idx(6, 3, 2 * 3 + 0, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (2 << 2) | 0);
+ x86_topo_ids_from_idx(6, 3, 2 * 3 + 1, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (2 << 2) | 1);
+ x86_topo_ids_from_idx(6, 3, 2 * 3 + 2, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (2 << 2) | 2);
+
+ x86_topo_ids_from_idx(6, 3, 5 * 3 + 0, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (5 << 2) | 0);
+ x86_topo_ids_from_idx(6, 3, 5 * 3 + 1, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (5 << 2) | 1);
+ x86_topo_ids_from_idx(6, 3, 5 * 3 + 2, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (5 << 2) | 2);
+
+ x86_topo_ids_from_idx(6, 3, 1 * 6 * 3 + 0 * 3 + 0, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (1 << 5) | 0);
+ x86_topo_ids_from_idx(6, 3, 1 * 6 * 3 + 1 * 3 + 1, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (1 << 5) | (1 << 2) | 1);
+ x86_topo_ids_from_idx(6, 3, 3 * 6 * 3 + 5 * 3 + 2, &topo);
+ g_assert_cmpuint(topo.apic_id, ==, (3 << 5) | (5 << 2) | 2);
+
+ x86_topo_ids_from_apic_id(6, 3, 0, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+ x86_topo_ids_from_apic_id(6, 3, 1, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 1);
+ x86_topo_ids_from_apic_id(6, 3, 2, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 2);
+
+ x86_topo_ids_from_apic_id(6, 3, (1 << 2) | 0, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 1);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+ x86_topo_ids_from_apic_id(6, 3, (1 << 2) | 1, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 1);
+ g_assert_cmpuint(topo.smt_id, ==, 1);
+ x86_topo_ids_from_apic_id(6, 3, (1 << 2) | 2, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 1);
+ g_assert_cmpuint(topo.smt_id, ==, 2);
+
+ x86_topo_ids_from_apic_id(6, 3, (2 << 2) | 0, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 2);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+ x86_topo_ids_from_apic_id(6, 3, (2 << 2) | 1, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 2);
+ g_assert_cmpuint(topo.smt_id, ==, 1);
+ x86_topo_ids_from_apic_id(6, 3, (2 << 2) | 2, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 2);
+ g_assert_cmpuint(topo.smt_id, ==, 2);
+
+ x86_topo_ids_from_apic_id(6, 3, (5 << 2) | 0, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 5);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+ x86_topo_ids_from_apic_id(6, 3, (5 << 2) | 1, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 5);
+ g_assert_cmpuint(topo.smt_id, ==, 1);
+ x86_topo_ids_from_apic_id(6, 3, (5 << 2) | 2, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 0);
+ g_assert_cmpuint(topo.core_id, ==, 5);
+ g_assert_cmpuint(topo.smt_id, ==, 2);
+
+ x86_topo_ids_from_apic_id(6, 3, (1 << 5) | 0, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 1);
+ g_assert_cmpuint(topo.core_id, ==, 0);
+ g_assert_cmpuint(topo.smt_id, ==, 0);
+ x86_topo_ids_from_apic_id(6, 3, (1 << 5) | (1 << 2) | 1, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 1);
+ g_assert_cmpuint(topo.core_id, ==, 1);
+ g_assert_cmpuint(topo.smt_id, ==, 1);
+ x86_topo_ids_from_apic_id(6, 3, (1 << 5) | (1 << 2) | 2, &topo);
+ g_assert_cmpuint(topo.pkg_id, ==, 1);
+ g_assert_cmpuint(topo.core_id, ==, 1);
+ g_assert_cmpuint(topo.smt_id, ==, 2);
}
int main(int argc, char **argv)
--
1.8.1.4
- [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), (continued)
- [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), chen.fan.fnst, 2014/03/11
- Re: [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Eduardo Habkost, 2014/03/11
- Re: [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Chen Fan, 2014/03/12
- [Qemu-devel] [RFC v4 0/3] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu, Chen Fan, 2014/03/12
- [Qemu-devel] [RFC v4 1/3] cpu: introduce CpuTopoInfo structure for argument simplification, Chen Fan, 2014/03/12
- Re: [Qemu-devel] [RFC v4 1/3] cpu: introduce CpuTopoInfo structure for argument simplification, Eduardo Habkost, 2014/03/12
- [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu, Chen Fan, 2014/03/19
- [Qemu-devel] [PATCH v1 2/4] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Chen Fan, 2014/03/19
- Re: [Qemu-devel] [PATCH v1 2/4] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Eduardo Habkost, 2014/03/19
- Re: [Qemu-devel] [PATCH v1 2/4] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Chen Fan, 2014/03/20
- [Qemu-devel] [PATCH v1 3/4] topo unit-test: update Unit tests to test-x86-cpuid.c,
Chen Fan <=
- [Qemu-devel] [PATCH v1 1/4] cpu: introduce CpuTopoInfo structure for argument simplification, Chen Fan, 2014/03/19
- [Qemu-devel] [PATCH v1 4/4] i386: introduce cpu QOM hierarchy tree, Chen Fan, 2014/03/19
- Re: [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu, Eric Blake, 2014/03/19
- Re: [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu, Chen Fan, 2014/03/19
- [Qemu-devel] [RFC v4 3/3] i386: introduce cpu QOM hierarchy tree, Chen Fan, 2014/03/12
- [Qemu-devel] [RFC v4 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Chen Fan, 2014/03/12
- Re: [Qemu-devel] [RFC v4 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu(), Eduardo Habkost, 2014/03/12
- [Qemu-devel] [RFC v3 3/3] i386: introduce cpu QOM hierarchy tree, chen.fan.fnst, 2014/03/11
[Qemu-devel] [RFC v2 2/2] i386: introduce cpu QOM hierarchy tree, Chen Fan, 2014/03/04