From patchwork Thu Apr 20 08:13:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9689839 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 396C360326 for ; Thu, 20 Apr 2017 08:15:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A1452845C for ; Thu, 20 Apr 2017 08:15:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EDB628464; Thu, 20 Apr 2017 08:15:16 +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 D85FA2845C for ; Thu, 20 Apr 2017 08:15:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC2CC6E336; Thu, 20 Apr 2017 08:15:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 317FC6E0E0 for ; Thu, 20 Apr 2017 08:15:12 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 20 Apr 2017 01:15:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,225,1488873600"; d="scan'208";a="959064133" Received: from skylake-nuc.fi.intel.com ([10.237.72.145]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2017 01:15:11 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Thu, 20 Apr 2017 11:13:46 +0300 Message-Id: <1492676028-15372-2-git-send-email-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492676028-15372-1-git-send-email-abdiel.janulgue@linux.intel.com> References: <1492676028-15372-1-git-send-email-abdiel.janulgue@linux.intel.com> Subject: [Intel-gfx] [i-g-t PATCH 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 8a7ba0d..e80a32a 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 6d4cf60..3e0d3c3 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -817,6 +817,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; /**