From patchwork Thu Jan 24 11:16:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 10778759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 434DE13BF for ; Thu, 24 Jan 2019 11:17:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328E32E974 for ; Thu, 24 Jan 2019 11:17:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26D0E2EA87; Thu, 24 Jan 2019 11:17:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A52682E974 for ; Thu, 24 Jan 2019 11:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727719AbfAXLRK (ORCPT ); Thu, 24 Jan 2019 06:17:10 -0500 Received: from foss.arm.com ([217.140.101.70]:54822 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfAXLRI (ORCPT ); Thu, 24 Jan 2019 06:17:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 32D4D1650; Thu, 24 Jan 2019 03:17:08 -0800 (PST) Received: from login12.euhpc.arm.com (login12.euhpc.arm.com [10.6.27.168]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 240073F614; Thu, 24 Jan 2019 03:17:07 -0800 (PST) From: Alexandru Elisei To: kvm@vger.kernel.org Cc: drjones@redhat.com, kvmarm@lists.cs.columbia.edu, andre.przywara@arm.com, vladimir.murzin@arm.com Subject: [kvm-unit-tests PATCH 7/7] arm/arm64: Use argv_find() for test names Date: Thu, 24 Jan 2019 11:16:34 +0000 Message-Id: <20190124111634.4727-8-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190124111634.4727-1-alexandru.elisei@arm.com> References: <20190124111634.4727-1-alexandru.elisei@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of aborting the test when an unexpected parameter is found, use argv_find() to search for the desired parameter. On arm and arm64, this allows kvm-unit-tests to be used with virtual machine monitors like kvmtool which automatically adds parameters to the kernel command line. For example, to run the gicv3-ipi test the following command was used: lkvm run -k gic.flat -c 8 -m 410 -p "ipi" --irqchip=gicv3 The resulting kernel command line that was passed to kvm-unit-tests was: "console=ttyS0 rw rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p init=/virt/init ip=dhcp ipi" Without the patch, the following error occurs: "ABORT: gicv3: Unknown subtest 'console=ttyS0'" With the patch, the test is able to run. Signed-off-by: Alexandru Elisei --- arm/gic.c | 7 ++++--- arm/selftest.c | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arm/gic.c b/arm/gic.c index ed5642e74f70..f3746de4bfd8 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -12,6 +12,7 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include +#include #include #include #include @@ -533,13 +534,13 @@ int main(int argc, char **argv) if (argc < 2) report_abort("no test specified"); - if (strcmp(argv[1], "ipi") == 0) { + if (argv_find("ipi", argc, argv) != -1) { report_prefix_push(argv[1]); nr_cpu_check(2); on_cpus(ipi_test, NULL); - } else if (strcmp(argv[1], "active") == 0) { + } else if (argv_find("active", argc, argv) != -1) { run_active_clear_test(); - } else if (strcmp(argv[1], "mmio") == 0) { + } else if (argv_find("mmio", argc, argv) != -1) { report_prefix_push(argv[1]); gic_test_mmio(); report_prefix_pop(); diff --git a/arm/selftest.c b/arm/selftest.c index ea5101ef7217..44b2f23ca115 100644 --- a/arm/selftest.c +++ b/arm/selftest.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -319,28 +320,32 @@ static void cpu_report(void *data __unused) int main(int argc, char **argv) { + int pos; + report_prefix_push("selftest"); if (argc < 2) report_abort("no test specified"); - report_prefix_push(argv[1]); - - if (strcmp(argv[1], "setup") == 0) { + if ((pos = argv_find("setup", argc, argv)) != -1) { - check_setup(argc-2, &argv[2]); + report_prefix_push("setup"); + check_setup(argc-(pos+1), &argv[pos+1]); - } else if (strcmp(argv[1], "vectors-kernel") == 0) { + } else if (argv_find("vectors-kernel", argc, argv) != -1) { + report_prefix_push("vectors-kernel"); check_vectors(NULL); - } else if (strcmp(argv[1], "vectors-user") == 0) { + } else if (argv_find("vectors-user", argc, argv) != -1) { + report_prefix_push("vectors-user"); start_usr(check_vectors, NULL, (unsigned long)thread_stack_alloc()); - } else if (strcmp(argv[1], "smp") == 0) { + } else if (argv_find("smp", argc, argv) != -1) { + report_prefix_push("smp"); report("PSCI version", psci_check()); on_cpus(cpu_report, NULL);