From nobody Mon Oct 27 18:31:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516297072847158.40682198189006; Thu, 18 Jan 2018 09:37:52 -0800 (PST) Received: from localhost ([::1]:43774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecE8O-0005fI-1W for importer@patchew.org; Thu, 18 Jan 2018 12:37:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecE6T-0004LI-4I for qemu-devel@nongnu.org; Thu, 18 Jan 2018 12:35:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecE6S-0007uR-4p for qemu-devel@nongnu.org; Thu, 18 Jan 2018 12:35:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecE6O-0007qb-Ch; Thu, 18 Jan 2018 12:35:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 700DF3C37; Thu, 18 Jan 2018 17:35:47 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 069F578E7D; Thu, 18 Jan 2018 17:35:45 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 18 Jan 2018 18:33:58 +0100 Message-Id: <1516296842-136976-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1516296842-136976-1-git-send-email-imammedo@redhat.com> References: <1516296842-136976-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 18 Jan 2018 17:35:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 1/5] tests: add machine 'none' with -cpu test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Laurent Vivier , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Check that "$QEMU -M none -cpu FOO" starts QEMU without error Signed-off-by: Igor Mammedov --- tests/Makefile.include | 2 ++ tests/machine-none.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 73 insertions(+) create mode 100644 tests/machine-none.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 8883274..6661149 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -380,6 +380,7 @@ check-qtest-s390x-y +=3D tests/virtio-balloon-test$(EXE= SUF) check-qtest-s390x-y +=3D tests/virtio-console-test$(EXESUF) check-qtest-s390x-y +=3D tests/virtio-serial-test$(EXESUF) =20 +check-qtest-generic-y +=3D tests/machine-none$(EXESUF) check-qtest-generic-y +=3D tests/qom-test$(EXESUF) check-qtest-generic-y +=3D tests/test-hmp$(EXESUF) =20 @@ -782,6 +783,7 @@ tests/display-vga-test$(EXESUF): tests/display-vga-test= .o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/test-hmp$(EXESUF): tests/test-hmp.o +tests/machine-none$(EXESUF): tests/machine-none.o tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-= y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-ob= j-y) tests/nvme-test$(EXESUF): tests/nvme-test.o diff --git a/tests/machine-none.c b/tests/machine-none.c new file mode 100644 index 0000000..d16c283 --- /dev/null +++ b/tests/machine-none.c @@ -0,0 +1,71 @@ +/* + * Machine 'none' tests. + * + * Copyright (c) 2018 Red Hat Inc. + * + * Authors: + * Igor Mammedov , + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * 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/types.h" + +struct arch2cpu { + const char *arch; + const char *cpu_model; +}; + +static struct arch2cpu cpus_map[] =3D { + /* tested targets list */ +}; + +static const char *get_cpu_model_by_arch(const char *arch) +{ + int i; + + for (i =3D 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) +{ + char *args; + QDict *response; + const char *arch =3D qtest_get_arch(); + const char *cpu_model =3D get_cpu_model_by_arch(arch); + + if (!cpu_model) { + 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 */ + } + args =3D g_strdup_printf("-machine none -cpu %s", cpu_model); + qtest_start(args); + + response =3D qmp("{ 'execute': 'quit' }"); + g_assert(qdict_haskey(response, "return")); + QDECREF(response); + + qtest_end(); + g_free(args); +} + +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(); +} --=20 2.7.4