diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-01-13 13:06:49 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-01-13 13:06:49 +0000 |
commit | 981c9b88e674408a1579ca3aa8d42770e3b689de (patch) | |
tree | f08bbcff5d0f240f057b5eedbbd200040f420902 /tests/qtest/machine-none-test.c | |
parent | abd5f8bb9525d3ad6cdced2c9208ee0cf445d9e1 (diff) | |
parent | 22108f333d16cbfbd5808bb4f661c394b08fe698 (diff) | |
download | qemu-981c9b88e674408a1579ca3aa8d42770e3b689de.zip |
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-01-12' into staging
* Move qtests into a separate directory
* Build index.html for docs
# gpg: Signature made Sun 12 Jan 2020 11:21:41 GMT
# gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg: aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5
* remotes/huth-gitlab/tags/pull-request-2020-01-12:
docs: build an index page for the HTML docs
tests/libqos: Move the libqos files under tests/qtest/
tests/Makefile: Move qtest-related settings to a separate Makefile.include
test: Move qtests to a separate directory
tests/Makefile: Separate unit test dependencies from qtest dependencies
tests/Makefile: Remove 'tests/' and '$(EXESUF)' from the check-qtest variables
tests/ptimer: Remove unnecessary inclusion of libqtest.h
tests/Makefile: test-char does not need libqtest
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qtest/machine-none-test.c')
-rw-r--r-- | tests/qtest/machine-none-test.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/qtest/machine-none-test.c b/tests/qtest/machine-none-test.c new file mode 100644 index 0000000000..5953d31755 --- /dev/null +++ b/tests/qtest/machine-none-test.c @@ -0,0 +1,103 @@ +/* + * 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-common.h" +#include "qemu/cutils.h" +#include "libqtest.h" +#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" }, + { "x86_64", "qemu64,apic-id=0" }, + { "i386", "qemu32,apic-id=0" }, + { "alpha", "ev67" }, + { "cris", "crisv32" }, + { "lm32", "lm32-full" }, + { "m68k", "m5206" }, + /* FIXME: { "microblaze", "any" }, doesn't work with -M none -cpu any */ + /* FIXME: { "microblazeel", "any" }, doesn't work with -M none -cpu any */ + { "mips", "4Kc" }, + { "mipsel", "I7200" }, + { "mips64", "20Kc" }, + { "mips64el", "I6500" }, + { "moxie", "MoxieLite" }, + { "nios2", "FIXME" }, + { "or1k", "or1200" }, + { "ppc", "604" }, + { "ppc64", "power8e_v2.1" }, + { "s390x", "qemu" }, + { "sh4", "sh7750r" }, + { "sh4eb", "sh7751r" }, + { "sparc", "LEON2" }, + { "sparc64", "Fujitsu Sparc64" }, + { "tricore", "tc1796" }, + { "unicore32", "UniCore-II" }, + { "xtensa", "dc233c" }, + { "xtensaeb", "fsf" }, + { "hppa", "hppa" }, + { "riscv64", "rv64gcsu-v1.10.0" }, + { "riscv32", "rv32gcsu-v1.9.1" }, +}; + +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); + QTestState *qts; + + if (!cpu_model) { + if (!(!strcmp(arch, "microblaze") || !strcmp(arch, "microblazeel"))) { + fprintf(stderr, "WARNING: cpu name for target '%s' isn't defined," + " add it to cpus_map\n", arch); + } + return; /* TODO: die here to force all targets have a test */ + } + qts = qtest_initf("-machine none -cpu '%s'", cpu_model); + + response = qtest_qmp(qts, "{ 'execute': 'quit' }"); + g_assert(qdict_haskey(response, "return")); + qobject_unref(response); + + qtest_quit(qts); +} + +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(); +} |