]> git.proxmox.com Git - mirror_qemu.git/blame - tests/numa-test.c
QMP: include CpuInstanceProperties into query_cpus output output
[mirror_qemu.git] / tests / numa-test.c
CommitLineData
63baf8bf
IM
1/*
2 * NUMA configuration test cases
3 *
4 * Copyright (c) 2017 Red Hat Inc.
5 * Authors:
6 * Igor Mammedov <imammedo@redhat.com>
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.
9 * See the COPYING file in the top-level directory.
10 */
11
12#include "qemu/osdep.h"
13#include "libqtest.h"
14
15static char *make_cli(const char *generic_cli, const char *test_cli)
16{
17 return g_strdup_printf("%s %s", generic_cli ? generic_cli : "", test_cli);
18}
19
20static char *hmp_info_numa(void)
21{
22 QDict *resp;
23 char *s;
24
25 resp = qmp("{ 'execute': 'human-monitor-command', 'arguments': "
26 "{ 'command-line': 'info numa '} }");
27 g_assert(resp);
28 g_assert(qdict_haskey(resp, "return"));
29 s = g_strdup(qdict_get_str(resp, "return"));
30 g_assert(s);
31 QDECREF(resp);
32 return s;
33}
34
35static void test_mon_explicit(const void *data)
36{
37 char *s;
38 char *cli;
39
40 cli = make_cli(data, "-smp 8 "
41 "-numa node,nodeid=0,cpus=0-3 "
42 "-numa node,nodeid=1,cpus=4-7 ");
43 qtest_start(cli);
44
45 s = hmp_info_numa();
46 g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
47 g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
48 g_free(s);
49
50 qtest_end();
51 g_free(cli);
52}
53
54static void test_mon_default(const void *data)
55{
56 char *s;
57 char *cli;
58
59 cli = make_cli(data, "-smp 8 -numa node -numa node");
60 qtest_start(cli);
61
62 s = hmp_info_numa();
63 g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
64 g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
65 g_free(s);
66
67 qtest_end();
68 g_free(cli);
69}
70
71static void test_mon_partial(const void *data)
72{
73 char *s;
74 char *cli;
75
76 cli = make_cli(data, "-smp 8 "
77 "-numa node,nodeid=0,cpus=0-1 "
78 "-numa node,nodeid=1,cpus=4-5 ");
79 qtest_start(cli);
80
81 s = hmp_info_numa();
82 g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
83 g_assert(strstr(s, "node 1 cpus: 4 5"));
84 g_free(s);
85
86 qtest_end();
87 g_free(cli);
88}
89
90int main(int argc, char **argv)
91{
92 const char *args = NULL;
93 const char *arch = qtest_get_arch();
94
95 if (strcmp(arch, "aarch64") == 0) {
96 args = "-machine virt";
97 }
98
99 g_test_init(&argc, &argv, NULL);
100
101 qtest_add_data_func("/numa/mon/default", args, test_mon_default);
102 qtest_add_data_func("/numa/mon/cpus/explicit", args, test_mon_explicit);
103 qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial);
104
105 return g_test_run();
106}