public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [i-g-t PATCH 2/3] igt/igt_core: Provide an option to check for the log buffer contents
Date: Tue,  6 Jun 2017 11:54:13 +0300	[thread overview]
Message-ID: <1496739254-18898-2-git-send-email-abdiel.janulgue@linux.intel.com> (raw)
In-Reply-To: <1496739254-18898-1-git-send-email-abdiel.janulgue@linux.intel.com>

Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
 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;
 
 /**
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-06-06  8:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06  8:54 [i-g-t PATCH v3 1/3] lib/igt_core: Add igt_system helpers Abdiel Janulgue
2017-06-06  8:54 ` Abdiel Janulgue [this message]
2017-06-12 11:48   ` [i-g-t PATCH 2/3] igt/igt_core: Provide an option to check for the log buffer contents Arkadiusz Hiler
2017-06-06  8:54 ` [i-g-t PATCH v3 3/3] Convert shell script tests to C version Abdiel Janulgue
2017-06-12 11:14   ` Arkadiusz Hiler
2017-06-13 10:22     ` Abdiel Janulgue
2017-06-12 12:37 ` [i-g-t PATCH v3 1/3] lib/igt_core: Add igt_system helpers Arkadiusz Hiler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1496739254-18898-2-git-send-email-abdiel.janulgue@linux.intel.com \
    --to=abdiel.janulgue@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox