diff mbox series

tests/qtest: Add numa test for loongarch system

Message ID 20240528082155.938586-1-maobibo@loongson.cn (mailing list archive)
State New, archived
Headers show
Series tests/qtest: Add numa test for loongarch system | expand

Commit Message

Bibo Mao May 28, 2024, 8:21 a.m. UTC
Add numa test case for loongarch system, it passes to run
with command "make check-qtest".

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 tests/qtest/meson.build |  2 +-
 tests/qtest/numa-test.c | 53 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

Comments

Thomas Huth May 29, 2024, 7:17 a.m. UTC | #1
On 28/05/2024 10.21, Bibo Mao wrote:
> Add numa test case for loongarch system, it passes to run
> with command "make check-qtest".
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   tests/qtest/meson.build |  2 +-
>   tests/qtest/numa-test.c | 53 +++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 54 insertions(+), 1 deletion(-)


Acked-by: Thomas Huth <thuth@redhat.com>

I assume this will also go through the loongarch tree? Let me know if you 
want to have this merged via the qtest tree instead.
gaosong May 31, 2024, 9:58 a.m. UTC | #2
在 2024/5/28 下午4:21, Bibo Mao 写道:
> Add numa test case for loongarch system, it passes to run
> with command "make check-qtest".
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   tests/qtest/meson.build |  2 +-
>   tests/qtest/numa-test.c | 53 +++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 54 insertions(+), 1 deletion(-)

Tested-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index b98fae6a6d..12792948ff 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -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
> diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
> index 7aa262dbb9..5518f6596b 100644
> --- a/tests/qtest/numa-test.c
> +++ b/tests/qtest/numa-test.c
> @@ -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();
>   }
diff mbox series

Patch

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index b98fae6a6d..12792948ff 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -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
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
index 7aa262dbb9..5518f6596b 100644
--- a/tests/qtest/numa-test.c
+++ b/tests/qtest/numa-test.c
@@ -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();
 }