From patchwork Mon May 29 12:08:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9753141 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 F2D8660249 for ; Mon, 29 May 2017 12:10:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BF1E23B24 for ; Mon, 29 May 2017 12:10:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00DBE23F88; Mon, 29 May 2017 12:10:14 +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 B357B23B24 for ; Mon, 29 May 2017 12:10:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AAB9A89B4D; Mon, 29 May 2017 12:10:11 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80D0389B20 for ; Mon, 29 May 2017 12:10:07 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2017 05:10:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.38,414,1491289200"; d="scan'208"; a="1154104054" Received: from skylake-nuc.fi.intel.com ([10.237.72.145]) by fmsmga001.fm.intel.com with ESMTP; 29 May 2017 05:10:06 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Mon, 29 May 2017 15:08:08 +0300 Message-Id: <1496059690-3308-2-git-send-email-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496059690-3308-1-git-send-email-abdiel.janulgue@linux.intel.com> References: <1496059690-3308-1-git-send-email-abdiel.janulgue@linux.intel.com> Subject: [Intel-gfx] [i-g-t PATCH v2 2/4] 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 --- 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 c2c8872..81d2039 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 c41aa1a..93f61d8 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; /**