diff mbox

[i-g-t] lib: add a function to indicate activity

Message ID 1412094070-24355-1-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood Sept. 30, 2014, 4:21 p.m. UTC
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt_aux.c              | 15 +++++++++++++++
 lib/igt_aux.h              |  1 +
 tests/kms_cursor_crc.c     |  3 ++-
 tests/kms_fence_pin_leak.c |  4 ++--
 tests/kms_flip.c           |  2 +-
 5 files changed, 21 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index c0ea0e2..7c07b7d 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -246,6 +246,21 @@  void igt_progress(const char *header, uint64_t i, uint64_t total)
 			 (long long unsigned)i * 100 / total);
 }
 
+/**
+ * igt_print_activity:
+ *
+ * Print a '.' to indicate activity. This is printed without a newline and
+ * only if output is to a terminal.
+ */
+void igt_print_activity(void)
+{
+	if (!isatty(STDOUT_FILENO))
+		return;
+
+	igt_info(".");
+	fflush(stdout);
+}
+
 /* mappable aperture trasher helper */
 drm_intel_bo **trash_bos;
 int num_trash_bos;
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index d958abe..d74bb8c 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -41,6 +41,7 @@  void igt_permute_array(void *array, unsigned size,
 						 unsigned i,
 						 unsigned j));
 void igt_progress(const char *header, uint64_t i, uint64_t total);
+void igt_print_activity(void);
 bool igt_check_boolean_env_var(const char *env_var, bool default_value);
 
 bool igt_aub_dump_enabled(void);
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index c348d7a..c6f0fe4 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -32,6 +32,7 @@ 
 #include "igt_debugfs.h"
 #include "igt_kms.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 #ifndef DRM_CAP_CURSOR_WIDTH
 #define DRM_CAP_CURSOR_WIDTH 0x8
@@ -105,7 +106,7 @@  static void do_single_test(data_t *data, int x, int y)
 	igt_plane_t *cursor;
 	cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, &data->primary_fb);
 
-	igt_info("."); fflush(stdout);
+	igt_print_activity();
 
 	/* Hardware test */
 	igt_paint_test_pattern(cr, data->screenw, data->screenh);
diff --git a/tests/kms_fence_pin_leak.c b/tests/kms_fence_pin_leak.c
index 69f36b8..fe2a038 100644
--- a/tests/kms_fence_pin_leak.c
+++ b/tests/kms_fence_pin_leak.c
@@ -33,6 +33,7 @@ 
 #include "igt_kms.h"
 #include "ioctl_wrappers.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 typedef struct {
 	int drm_fd;
@@ -173,8 +174,7 @@  static bool run_single_test(data_t *data, enum pipe pipe, igt_output_t *output)
 		igt_plane_set_fb(primary, &fb[!(i&1)]);
 		igt_display_commit(display);
 
-		igt_info(".");
-		fflush(stdout);
+		igt_print_activity();
 	}
 
 	igt_plane_set_fb(primary, NULL);
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 3d3aa9b..adf5a28 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -885,7 +885,7 @@  static unsigned int run_test_step(struct test_output *o)
 		join_vblank_wait_thread();
 	}
 
-	igt_info("."); fflush(stdout);
+	igt_print_activity();
 
 	if (do_flip && (o->flags & TEST_HANG)) {
 		hang = hang_gpu(drm_fd);