[Intel-gfx] [PATCH i-g-t 4/5] lib: clear log buffer after writing it out or starting a new subtest

Thomas Wood thomas.wood at intel.com
Wed Dec 17 08:45:46 PST 2014


Signed-off-by: Thomas Wood <thomas.wood at intel.com>
---
 lib/igt_core.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index b98cb41..925d78c 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -366,6 +366,23 @@ static void low_mem_killer_disable(bool disable)
 }
 
 #define write_log_msg(x) write(STDERR_FILENO, x, strlen(x))
+static void clear_log(void)
+{
+	uint8_t i;
+
+	pthread_mutex_lock(&log_buffer_mutex);
+
+	i = 0;
+	do {
+		free(log_buffer.entries[i]);
+		log_buffer.entries[i] = NULL;
+		i++;
+	} while (i != 0);
+	log_buffer.start = 0;
+	log_buffer.end = 0;
+
+	pthread_mutex_unlock(&log_buffer_mutex);
+}
 
 /* this function must be safe to be called inside a signal handler */
 static void write_log(void)
@@ -409,6 +426,8 @@ static void write_log(void)
 	write_log_msg("--- Log End\n");
 
 	pthread_mutex_unlock(&log_buffer_mutex);
+
+	clear_log();
 }
 
 bool igt_exit_called;
@@ -761,6 +780,8 @@ bool __igt_run_subtest(const char *subtest_name)
 		return false;
 	}
 
+	clear_log();
+
 	kmsg(KERN_INFO "%s: starting subtest %s\n", command_str, subtest_name);
 
 	gettime(&subtest_time);
-- 
2.1.0



More information about the Intel-gfx mailing list