2018-02-07 13:40:24 +03:00
|
|
|
/*
|
|
|
|
* Machine 'none' tests.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Igor Mammedov <imammedo@redhat.com>,
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
|
|
|
|
#include "qemu/cutils.h"
|
2022-03-30 12:39:05 +03:00
|
|
|
#include "libqtest.h"
|
2018-02-07 13:40:24 +03:00
|
|
|
#include "qapi/qmp/qdict.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct arch2cpu {
|
|
|
|
const char *arch;
|
|
|
|
const char *cpu_model;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct arch2cpu cpus_map[] = {
|
|
|
|
/* tested targets list */
|
|
|
|
{ "arm", "cortex-a15" },
|
|
|
|
{ "aarch64", "cortex-a57" },
|
2020-01-24 03:51:22 +03:00
|
|
|
{ "avr", "avr6-avr-cpu" },
|
2018-02-07 13:40:24 +03:00
|
|
|
{ "x86_64", "qemu64,apic-id=0" },
|
|
|
|
{ "i386", "qemu32,apic-id=0" },
|
|
|
|
{ "alpha", "ev67" },
|
|
|
|
{ "m68k", "m5206" },
|
2020-04-16 22:33:03 +03:00
|
|
|
{ "microblaze", "any" },
|
|
|
|
{ "microblazeel", "any" },
|
2018-02-07 13:40:24 +03:00
|
|
|
{ "mips", "4Kc" },
|
2019-07-01 17:01:43 +03:00
|
|
|
{ "mipsel", "I7200" },
|
2018-02-07 13:40:24 +03:00
|
|
|
{ "mips64", "20Kc" },
|
2019-07-01 17:01:43 +03:00
|
|
|
{ "mips64el", "I6500" },
|
2018-02-07 13:40:24 +03:00
|
|
|
{ "or1k", "or1200" },
|
|
|
|
{ "ppc", "604" },
|
|
|
|
{ "ppc64", "power8e_v2.1" },
|
|
|
|
{ "s390x", "qemu" },
|
|
|
|
{ "sh4", "sh7750r" },
|
2024-10-24 11:27:34 +03:00
|
|
|
{ "sh4eb", "sh7751r" },
|
2018-02-07 13:40:24 +03:00
|
|
|
{ "sparc", "LEON2" },
|
|
|
|
{ "sparc64", "Fujitsu Sparc64" },
|
|
|
|
{ "tricore", "tc1796" },
|
|
|
|
{ "xtensa", "dc233c" },
|
|
|
|
{ "xtensaeb", "fsf" },
|
|
|
|
{ "hppa", "hppa" },
|
2020-05-06 23:03:25 +03:00
|
|
|
{ "riscv64", "rv64" },
|
|
|
|
{ "riscv32", "rv32" },
|
2019-01-21 16:18:59 +03:00
|
|
|
{ "rx", "rx62n" },
|
2022-07-13 05:02:58 +03:00
|
|
|
{ "loongarch64", "la464"},
|
2018-02-07 13:40:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *get_cpu_model_by_arch(const char *arch)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(cpus_map); i++) {
|
|
|
|
if (!strcmp(arch, cpus_map[i].arch)) {
|
|
|
|
return cpus_map[i].cpu_model;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_machine_cpu_cli(void)
|
|
|
|
{
|
|
|
|
QDict *response;
|
|
|
|
const char *arch = qtest_get_arch();
|
|
|
|
const char *cpu_model = get_cpu_model_by_arch(arch);
|
2018-11-13 23:11:13 +03:00
|
|
|
QTestState *qts;
|
2018-02-07 13:40:24 +03:00
|
|
|
|
|
|
|
if (!cpu_model) {
|
2020-04-16 22:33:03 +03:00
|
|
|
fprintf(stderr, "WARNING: cpu name for target '%s' isn't defined,"
|
|
|
|
" add it to cpus_map\n", arch);
|
2018-02-07 13:40:24 +03:00
|
|
|
return; /* TODO: die here to force all targets have a test */
|
|
|
|
}
|
2022-08-24 12:40:14 +03:00
|
|
|
qts = qtest_initf("-machine none -cpu \"%s\"", cpu_model);
|
2018-02-07 13:40:24 +03:00
|
|
|
|
2018-11-13 23:11:13 +03:00
|
|
|
response = qtest_qmp(qts, "{ 'execute': 'quit' }");
|
2018-02-07 13:40:24 +03:00
|
|
|
g_assert(qdict_haskey(response, "return"));
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(response);
|
2018-02-07 13:40:24 +03:00
|
|
|
|
2018-11-13 23:11:13 +03:00
|
|
|
qtest_quit(qts);
|
2018-02-07 13:40:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
|
|
|
|
qtest_add_func("machine/none/cpu_option", test_machine_cpu_cli);
|
|
|
|
|
|
|
|
return g_test_run();
|
|
|
|
}
|