From patchwork Fri Apr 21 00:49:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 9691505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A1926038D for ; Fri, 21 Apr 2017 00:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BC022847C for ; Fri, 21 Apr 2017 00:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DA6C2847B; Fri, 21 Apr 2017 00:50:19 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 1B8D62847B for ; Fri, 21 Apr 2017 00:50:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033566AbdDUAuO (ORCPT ); Thu, 20 Apr 2017 20:50:14 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:36171 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S946602AbdDUAuK (ORCPT ); Thu, 20 Apr 2017 20:50:10 -0400 Received: by mail-io0-f175.google.com with SMTP id o22so104063570iod.3 for ; Thu, 20 Apr 2017 17:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7SJWLH0hx2OJxnFZPi2IYC8J1tJbU5YUhHPmUPlrwk4=; b=YOLJ6hq52gjfP9ViAECCKROsqEZzESMhMuLr1z2+qDzrvPgVgj52BcPNNmiZRNHehv PTJgGZb9aiPLS2mnic02k6Dizq+lNsyM/Gsdlejp+qV3ZfTcsLldnFgsjVdBdB/QDlSw XJ7KQSut3GYq6XnoD2pHa2hi/HM9/5Y6U3PIP/2tPJVizUVXakeQB3wPa+N99ORelVRH s2HDAXGL1Kxju2Am8jK91/cRZnNCMpvAQyQBfmjvmQvd3mvH3F3MxIAwO4BmR7YcvBAK kWG/jQiJSHthb+KgRTtplpQm07kHf6ZnAsCXwChTjkVb0R8YHzBOh0jxv4bh8pApszQ3 YXRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7SJWLH0hx2OJxnFZPi2IYC8J1tJbU5YUhHPmUPlrwk4=; b=P/m7EGK4dK63cIRgO7Q/IXo1zhj56S7FpGdy2xiK9Y8AZJGK95uRoEAFpMRAK2awh8 STLZ0CCzJGXHT3bkrCSE8fo++ShncfUrPxBC2E88w3XeLVhBBDW8Ze+d3zzaeBdfEUW5 2jzcCpLU4k/LlwpytXQ/vZpWwcusaWssgKbtRgfaotcQp7Pr7W2mp+QSy4U+lQbQZSkH J2dKB/44NE5+Qmrm8qcy4QqMxyNWw8EvSLTmS09XW1CCn0JgpHxSECYYMztCwECwE5gD x5JxJcg1UDJRqXS3O+KkoNtlLa9RNFpw4Yzi+YcQDBPRS0QP658IAeCxDQa9nLb0rOHH /nnw== X-Gm-Message-State: AN3rC/6XMWXi3Cj5YXlMggNSl0lVl70GSP6gXh4+iSf/NhmOkxtMF6aE PHMV0o7egKsTFb+r X-Received: by 10.99.2.9 with SMTP id 9mr7298623pgc.69.1492735809163; Thu, 20 Apr 2017 17:50:09 -0700 (PDT) Received: from dmatlack.sea.corp.google.com ([100.100.206.82]) by smtp.gmail.com with ESMTPSA id e13sm12466486pfb.30.2017.04.20.17.50.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 17:50:08 -0700 (PDT) From: David Matlack To: kvm@vger.kernel.org Cc: Peter Feiner , David Matlack Subject: [kvm-unit-tests PATCH 01/32] x86: add test filter to vmx.flat. Date: Thu, 20 Apr 2017 17:49:33 -0700 Message-Id: <20170421005004.137260-2-dmatlack@google.com> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog In-Reply-To: <20170421005004.137260-1-dmatlack@google.com> References: <20170421005004.137260-1-dmatlack@google.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Feiner The VMX nesting test has lots of test cases. Now a specific test case can be run by appending its name to the multiboot command line (i.e., under Qemu's: -append ) Signed-off-by: Peter Feiner Signed-off-by: David Matlack --- x86/vmx.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/x86/vmx.c b/x86/vmx.c index b0b69602bdae..202cfaaa822e 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -1158,9 +1158,37 @@ out: extern struct vmx_test vmx_tests[]; -int main(void) +/* Match name with wanted allowing underscores in place of spaces. */ +static bool test_name_wanted(const char *name, const char *wanted) +{ + const char *n; + const char *w; + + for (n = name, w = wanted; *n != '\0' && *w != '\0'; n++, w++) { + if (*n != *w && !(*n == ' ' && *w == '_')) + return false; + } + return *n == '\0' && *w == '\0'; +} + +static bool test_wanted(struct vmx_test *test, char *wanted[], int nwanted) +{ + int i; + + if (!nwanted) + return true; + + for (i = 0; i < nwanted; ++i) { + if (test_name_wanted(test->name, wanted[i])) + return true; + } + return false; +} + +int main(int argc, char *argv[]) { int i = 0; + int matched = 0; setup_vm(); setup_idt(); @@ -1188,9 +1216,16 @@ int main(void) test_vmxoff(); test_vmx_caps(); - while (vmx_tests[++i].name != NULL) + while (vmx_tests[++i].name != NULL) { + if (!test_wanted(&vmx_tests[i], argv + 1, argc - 1)) + continue; + matched++; if (test_run(&vmx_tests[i])) goto exit; + } + + if (!matched) + report("command line didn't match any tests!", matched); exit: return report_summary();