tests/qtest: Add numa test for loongarch system

Add numa test case for loongarch system, it passes to run
with command "make check-qtest".

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Acked-by: Thomas Huth <thuth@redhat.com>
Tested-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240528082155.938586-1-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
Bibo Mao 2024-05-28 16:21:55 +08:00 committed by Song Gao
parent fe43cc5bde
commit a73f7a00ee
2 changed files with 54 additions and 1 deletions

View File

@ -140,7 +140,7 @@ qtests_hppa = ['boot-serial-test'] + \
(config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
qtests_loongarch64 = qtests_filter + \
['boot-serial-test']
['boot-serial-test', 'numa-test']
qtests_m68k = ['boot-serial-test'] + \
qtests_filter

View File

@ -265,6 +265,54 @@ static void aarch64_numa_cpu(const void *data)
qtest_quit(qts);
}
static void loongarch64_numa_cpu(const void *data)
{
QDict *resp;
QList *cpus;
QObject *e;
QTestState *qts;
g_autofree char *cli = NULL;
cli = make_cli(data, "-machine "
"smp.cpus=2,smp.sockets=2,smp.cores=1,smp.threads=1 "
"-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
"-numa cpu,node-id=0,socket-id=1,core-id=0,thread-id=0 "
"-numa cpu,node-id=1,socket-id=0,core-id=0,thread-id=0");
qts = qtest_init(cli);
cpus = get_cpus(qts, &resp);
g_assert(cpus);
while ((e = qlist_pop(cpus))) {
QDict *cpu, *props;
int64_t socket, core, thread, node;
cpu = qobject_to(QDict, e);
g_assert(qdict_haskey(cpu, "props"));
props = qdict_get_qdict(cpu, "props");
g_assert(qdict_haskey(props, "node-id"));
node = qdict_get_int(props, "node-id");
g_assert(qdict_haskey(props, "socket-id"));
socket = qdict_get_int(props, "socket-id");
g_assert(qdict_haskey(props, "core-id"));
core = qdict_get_int(props, "core-id");
g_assert(qdict_haskey(props, "thread-id"));
thread = qdict_get_int(props, "thread-id");
if (socket == 0 && core == 0 && thread == 0) {
g_assert_cmpint(node, ==, 1);
} else if (socket == 1 && core == 0 && thread == 0) {
g_assert_cmpint(node, ==, 0);
} else {
g_assert(false);
}
qobject_unref(e);
}
qobject_unref(resp);
qtest_quit(qts);
}
static void pc_dynamic_cpu_cfg(const void *data)
{
QObject *e;
@ -593,6 +641,11 @@ int main(int argc, char **argv)
aarch64_numa_cpu);
}
if (!strcmp(arch, "loongarch64")) {
qtest_add_data_func("/numa/loongarch64/cpu/explicit", args,
loongarch64_numa_cpu);
}
out:
return g_test_run();
}