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-common.h"
16 #include "qemu/cutils.h"
18 #include "qapi/qmp/qdict.h"
23 const char *cpu_model
;
26 static struct arch2cpu cpus_map
[] = {
27 /* tested targets list */
28 { "arm", "cortex-a15" },
29 { "aarch64", "cortex-a57" },
30 { "x86_64", "qemu64,apic-id=0" },
31 { "i386", "qemu32,apic-id=0" },
33 { "cris", "crisv32" },
34 { "lm32", "lm32-full" },
36 /* FIXME: { "microblaze", "any" }, doesn't work with -M none -cpu any */
37 /* FIXME: { "microblazeel", "any" }, doesn't work with -M none -cpu any */
41 { "mips64el", "20Kc" },
42 { "moxie", "MoxieLite" },
46 { "ppc64", "power8e_v2.1" },
47 { "ppcemb", "440epb" },
50 { "sh4eb", "sh7751r" },
52 { "sparc64", "Fujitsu Sparc64" },
53 { "tricore", "tc1796" },
54 { "unicore32", "UniCore-II" },
55 { "xtensa", "dc233c" },
56 { "xtensaeb", "fsf" },
58 { "riscv64", "rv64gcsu-v1.10.0" },
59 { "riscv32", "rv32gcsu-v1.9.1" },
62 static const char *get_cpu_model_by_arch(const char *arch
)
66 for (i
= 0; i
< ARRAY_SIZE(cpus_map
); i
++) {
67 if (!strcmp(arch
, cpus_map
[i
].arch
)) {
68 return cpus_map
[i
].cpu_model
;
74 static void test_machine_cpu_cli(void)
77 const char *arch
= qtest_get_arch();
78 const char *cpu_model
= get_cpu_model_by_arch(arch
);
81 if (!(!strcmp(arch
, "microblaze") || !strcmp(arch
, "microblazeel"))) {
82 fprintf(stderr
, "WARNING: cpu name for target '%s' isn't defined,"
83 " add it to cpus_map\n", arch
);
85 return; /* TODO: die here to force all targets have a test */
87 global_qtest
= qtest_initf("-machine none -cpu '%s'", cpu_model
);
89 response
= qmp("{ 'execute': 'quit' }");
90 g_assert(qdict_haskey(response
, "return"));
91 qobject_unref(response
);
93 qtest_quit(global_qtest
);
96 int main(int argc
, char **argv
)
98 g_test_init(&argc
, &argv
, NULL
);
100 qtest_add_func("machine/none/cpu_option", test_machine_cpu_cli
);