From patchwork Thu Jan 29 14:22:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5742761 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8D9C1BF440 for ; Thu, 29 Jan 2015 14:22:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC4D62017D for ; Thu, 29 Jan 2015 14:22:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CA8D220142 for ; Thu, 29 Jan 2015 14:22:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F5BC720A9; Thu, 29 Jan 2015 06:22:37 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A130720A2 for ; Thu, 29 Jan 2015 06:22:33 -0800 (PST) Received: by mail-wi0-f179.google.com with SMTP id l15so25195073wiw.0 for ; Thu, 29 Jan 2015 06:22:32 -0800 (PST) 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=LTZ92Vi7A3MMnIkA1Yk5M+MBjdvXyyHEChNAOrlR0Uc=; b=V+Z49FsjywPMJU0+dzL4lli1zkZ0OeVkHVwtbFdJfmrCrM//1P9jmWe370LUnDHr30 1wyOmlMHmpoiXhElYnSxMKB2uSg0w1aOnEvM0phSY5Ya5NNw6r6NtKLW3YcQcp1ezKKZ 6DvDYhEyfxnIRpEf+K2DIeOhj7GoRJUjVRym+OGJSaqJ59iq7JaMBokDKrN71Kftorpn lXcp7P9vmysxI8BvBgkYA5AXz1Zul2ChgGvoJhmF/ErGvqJFIHagIwPYNKLJ7DuKYHFQ gwlxlzPBSfvImBvhzD0+ShWLG5LA6zGO8EQEQAJFh97UyWCbyrtHgFJwTR2+Vsr1AeY5 8xRA== X-Gm-Message-State: ALoCoQnNP/TLu9byEIV6vxLvMr/4XGoKR60ED0XNJpx7KUOdlA9qiHfIwAqbg9RYyN9SCAkSefVS X-Received: by 10.180.21.206 with SMTP id x14mr547453wie.64.1422541352428; Thu, 29 Jan 2015 06:22:32 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id fm10sm2704586wib.7.2015.01.29.06.22.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jan 2015 06:22:31 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Thu, 29 Jan 2015 14:22:27 +0000 Message-Id: <1422541347-584-3-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422541347-584-1-git-send-email-thomas.wood@intel.com> References: <1422541347-584-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/2] lib: print recent log messages to stderr when a test or subtest fails 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, T_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 Signed-off-by: Thomas Wood --- lib/igt_core.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index b03b7df..596ab77 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -236,6 +236,9 @@ enum { OPT_HELP = 'h' }; +static int igt_exitcode = IGT_EXIT_SUCCESS; +static const char *command_str; + static char* igt_log_domain_filter; static struct { char *entries[256]; @@ -265,7 +268,39 @@ static void _igt_log_buffer_reset(void) pthread_mutex_unlock(&log_buffer_mutex); } +static void _igt_log_buffer_dump(void) +{ + uint8_t i; + + if (in_subtest) + fprintf(stderr, "Subtest %s failed.\n", in_subtest); + else + fprintf(stderr, "Test %s failed.\n", command_str); + + if (log_buffer.start == log_buffer.end) { + fprintf(stderr, "No log.\n"); + return; + } + + pthread_mutex_lock(&log_buffer_mutex); + fprintf(stderr, "Log Start\n"); + + i = log_buffer.start; + do { + char *last_line = log_buffer.entries[i]; + fprintf(stderr, "%s%s", last_line, + (last_line[strlen(last_line)-1] != '\n') ? "\n" : ""); + i++; + } while (i != log_buffer.start && i != log_buffer.end); + + /* reset the buffer */ + log_buffer.start = log_buffer.end = 0; + + pthread_mutex_unlock(&log_buffer_mutex); + + fprintf(stderr, "Log End\n"); +} __attribute__((format(printf, 1, 2))) static void kmsg(const char *format, ...) @@ -422,8 +457,6 @@ static void print_version(void) uts.sysname, uts.release, uts.machine); } -static const char *command_str; - static void print_usage(const char *help_str, bool output_on_stderr) { FILE *f = output_on_stderr ? stderr : stdout; @@ -777,7 +810,6 @@ bool igt_only_list_subtests(void) static bool skipped_one = false; static bool succeeded_one = false; static bool failed_one = false; -static int igt_exitcode = IGT_EXIT_SUCCESS; static void exit_subtest(const char *) __attribute__((noreturn)); static void exit_subtest(const char *result) @@ -910,6 +942,8 @@ void igt_fail(int exitcode) if (test_child) exit(exitcode); + _igt_log_buffer_dump(); + if (in_subtest) { if (exitcode == IGT_EXIT_TIMEOUT) exit_subtest("TIMEOUT");