[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 27/52] test/test-smp-parse: Check fields of MachineState.topo.smp
From: |
Zhao Liu |
Subject: |
[RFC 27/52] test/test-smp-parse: Check fields of MachineState.topo.smp |
Date: |
Mon, 13 Feb 2023 17:50:10 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
MachineState.smp is being replaced by MachineState.topo.smp, so test
MachineState.topo.smp fields parsing for smp command.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
tests/unit/test-smp-parse.c | 62 ++++++++++++++++++++++---------------
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c
index fdc39a846ca6..d6816f109084 100644
--- a/tests/unit/test-smp-parse.c
+++ b/tests/unit/test-smp-parse.c
@@ -41,10 +41,13 @@
#define CPU_TOPOLOGY_GENERIC(a, b, c, d, e) \
{ \
.cpus = a, \
- .sockets = b, \
- .cores = c, \
- .threads = d, \
.max_cpus = e, \
+ .topo_type = CPU_TOPO_TYPE_SMP, \
+ .smp = { \
+ .sockets = b, \
+ .cores = c, \
+ .threads = d, \
+ } \
}
/*
@@ -406,8 +409,8 @@ static char *cpu_topology_to_string(const CpuTopology *topo)
" .threads = %u,\n"
" .max_cpus = %u,\n"
"}",
- topo->cpus, topo->sockets, topo->dies, topo->clusters,
- topo->cores, topo->threads, topo->max_cpus);
+ topo->cpus, topo->smp.sockets, topo->smp.dies, topo->smp.clusters,
+ topo->smp.cores, topo->smp.threads, topo->max_cpus);
}
static void check_parse(MachineState *ms, const SMPConfiguration *config,
@@ -422,18 +425,19 @@ static void check_parse(MachineState *ms, const
SMPConfiguration *config,
/* call the generic parser */
machine_parse_smp_config(ms, config, &err);
- output_topo_str = cpu_topology_to_string(&ms->smp);
+ output_topo_str = cpu_topology_to_string(&ms->topo);
/* when the configuration is supposed to be valid */
if (is_valid) {
if ((err == NULL) &&
- (ms->smp.cpus == expect_topo->cpus) &&
- (ms->smp.sockets == expect_topo->sockets) &&
- (ms->smp.dies == expect_topo->dies) &&
- (ms->smp.clusters == expect_topo->clusters) &&
- (ms->smp.cores == expect_topo->cores) &&
- (ms->smp.threads == expect_topo->threads) &&
- (ms->smp.max_cpus == expect_topo->max_cpus)) {
+ (machine_topo_is_smp(ms) == true) &&
+ (machine_topo_get_cpus(ms) == expect_topo->cpus) &&
+ (machine_topo_get_sockets(ms) == expect_topo->smp.sockets) &&
+ (machine_topo_get_dies(ms) == expect_topo->smp.dies) &&
+ (machine_topo_get_clusters(ms) == expect_topo->smp.clusters) &&
+ (machine_topo_get_smp_cores(ms) == expect_topo->smp.cores) &&
+ (machine_topo_get_smp_threads(ms) == expect_topo->smp.threads) &&
+ (machine_topo_get_max_cpus(ms) == expect_topo->max_cpus)) {
return;
}
@@ -509,13 +513,13 @@ static void smp_parse_test(MachineState *ms, SMPTestData
*data, bool is_valid)
static void unsupported_params_init(const MachineClass *mc, SMPTestData *data)
{
if (!mc->smp_props.dies_supported) {
- data->expect_prefer_sockets.dies = 1;
- data->expect_prefer_cores.dies = 1;
+ data->expect_prefer_sockets.smp.dies = 1;
+ data->expect_prefer_cores.smp.dies = 1;
}
if (!mc->smp_props.clusters_supported) {
- data->expect_prefer_sockets.clusters = 1;
- data->expect_prefer_cores.clusters = 1;
+ data->expect_prefer_sockets.smp.clusters = 1;
+ data->expect_prefer_cores.smp.clusters = 1;
}
}
@@ -529,6 +533,13 @@ static void machine_base_class_init(ObjectClass *oc, void
*data)
mc->name = g_strdup(SMP_MACHINE_NAME);
}
+static void machine_smp_topo_initfn(Object *obj)
+{
+ MachineState *ms = MACHINE(obj);
+
+ ms->topo.topo_type = CPU_TOPO_TYPE_SMP;
+}
+
static void machine_generic_invalid_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -610,8 +621,8 @@ static void test_with_dies(const void *opaque)
unsupported_params_init(mc, &data);
/* when dies parameter is omitted, it will be set as 1 */
- data.expect_prefer_sockets.dies = 1;
- data.expect_prefer_cores.dies = 1;
+ data.expect_prefer_sockets.smp.dies = 1;
+ data.expect_prefer_cores.smp.dies = 1;
smp_parse_test(ms, &data, true);
@@ -625,10 +636,10 @@ static void test_with_dies(const void *opaque)
data.config.maxcpus *= num_dies;
}
- data.expect_prefer_sockets.dies = num_dies;
+ data.expect_prefer_sockets.smp.dies = num_dies;
data.expect_prefer_sockets.cpus *= num_dies;
data.expect_prefer_sockets.max_cpus *= num_dies;
- data.expect_prefer_cores.dies = num_dies;
+ data.expect_prefer_cores.smp.dies = num_dies;
data.expect_prefer_cores.cpus *= num_dies;
data.expect_prefer_cores.max_cpus *= num_dies;
@@ -660,8 +671,8 @@ static void test_with_clusters(const void *opaque)
unsupported_params_init(mc, &data);
/* when clusters parameter is omitted, it will be set as 1 */
- data.expect_prefer_sockets.clusters = 1;
- data.expect_prefer_cores.clusters = 1;
+ data.expect_prefer_sockets.smp.clusters = 1;
+ data.expect_prefer_cores.smp.clusters = 1;
smp_parse_test(ms, &data, true);
@@ -675,10 +686,10 @@ static void test_with_clusters(const void *opaque)
data.config.maxcpus *= num_clusters;
}
- data.expect_prefer_sockets.clusters = num_clusters;
+ data.expect_prefer_sockets.smp.clusters = num_clusters;
data.expect_prefer_sockets.cpus *= num_clusters;
data.expect_prefer_sockets.max_cpus *= num_clusters;
- data.expect_prefer_cores.clusters = num_clusters;
+ data.expect_prefer_cores.smp.clusters = num_clusters;
data.expect_prefer_cores.cpus *= num_clusters;
data.expect_prefer_cores.max_cpus *= num_clusters;
@@ -704,6 +715,7 @@ static const TypeInfo smp_machine_types[] = {
.class_init = machine_base_class_init,
.class_size = sizeof(MachineClass),
.instance_size = sizeof(MachineState),
+ .instance_init = machine_smp_topo_initfn,
}, {
.name = MACHINE_TYPE_NAME("smp-generic-valid"),
.parent = TYPE_MACHINE,
--
2.34.1
- [RFC 16/52] plugins: Use generic topology name and helper, (continued)
- [RFC 16/52] plugins: Use generic topology name and helper, Zhao Liu, 2023/02/13
- [RFC 17/52] softmmu/cpus: Use generic topology helper in vcpus initialization, Zhao Liu, 2023/02/13
- [RFC 18/52] general: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 19/52] i386: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 20/52] s390x: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 21/52] ppc: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 22/52] riscv: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 23/52] arm: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 25/52] mips: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 26/52] hw: Replace MachineState.smp access with topology helpers for all remaining archs, Zhao Liu, 2023/02/13
- [RFC 27/52] test/test-smp-parse: Check fields of MachineState.topo.smp,
Zhao Liu <=
- [RFC 28/52] hw/core/machine: Remove support of MachineState.smp, Zhao Liu, 2023/02/13
- [RFC 24/52] loongarch: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 30/52] i386: Drop nr_dies and nr_modules CPUX86State, Zhao Liu, 2023/02/13
- [RFC 29/52] hw/core/cpu: Introduce TopologyState in CPUState, Zhao Liu, 2023/02/13
- [RFC 31/52] i386/cpu: Use CPUState.topo to replace X86CPUTopoInfo to get topology info, Zhao Liu, 2023/02/13
- [RFC 32/52] i386: Rename X86CPUTopoInfo and its members to reflect relationship with APIC ID, Zhao Liu, 2023/02/13
- [RFC 35/52] i386: Support APIC ID topology for hybrid CPU topology, Zhao Liu, 2023/02/13
- [RFC 33/52] i386: Rename init_topo_info() to init_apic_topo_info(), Zhao Liu, 2023/02/13