From patchwork Wed Jan 27 10:05:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Morton X-Patchwork-Id: 8132011 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 89ABD9F1C0 for ; Wed, 27 Jan 2016 10:06:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A03CD20218 for ; Wed, 27 Jan 2016 10:06:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8E2322017E for ; Wed, 27 Jan 2016 10:06:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37F396E290; Wed, 27 Jan 2016 02:06:02 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EC7D6E290 for ; Wed, 27 Jan 2016 02:06:01 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 27 Jan 2016 02:06:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,354,1449561600"; d="scan'208";a="899216533" Received: from djmorton-linux2.isw.intel.com ([10.102.226.90]) by orsmga002.jf.intel.com with ESMTP; 27 Jan 2016 02:05:59 -0800 From: Derek Morton To: intel-gfx@lists.freedesktop.org Date: Wed, 27 Jan 2016 10:05:56 +0000 Message-Id: <1453889156-24489-1-git-send-email-derek.j.morton@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH i-g-t] lib/igt_core.c: Expand --run-subtest functionality. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added support for specifying arbitary lists of subtests to run or to exclude from being run by using : or ^ as a seperator. :subtest1:subtest2: Will run subtest1 and subtest2 ^subtest1^subtest2^ will run all subtests except subtest1 and subtest2 Any subtest string not starting : or ^ is treated as a normal wildcard expression. This is required mainly on android to exclude subtests that test features that do not exist in the android driver while still being able to run other subtests in the binary when a wildcard expression is insufficient. Signed-off-by: Derek Morton --- lib/igt_core.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 6b69bb7..b9e7470 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -207,7 +207,15 @@ * To do that obtain the lists of subtests with "--list-subtests", which can be * run as non-root and doesn't require the i915 driver to be loaded (or any * intel gpu to be present). Then individual subtests can be run with - * "--run-subtest". Usage help for tests with subtests can be obtained with the + * "--run-subtest". --run-subtest accepts wildcard characters. A list of + * subtests to run may be specified by using : as a seperator. A list of + * subtests to exclude may be specified using ^ as a seperator. + * + * - --run-subtest basic* will run all subtests starting basic. + * - --run-subtest :subtest1:subtest2: will run only subtest1 and subtest2 + * - --run-subtest ^subtest1^subtest2^ will run all except subtest1 and subtest2 + * + * Usage help for tests with subtests can be obtained with the * "--help" command line option. */ @@ -786,6 +794,35 @@ void igt_simple_init_parse_opts(int *argc, char **argv, extra_opt_handler, handler_data); } +static bool check_testlist(const char *subtest_name) +{ + char *p; + + /* Run subtests in list + * Look for subtest_name in list of form :subtest1:subtest2:subtest3: + * return true if found. + */ + if (run_single_subtest[0] == ':') { + p = strstr(run_single_subtest, subtest_name); + if ((p) && (*(p-1) == ':') && (*(p+strlen(subtest_name)) == ':' )) + return true; + } + /* Run subtests not in list + * Look for subtest_name in list of form ^test1^subtest2^subtest3^ + * return true if not found. + */ + else if (run_single_subtest[0] == '^') { + p = strstr(run_single_subtest, subtest_name); + if (!((p) && (*(p-1) == '^') && (*(p+strlen(subtest_name)) == '^' ))) + return true; + } + /* Run subtests that match shell wildcard */ + else if (fnmatch(run_single_subtest, subtest_name, 0) == 0) + return true; + + return false; +} + /* * Note: Testcases which use these helpers MUST NOT output anything to stdout * outside of places protected by igt_run_subtest checks - the piglit @@ -814,7 +851,8 @@ bool __igt_run_subtest(const char *subtest_name) } if (run_single_subtest) { - if (fnmatch(run_single_subtest, subtest_name, 0) != 0) + + if (check_testlist(subtest_name) == false) return false; else run_single_subtest_found = true;