From patchwork Tue Jun 6 08:54:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9768301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BED6B6035D for ; Tue, 6 Jun 2017 08:58:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B25B5204C1 for ; Tue, 6 Jun 2017 08:58:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A704226E78; Tue, 6 Jun 2017 08:58:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1890E26E78 for ; Tue, 6 Jun 2017 08:58:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FC726E0D1; Tue, 6 Jun 2017 08:58:26 +0000 (UTC) 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 ESMTPS id 141476E067 for ; Tue, 6 Jun 2017 08:58:25 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2017 01:58:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,305,1493708400"; d="scan'208";a="96063838" Received: from skylake-nuc.fi.intel.com ([10.237.72.145]) by orsmga002.jf.intel.com with ESMTP; 06 Jun 2017 01:58:24 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Tue, 6 Jun 2017 11:54:13 +0300 Message-Id: <1496739254-18898-2-git-send-email-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496739254-18898-1-git-send-email-abdiel.janulgue@linux.intel.com> References: <1496739254-18898-1-git-send-email-abdiel.janulgue@linux.intel.com> Subject: [Intel-gfx] [i-g-t PATCH 2/3] igt/igt_core: Provide an option to check for the log buffer contents 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-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Abdiel Janulgue Reviewed-by: Arkadiusz Hiler --- lib/igt_core.c | 24 ++++++++++++++++++++++++ lib/igt_core.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/lib/igt_core.c b/lib/igt_core.c index 26f7fc5..94f5529 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -329,6 +329,30 @@ static void _igt_log_buffer_dump(void) pthread_mutex_unlock(&log_buffer_mutex); } +/** + * igt_log_buffer_inspect: + * + * Provides a way to replay the internal igt log buffer for inspection. + * @check: A user-specified handler that gets invoked for each line of + the log buffer. The handler should return true to stop + inspecting the rest of the buffer. + * @data: passed as a user argument to the inspection function. + */ +void igt_log_buffer_inspect(igt_buffer_log_handler_t check, void *data) +{ + uint8_t i; + pthread_mutex_lock(&log_buffer_mutex); + + i = log_buffer.start; + do { + if (check(log_buffer.entries[i], data)) + break; + i++; + } while (i != log_buffer.start && i != log_buffer.end); + + pthread_mutex_unlock(&log_buffer_mutex); +} + __attribute__((format(printf, 1, 2))) static void kmsg(const char *format, ...) #define KERN_EMER "<0>" diff --git a/lib/igt_core.h b/lib/igt_core.h index 1855c5e..a2ed972 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -818,6 +818,9 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, */ #define igt_critical(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_CRITICAL, f) +typedef bool (*igt_buffer_log_handler_t)(const char *line, void *data); +void igt_log_buffer_inspect(igt_buffer_log_handler_t check, void *data); + extern enum igt_log_level igt_log_level; /**