From patchwork Fri Jan 17 22:56:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jeff.mcgee@intel.com X-Patchwork-Id: 3507571 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 3FEB09F2E9 for ; Fri, 17 Jan 2014 22:49:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 766932018B for ; Fri, 17 Jan 2014 22:49:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9902F2017E for ; Fri, 17 Jan 2014 22:49:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8035FBF6A; Fri, 17 Jan 2014 14:49:50 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id EF487FBF2E for ; Fri, 17 Jan 2014 14:49:39 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 17 Jan 2014 14:49:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,676,1384329600"; d="scan'208";a="460716977" Received: from jeffdesk.fso.intel.com ([10.5.53.1]) by fmsmga001.fm.intel.com with ESMTP; 17 Jan 2014 14:49:36 -0800 From: jeff.mcgee@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 17 Jan 2014 16:56:06 -0600 Message-Id: <1389999366-19715-4-git-send-email-jeff.mcgee@intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389999366-19715-1-git-send-email-jeff.mcgee@intel.com> References: <1389999366-19715-1-git-send-email-jeff.mcgee@intel.com> Subject: [Intel-gfx] [PATCH 3/3] pm_rps: Fix verbose option and streamline its use X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.5 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 From: Jeff McGee Signed-off-by: Jeff McGee --- tests/pm_rps.c | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/tests/pm_rps.c b/tests/pm_rps.c index 4d64f0a..192dca7 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "drmtest.h" static bool verbose = false; @@ -130,6 +131,8 @@ static void dumpit(void) printf("\n"); } +#define dump() if (verbose) dumpit() +#define log(...) if (verbose) printf(__VA_ARGS__) static void pm_rps_exit_handler(int sig) { @@ -142,8 +145,40 @@ static void pm_rps_exit_handler(int sig) } } -igt_main +static int opt_handler(int opt, int opt_index) { + switch (opt) { + case 'v': + verbose = true; + break; + default: + assert(0); + } + + return 0; +} + +/* Mod of igt_subtest_init that adds our extra options */ +void subtest_init(int argc, char **argv) +{ + struct option long_opts[] = { + {"verbose", 0, 0, 'v'} + }; + const char *help_str = " -v, --verbose"; + int ret; + + ret = igt_subtest_init_parse_opts(argc, argv, "v", long_opts, + help_str, opt_handler); + + if (ret < 0) + /* exit with no error for -h/--help */ + exit(ret == -1 ? 0 : ret); +} + +int main(int argc, char **argv) +{ + subtest_init(argc, argv); + igt_skip_on_simulation(); igt_fixture { @@ -176,21 +211,16 @@ igt_main } igt_subtest("min-max-config-at-idle") { - if (verbose) - printf("Original min = %d\nOriginal max = %d\n", - origmin, origmax); + log("Original min = %d\nOriginal max = %d\n", origmin, origmax); - if (verbose) - dumpit(); + dump(); checkit(); setfreq(origmin); - if (verbose) - dumpit(); + dump(); igt_assert(fcur == fmin); setfreq(origmax); - if (verbose) - dumpit(); + dump(); igt_assert(fcur == fmax); checkit(); @@ -209,4 +239,6 @@ igt_main writeval(stuff[MIN].filp, origmin); writeval(stuff[MAX].filp, origmax); } + + igt_exit(); }