[Piglit] [PATCH 2/8] shader_runner: add support for a link-error command for negative tests

Jordan Justen jordan.l.justen at intel.com
Sun Feb 17 10:31:21 PST 2013


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 tests/shaders/shader_runner.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 2293b9e..a7083b9 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1655,12 +1655,11 @@ piglit_display(void)
 	const char *line;
 	bool pass = true;
 	GLbitfield clear_bits = 0;
+	bool link_error_expected = false;
 
 	if (test_start == NULL)
 		return PIGLIT_PASS;
 
-	program_must_be_in_use();
-
 	line = test_start;
 	while (line[0] != '\0') {
 		float c[32];
@@ -1685,11 +1684,13 @@ piglit_display(void)
 			}
 			glClipPlane(GL_CLIP_PLANE0 + x, d);
 		} else if (string_match("draw rect", line)) {
+			program_must_be_in_use();
 			get_floats(line + 9, c, 4);
 			piglit_draw_rect(c[0], c[1], c[2], c[3]);
 		} else if (string_match("draw instanced rect", line)) {
 			int primcount;
 
+			program_must_be_in_use();
 			sscanf(line + 19, "%d %f %f %f %f",
 			       &primcount,
 			       c + 0, c + 1, c + 2, c + 3);
@@ -1698,6 +1699,7 @@ piglit_display(void)
 			GLenum mode = decode_drawing_mode(s);
 			int first = x;
 			size_t count = (size_t) y;
+			program_must_be_in_use();
 			if (first < 0) {
 				printf("draw arrays 'first' must be >= 0\n");
 				piglit_report_result(PIGLIT_FAIL);
@@ -1892,9 +1894,18 @@ piglit_display(void)
 		} else if (string_match("texparameter ", line)) {
 			handle_texparameter(line + strlen("texparameter "));
 		} else if (string_match("uniform", line)) {
+			program_must_be_in_use();
 			set_uniform(line + 7);
 		} else if (string_match("parameter ", line)) {
 			set_parameter(line + strlen("parameter "));
+		} else if (string_match("link error", line)) {
+			link_error_expected = true;
+			if (link_ok) {
+				printf("shader link error expected, but it was sucessful!\n");
+				piglit_report_result(PIGLIT_FAIL);
+			}
+		} else if (string_match("link success", line)) {
+			program_must_be_in_use();
 		} else if ((line[0] != '\n') && (line[0] != '\0')
 			   && (line[0] != '#')) {
 			printf("unknown command \"%s\"", line);
@@ -1906,6 +1917,10 @@ piglit_display(void)
 			line++;
 	}
 
+	if (!link_ok && !link_error_expected) {
+		program_must_be_in_use();
+	}
+
 	piglit_present_results();
 
 	if (piglit_automatic) {
-- 
1.7.10.4



More information about the Piglit mailing list