2 * Machine 'none' tests.
4 * Copyright (c) 2018 Red Hat Inc.
7 * Igor Mammedov <imammedo@redhat.com>,
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
15 #include "qemu/cutils.h"
17 #include "qapi/qmp/qdict.h"
22 const char *cpu_model
;
25 static struct arch2cpu cpus_map
[] = {
26 /* tested targets list */
27 { "arm", "cortex-a15" },
28 { "aarch64", "cortex-a57" },
29 { "avr", "avr6-avr-cpu" },
30 { "x86_64", "qemu64,apic-id=0" },
31 { "i386", "qemu32,apic-id=0" },
33 { "cris", "crisv32" },
35 { "microblaze", "any" },
36 { "microblazeel", "any" },
38 { "mipsel", "I7200" },
40 { "mips64el", "I6500" },
44 { "ppc64", "power8e_v2.1" },
47 { "sh4eb", "sh7751r" },
49 { "sparc64", "Fujitsu Sparc64" },
50 { "tricore", "tc1796" },
51 { "xtensa", "dc233c" },
52 { "xtensaeb", "fsf" },
54 { "riscv64", "rv64" },
55 { "riscv32", "rv32" },
57 { "loongarch64", "la464"},
60 static const char *get_cpu_model_by_arch(const char *arch
)
64 for (i
= 0; i
< ARRAY_SIZE(cpus_map
); i
++) {
65 if (!strcmp(arch
, cpus_map
[i
].arch
)) {
66 return cpus_map
[i
].cpu_model
;
72 static void test_machine_cpu_cli(void)
75 const char *arch
= qtest_get_arch();
76 const char *cpu_model
= get_cpu_model_by_arch(arch
);
80 fprintf(stderr
, "WARNING: cpu name for target '%s' isn't defined,"
81 " add it to cpus_map\n", arch
);
82 return; /* TODO: die here to force all targets have a test */
84 qts
= qtest_initf("-machine none -cpu \"%s\"", cpu_model
);
86 response
= qtest_qmp(qts
, "{ 'execute': 'quit' }");
87 g_assert(qdict_haskey(response
, "return"));
88 qobject_unref(response
);
93 int main(int argc
, char **argv
)
95 g_test_init(&argc
, &argv
, NULL
);
97 qtest_add_func("machine/none/cpu_option", test_machine_cpu_cli
);