From patchwork Mon Nov 9 17:17:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 7585631 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 31CF79F1AF for ; Mon, 9 Nov 2015 17:27:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 536EF2064E for ; Mon, 9 Nov 2015 17:27:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 64C812060F for ; Mon, 9 Nov 2015 17:27:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 607146E5F1; Mon, 9 Nov 2015 09:27:50 -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 425286E5F1 for ; Mon, 9 Nov 2015 09:27:49 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 09 Nov 2015 09:27:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,266,1444719600"; d="scan'208";a="681534867" Received: from otc-vmt1.isw.intel.com ([10.237.224.80]) by orsmga003.jf.intel.com with ESMTP; 09 Nov 2015 09:27:38 -0800 From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Mon, 9 Nov 2015 17:17:13 +0000 Message-Id: <1447089433-10749-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <2D016F5BA44C744783BA96B1D3EBC5BD13EAE994@IRSMSX102.ger.corp.intel.com> References: <2D016F5BA44C744783BA96B1D3EBC5BD13EAE994@IRSMSX102.ger.corp.intel.com> Organization: Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ Subject: [Intel-gfx] [PATCH i-g-t] lib: add a environment variable to control output 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.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 Disable output of terminal control characters and progress meters when IGT_PLAIN_OUTPUT is set in the environment. Cc: Derek Morton Signed-off-by: Thomas Wood --- lib/igt_aux.c | 2 +- lib/igt_core.c | 23 ++++++++++++++--------- lib/igt_core.h | 2 ++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index f3c76ae..4d08d68 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -231,7 +231,7 @@ static void igt_interactive_info(const char *format, ...) { va_list args; - if (!isatty(STDERR_FILENO)) + if (!isatty(STDERR_FILENO) || __igt_plain_output) return; if (igt_log_level > IGT_LOG_INFO) diff --git a/lib/igt_core.c b/lib/igt_core.c index 7123455..ea9a68b 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -227,6 +227,8 @@ static enum { CONT = 0, SKIP, FAIL } skip_subtests_henceforth = CONT; +bool __igt_plain_output = false; + /* fork support state */ pid_t *test_children; int num_test_children; @@ -523,11 +525,15 @@ static int common_init(int *argc, char **argv, int extra_opt_count; int all_opt_count; int ret = 0; - char *env = getenv("IGT_LOG_LEVEL"); + const char *env; + + if (!isatty(STDOUT_FILENO) || getenv("IGT_PLAIN_OUTPUT")) + __igt_plain_output = true; - if (isatty(STDOUT_FILENO)) + if (!__igt_plain_output) setlocale(LC_ALL, ""); + env = getenv("IGT_LOG_LEVEL"); if (env) { if (strcmp(env, "debug") == 0) igt_log_level = IGT_LOG_DEBUG; @@ -779,12 +785,10 @@ bool __igt_run_subtest(const char *subtest_name) } if (skip_subtests_henceforth) { - bool istty = isatty(STDOUT_FILENO); - printf("%sSubtest %s: %s%s\n", - (istty) ? "\x1b[1m" : "", subtest_name, + (!__igt_plain_output) ? "\x1b[1m" : "", subtest_name, skip_subtests_henceforth == SKIP ? - "SKIP" : "FAIL", (istty) ? "\x1b[0m" : ""); + "SKIP" : "FAIL", (!__igt_plain_output) ? "\x1b[0m" : ""); return false; } @@ -828,14 +832,15 @@ static void exit_subtest(const char *result) { struct timespec now; double elapsed; - bool istty = isatty(STDOUT_FILENO); gettime(&now); elapsed = now.tv_sec - subtest_time.tv_sec; elapsed += (now.tv_nsec - subtest_time.tv_nsec) * 1e-9; - printf("%sSubtest %s: %s (%.3fs)%s\n", (istty) ? "\x1b[1m" : "", - in_subtest, result, elapsed, (istty) ? "\x1b[0m" : ""); + printf("%sSubtest %s: %s (%.3fs)%s\n", + (!__igt_plain_output) ? "\x1b[1m" : "", + in_subtest, result, elapsed, + (!__igt_plain_output) ? "\x1b[0m" : ""); fflush(stdout); in_subtest = NULL; diff --git a/lib/igt_core.h b/lib/igt_core.h index 5ae0965..a244fc3 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -45,6 +45,8 @@ extern const char* __igt_test_description __attribute__((weak)); +extern bool __igt_plain_output; + /** * IGT_TEST_DESCRIPTION: