2 * NUMA configuration test cases
4 * Copyright (c) 2017 Red Hat Inc.
6 * Igor Mammedov <imammedo@redhat.com>
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.
12 #include "qemu/osdep.h"
15 static char *make_cli(const char *generic_cli
, const char *test_cli
)
17 return g_strdup_printf("%s %s", generic_cli
? generic_cli
: "", test_cli
);
20 static char *hmp_info_numa(void)
25 resp
= qmp("{ 'execute': 'human-monitor-command', 'arguments': "
26 "{ 'command-line': 'info numa '} }");
28 g_assert(qdict_haskey(resp
, "return"));
29 s
= g_strdup(qdict_get_str(resp
, "return"));
35 static void test_mon_explicit(const void *data
)
40 cli
= make_cli(data
, "-smp 8 "
41 "-numa node,nodeid=0,cpus=0-3 "
42 "-numa node,nodeid=1,cpus=4-7 ");
46 g_assert(strstr(s
, "node 0 cpus: 0 1 2 3"));
47 g_assert(strstr(s
, "node 1 cpus: 4 5 6 7"));
54 static void test_mon_default(const void *data
)
59 cli
= make_cli(data
, "-smp 8 -numa node -numa node");
63 g_assert(strstr(s
, "node 0 cpus: 0 2 4 6"));
64 g_assert(strstr(s
, "node 1 cpus: 1 3 5 7"));
71 static void test_mon_partial(const void *data
)
76 cli
= make_cli(data
, "-smp 8 "
77 "-numa node,nodeid=0,cpus=0-1 "
78 "-numa node,nodeid=1,cpus=4-5 ");
82 g_assert(strstr(s
, "node 0 cpus: 0 1 2 3 6 7"));
83 g_assert(strstr(s
, "node 1 cpus: 4 5"));
90 int main(int argc
, char **argv
)
92 const char *args
= NULL
;
93 const char *arch
= qtest_get_arch();
95 if (strcmp(arch
, "aarch64") == 0) {
96 args
= "-machine virt";
99 g_test_init(&argc
, &argv
, NULL
);
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
);