[Intel-gfx] [PATCH 3/5] tests: dont polute stderr if the test succeeds/skips

Daniel Vetter daniel.vetter at ffwll.ch
Tue Nov 27 21:13:51 CET 2012


Results in spurious 'warn' results in piglit. Also don't print
progress indicators when not outputting to a terminal.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 lib/drmtest.c           | 3 +++
 tests/gem_cpu_reloc.c   | 2 +-
 tests/gem_cs_prefetch.c | 2 +-
 tests/gem_ctx_create.c  | 2 +-
 tests/sysfs_rps.c       | 2 +-
 5 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index c309851..a18b3a0 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -543,6 +543,9 @@ void drmtest_progress(const char *header, uint64_t i, uint64_t total)
 {
 	int divider = 200;
 
+	if (!isatty(fileno(stderr)))
+		return;
+
 	if (i+1 >= total) {
 		fprintf(stderr, "\r%s100%%\n", header);
 		return;
diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 787e507..baf8301 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -209,7 +209,7 @@ int main(int argc, char **argv)
 		drmtest_progress("gem_cpu_reloc: ", 2*count+i, 3*count);
 	}
 
-	fprintf(stderr, "Test suceeded, cleanup up - this might take a while.\n");
+	printf("Test suceeded, cleanup up - this might take a while.\n");
 	close(fd);
 
 	return 0;
diff --git a/tests/gem_cs_prefetch.c b/tests/gem_cs_prefetch.c
index 9ba8028..9ef35eb 100644
--- a/tests/gem_cs_prefetch.c
+++ b/tests/gem_cs_prefetch.c
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
 		drmtest_progress("gem_cs_prefetch: ", i, count);
 	}
 
-	fprintf(stderr, "Test suceeded, cleanup up - this might take a while.\n");
+	printf("Test suceeded, cleanup up - this might take a while.\n");
 	drm_intel_bufmgr_destroy(bufmgr);
 
 	close(fd);
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index def76d3..84ef214 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
 
 	ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
 	if (ret != 0 && (errno == ENODEV || errno == EINVAL)) {
-		fprintf(stderr, "Kernel is too old, or contexts not supported: %s\n",
+		printf("Kernel is too old, or contexts not supported: %s\n",
 			strerror(errno));
 		exit(77);
 	} else if (ret != 0) {
diff --git a/tests/sysfs_rps.c b/tests/sysfs_rps.c
index 94c4382..8ba541c 100644
--- a/tests/sysfs_rps.c
+++ b/tests/sysfs_rps.c
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
 		assert(ret != -1);
 		junk->filp = fopen(path, junk->mode);
 		if (junk->filp == NULL) {
-			fprintf(stderr, "Kernel is too old. GTFO\n");
+			printf("Kernel is too old. GTFO\n");
 			exit(77);
 		}
 		val = readval(junk->filp);
-- 
1.7.11.7




More information about the Intel-gfx mailing list