From patchwork Thu Oct 30 16:48:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5198911 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 314309F349 for ; Thu, 30 Oct 2014 16:49:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60FDA2015D for ; Thu, 30 Oct 2014 16:49:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 35AD1201FE for ; Thu, 30 Oct 2014 16:49:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B4216E4FF; Thu, 30 Oct 2014 09:49:09 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 74D866E0AF for ; Thu, 30 Oct 2014 09:49:06 -0700 (PDT) Received: by mail-wi0-f182.google.com with SMTP id d1so7958495wiv.15 for ; Thu, 30 Oct 2014 09:49:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=OTXmPpPpFP2upEWmtiwVF7pJkHutWZ+Nmx+Y0ZG+hRE=; b=JGXdAjqsA/Vy4dBgg2eX5dpA2aHFW4u82MhjX76aH9805kefLDvfKDTQ9Ep5pEcPYm fonKwh+MEyVo7BAOCWS+ESTQEioOVFeAA/q1OvCmVfulQ7lDjWoypP3trlrcG5kOvW2l 9KTOkalgKD8vQLLIH6vBV/CxzrXz4L2NqUvIh7ujc0qqNbrS1M9cGGXrPx/aqlktxIM2 xwekz/iyLoJDmKZY/1VfguGNzWlJROB833wHyXhC9N+DEPh3+0zRMT+y+r9+RKreDY0u 9wP2nhku4knXOiaF3cccf6jH7tXlSaY8J4gryX5UAn8dNL6y4otVyvKSbeousA3XGCWh 6Q2g== X-Gm-Message-State: ALoCoQlEFjy2ogk+1Vl84pj29jowji1DevxrZNe5TeUEULCa5kqhA13Sq8s3yk7Rhuku2ZwEAGMQ X-Received: by 10.195.11.6 with SMTP id ee6mr1112886wjd.95.1414687745501; Thu, 30 Oct 2014 09:49:05 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id k10sm9264702wjb.28.2014.10.30.09.49.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Oct 2014 09:49:04 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Thu, 30 Oct 2014 16:48:56 +0000 Message-Id: <1414687741-7830-2-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1414687741-7830-1-git-send-email-thomas.wood@intel.com> References: <1414687741-7830-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t v2 1/6] lib: add the ability to include a description with a test 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.8 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 The IGT_TEST_DESCRIPTION macro can be used to define a description for a test. v2: Remove semicolon from end of macro (Damien Lespiau) Add API documentation for the macro. Signed-off-by: Thomas Wood --- lib/igt_core.c | 19 ++++++++++++++++--- lib/igt_core.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index e3d5fb0..3861121 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -223,6 +223,7 @@ bool test_child; enum { OPT_LIST_SUBTESTS, OPT_RUN_SUBTEST, + OPT_DESCRIPTION, OPT_DEBUG, OPT_HELP = 'h' }; @@ -360,6 +361,12 @@ static void common_exit_handler(int sig) assert(sig != 0 || igt_exit_called); } +static void print_test_description(void) +{ + if (&__igt_test_description) + printf("%s\n", __igt_test_description); +} + static void print_version(void) { struct utsname uts; @@ -380,11 +387,12 @@ static void print_usage(const char *help_str, bool output_on_stderr) { FILE *f = output_on_stderr ? stderr : stdout; - fprintf(f, "Usage: %s [OPTIONS]\n" - " --list-subtests\n" + fprintf(f, "Usage: %s [OPTIONS]\n", command_str); + fprintf(f, " --list-subtests\n" " --run-subtest \n" " --debug\n" - " --help\n", command_str); + " --help-description\n" + " --help\n"); if (help_str) fprintf(f, "%s\n", help_str); } @@ -413,6 +421,7 @@ static int common_init(int argc, char **argv, static struct option long_options[] = { {"list-subtests", 0, 0, OPT_LIST_SUBTESTS}, {"run-subtest", 1, 0, OPT_RUN_SUBTEST}, + {"help-description", 0, 0, OPT_DESCRIPTION}, {"debug", 0, 0, OPT_DEBUG}, {"help", 0, 0, OPT_HELP}, {0, 0, 0, 0} @@ -510,6 +519,10 @@ static int common_init(int argc, char **argv, if (!list_subtests) run_single_subtest = strdup(optarg); break; + case OPT_DESCRIPTION: + print_test_description(); + ret = -1; + goto out; case OPT_HELP: print_usage(help_str, false); ret = -1; diff --git a/lib/igt_core.h b/lib/igt_core.h index b8f6702..69e54d8 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -38,6 +38,18 @@ #include #include +extern const char* __igt_test_description __attribute__((weak)); + +/** + * IGT_TEST_DESCRIPTION: + * @str: description string + * + * Defines a description for a test. This is used as the output for the + * "--help-description" option and is also included in the generated + * documentation. + */ +#define IGT_TEST_DESCRIPTION(str) const char* __igt_test_description = str + /** * IGT_EXIT_TIMEOUT: *