[Piglit] [PATCH 3/4] util: Print shader source and exit in the compile failure case.

Eric Anholt eric at anholt.net
Wed May 29 10:59:43 PDT 2013


This util function was printing to stderr anyway (so it's going to be
a piglit failure according to the summary), and we always want to stop
and look at the source producing the error.
---
 .../spec/arb_uniform_buffer_object/link-mismatch-blocks.c |  9 ---------
 tests/spec/arb_uniform_buffer_object/maxblocks.c          | 15 ++-------------
 .../spec/arb_uniform_buffer_object/maxuniformblocksize.c  |  9 ---------
 .../spec/arb_uniform_buffer_object/referenced-by-shader.c |  8 --------
 tests/spec/glsl-1.40/tf-no-position.c                     |  2 --
 tests/util/piglit-shader.c                                | 11 +++--------
 6 files changed, 5 insertions(+), 49 deletions(-)

diff --git a/tests/spec/arb_uniform_buffer_object/link-mismatch-blocks.c b/tests/spec/arb_uniform_buffer_object/link-mismatch-blocks.c
index d62eb4d..75735a8 100644
--- a/tests/spec/arb_uniform_buffer_object/link-mismatch-blocks.c
+++ b/tests/spec/arb_uniform_buffer_object/link-mismatch-blocks.c
@@ -218,16 +218,7 @@ test_link_fail(struct test *test, GLenum a_target, GLenum b_target)
 	b_source = get_shader(b_target, test->b_header, test->b_body);
 
 	a = piglit_compile_shader_text(a_target, a_source);
-	if (!a) {
-		fprintf(stderr, "Failed to compile shader:\n%s", a_source);
-		return false;
-	}
-
 	b = piglit_compile_shader_text(b_target, b_source);
-	if (!b) {
-		fprintf(stderr, "Failed to compile shader:\n%s", b_source);
-		return false;
-	}
 
 	prog = glCreateProgram();
 	glAttachShader(prog, a);
diff --git a/tests/spec/arb_uniform_buffer_object/maxblocks.c b/tests/spec/arb_uniform_buffer_object/maxblocks.c
index d7f57d3..f846894 100644
--- a/tests/spec/arb_uniform_buffer_object/maxblocks.c
+++ b/tests/spec/arb_uniform_buffer_object/maxblocks.c
@@ -135,22 +135,11 @@ build_shaders(const char *vs_prefix, int vs_blocks,
 	fs_source = get_shader(GL_FRAGMENT_SHADER, fs_prefix, fs_blocks);
 
 	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
-	if (!vs) {
-		fprintf(stderr, "Failed to compile VS:\n%s", vs_source);
-		piglit_report_result(PIGLIT_FAIL);
-	}
-
 	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
-	if (!fs) {
-		fprintf(stderr, "Failed to compile FS:\n%s", fs_source);
-		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	prog = glCreateProgram();
-	if (vs)
-		glAttachShader(prog, vs);
-	if (fs)
-		glAttachShader(prog, fs);
+	glAttachShader(prog, vs);
+	glAttachShader(prog, fs);
 	glLinkProgram(prog);
 
 	if (!piglit_link_check_status_quiet(prog)) {
diff --git a/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c b/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
index 171894c..879fa19 100644
--- a/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
+++ b/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
@@ -156,16 +156,7 @@ piglit_display(void)
 	}
 
 	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
-	if (!vs) {
-		fprintf(stderr, "Failed to compile VS:\n%s", vs_source);
-		piglit_report_result(PIGLIT_FAIL);
-	}
-
 	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
-	if (!fs) {
-		fprintf(stderr, "Failed to compile FS:\n%s", fs_source);
-		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	prog = glCreateProgram();
 	glAttachShader(prog, vs);
diff --git a/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c b/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c
index 4c66cc2..dad8c77 100644
--- a/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c
+++ b/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c
@@ -73,15 +73,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_ARB_uniform_buffer_object");
 
 	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
-	if (!fs) {
-		fprintf(stderr, "Failed to compile shader:\n%s", fs_source);
-		piglit_report_result(PIGLIT_FAIL);
-	}
 	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
-	if (!vs) {
-		fprintf(stderr, "Failed to compile shader:\n%s", vs_source);
-		piglit_report_result(PIGLIT_FAIL);
-	}
 	prog = piglit_link_simple_program(vs, fs);
 	if (!prog) {
 		fprintf(stderr, "Failed to link shaders.\n");
diff --git a/tests/spec/glsl-1.40/tf-no-position.c b/tests/spec/glsl-1.40/tf-no-position.c
index 4af8c6e..c666c50 100644
--- a/tests/spec/glsl-1.40/tf-no-position.c
+++ b/tests/spec/glsl-1.40/tf-no-position.c
@@ -76,8 +76,6 @@ void piglit_init(int argc, char **argv)
 	piglit_require_gl_version(30);
 	piglit_require_transform_feedback();
 	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
-	if (!vs)
-		piglit_report_result(PIGLIT_FAIL);
 
 	prog = glCreateProgram();
 	glAttachShader(prog, vs);
diff --git a/tests/util/piglit-shader.c b/tests/util/piglit-shader.c
index d715bab..8172dfb 100644
--- a/tests/util/piglit-shader.c
+++ b/tests/util/piglit-shader.c
@@ -160,8 +160,9 @@ piglit_compile_shader_text(GLenum target, const char *text)
 			fprintf(stderr, "Failed to compile %s shader: %s\n",
 				shader_name(target),
 				info);
-			glDeleteShader(prog);
-			prog = 0;
+
+			fprintf(stderr, "source:\n%s", text);
+			piglit_report_result(PIGLIT_FAIL);
 		}
 		else if (0) {
 			/* Enable this to get extra compilation info.
@@ -275,16 +276,10 @@ piglit_build_simple_program(const char *vs_source, const char *fs_source)
 
 	if (vs_source) {
 		vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
-		if (!vs) {
-			piglit_report_result(PIGLIT_FAIL);
-		}
 	}
 
 	if (fs_source) {
 		fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
-		if (!fs) {
-			piglit_report_result(PIGLIT_FAIL);
-		}
 	}
 
 	prog = piglit_link_simple_program(vs, fs);
-- 
1.8.3.rc0



More information about the Piglit mailing list