[Piglit] [PATCH] util: call fflush() after printf() calls

Brian Paul brianp at vmware.com
Wed Jun 7 15:51:52 UTC 2017


Otherwise, on Windows, we don't see the printf() output until the program
exits.  That's fine with the -auto option, but a problem w/out -auto.
---
 tests/util/piglit-util-gl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 5ff13fe..f5734d9 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -1169,6 +1169,7 @@ piglit_probe_pixel_rgb(int x, int y, const float* expected)
 	printf("Probe color at (%i,%i)\n", x, y);
 	printf("  Expected: %f %f %f\n", expected[0], expected[1], expected[2]);
 	printf("  Observed: %f %f %f\n", probe[0], probe[1], probe[2]);
+	fflush(stdout);
 
 	return 0;
 }
@@ -1199,6 +1200,7 @@ piglit_probe_pixel_rgba(int x, int y, const float* expected)
 	printf("Probe color at (%i,%i)\n", x, y);
 	printf("  Expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
 	printf("  Observed: %f %f %f %f\n", probe[0], probe[1], probe[2], probe[3]);
+	fflush(stdout);
 
 	return 0;
 }
@@ -1259,6 +1261,7 @@ piglit_probe_rect_ubyte(int x, int y, int w, int h, int num_components,
 							printf("  Observed: %u %u %u\n",
 							       probe[0], probe[1], probe[2]);
 						}
+						fflush(stdout);
 					}
 					free(pixels);
 					return false;
@@ -1321,6 +1324,7 @@ piglit_probe_rect_r_ubyte(int x, int y, int w, int h, GLubyte expected)
 				printf("Probe color at (%i,%i)\n", x+i, y+j);
 				printf("  Expected: %u\n", expected);
 				printf("  Observed: %u\n", probe);
+				fflush(stdout);
 
 				free(pixels);
 				return 0;
@@ -1355,6 +1359,7 @@ piglit_probe_rect_rgb(int x, int y, int w, int h, const float *expected)
 					       expected[0], expected[1], expected[2]);
 					printf("  Observed: %f %f %f\n",
 					       probe[0], probe[1], probe[2]);
+					fflush(stdout);
 
 					free(pixels);
 					return 0;
@@ -1425,6 +1430,7 @@ piglit_probe_rect_rgba(int x, int y, int w, int h, const float *expected)
 					       expected[0], expected[1], expected[2], expected[3]);
 					printf("  Observed: %f %f %f %f\n",
 					       probe[0], probe[1], probe[2], probe[3]);
+					fflush(stdout);
 
 					free(pixels);
 					return 0;
@@ -1457,6 +1463,7 @@ piglit_probe_rect_rgba_int(int x, int y, int w, int h, const int *expected)
 					       expected[0], expected[1], expected[2], expected[3]);
 					printf("  Observed: %d %d %d %d\n",
 					       probe[0], probe[1], probe[2], probe[3]);
+					fflush(stdout);
 
 					free(pixels);
 					return 0;
@@ -1490,6 +1497,7 @@ piglit_probe_rect_rgba_uint(int x, int y, int w, int h,
 					       expected[0], expected[1], expected[2], expected[3]);
 					printf("  Observed: %u %u %u %u\n",
 					       probe[0], probe[1], probe[2], probe[3]);
+					fflush(stdout);
 
 					free(pixels);
 					return 0;
@@ -1685,6 +1693,7 @@ piglit_compare_images_ubyte(int x, int y, int w, int h,
 				printf("Probe at (%i,%i)\n", x+i, y+j);
 				printf("  Expected: %d\n", expected);
 				printf("  Observed: %d\n", probe);
+				fflush(stdout);
 
 				return 0;
 			}
@@ -1858,6 +1867,7 @@ int piglit_probe_texel_rect_rgb(int target, int level, int x, int y,
 					       expected[0], expected[1], expected[2]);
 					printf("  Observed: %f %f %f\n",
 					       probe[0], probe[1], probe[2]);
+					fflush(stdout);
 
 					free(buffer);
 					return 0;
@@ -1921,6 +1931,7 @@ int piglit_probe_texel_rect_rgba(int target, int level, int x, int y,
 					       expected[0], expected[1], expected[2], expected[3]);
 					printf("  Observed: %f %f %f %f\n",
 					       probe[0], probe[1], probe[2], probe[3]);
+					fflush(stdout);
 
 					free(buffer);
 					return 0;
@@ -1990,6 +2001,7 @@ int piglit_probe_texel_volume_rgba(int target, int level, int x, int y, int z,
 						       expected[0], expected[1], expected[2], expected[3]);
 						printf("  Observed: %f %f %f %f\n",
 						       probe[0], probe[1], probe[2], probe[3]);
+						fflush(stdout);
 
 						free(buffer);
 						return 0;
@@ -2024,6 +2036,7 @@ int piglit_probe_pixel_depth(int x, int y, float expected)
 	printf("Probe depth at (%i,%i)\n", x, y);
 	printf("  Expected: %f\n", expected);
 	printf("  Observed: %f\n", probe);
+	fflush(stdout);
 
 	return 0;
 }
@@ -2044,6 +2057,7 @@ int piglit_probe_rect_depth(int x, int y, int w, int h, float expected)
 				printf("Probe depth at (%i,%i)\n", x+i, y+j);
 				printf("  Expected: %f\n", expected);
 				printf("  Observed: %f\n", *probe);
+				fflush(stdout);
 
 				free(pixels);
 				return 0;
@@ -2066,6 +2080,7 @@ int piglit_probe_pixel_stencil(int x, int y, unsigned expected)
 	printf("Probe stencil at (%i, %i)\n", x, y);
 	printf("  Expected: %u\n", expected);
 	printf("  Observed: %u\n", probe);
+	fflush(stdout);
 
 	return 0;
 }
@@ -2084,6 +2099,7 @@ int piglit_probe_rect_stencil(int x, int y, int w, int h, unsigned expected)
 				printf("Probe stencil at (%i, %i)\n", x + i, y + j);
 				printf("  Expected: %u\n", expected);
 				printf("  Observed: %u\n", probe);
+				fflush(stdout);
 				free(pixels);
 				return 0;
 			}
@@ -2109,6 +2125,7 @@ bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
 		if (fabs(ptr[i] - expected[i % num_components]) > 0.01) {
 			printf("%s[%i]: %f, Expected: %f\n", label, i, ptr[i],
 				expected[i % num_components]);
+			fflush(stdout);
 			status = false;
 		}
 	}
@@ -2133,6 +2150,7 @@ bool piglit_probe_buffer_doubles(GLuint buf, GLenum target, const char *label,
 		if (fabs(ptr[i] - expected[i % num_components]) > 0.01) {
 			printf("%s[%i]: %f, Expected: %f\n", label, i, ptr[i],
 				expected[i % num_components]);
+			fflush(stdout);
 			status = false;
 		}
 	}
@@ -2200,10 +2218,13 @@ GLuint piglit_compile_program(GLenum target, const char* text)
 			fprintf(stderr, "%c", text[errorPos+a]);
 		}
 		fprintf(stderr, "\nin program:\n%s", text);
+		fflush(stderr);
+
 		piglit_report_result(PIGLIT_FAIL);
 	}
 	if (!glIsProgramARB(program)) {
 		fprintf(stderr, "glIsProgramARB failed\n");
+		fflush(stderr);
 		piglit_report_result(PIGLIT_FAIL);
 	}
 
-- 
1.9.1



More information about the Piglit mailing list