Use piglit-bitset to keep track of shader compile results.

Use this information to print all passing or failing
shaders (by number) when 'compile error' or 'compiler success'
is used.

Signed-off-by: Jordan Justen <[email protected]>
---
 tests/shaders/shader_runner.c |   53 +++++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 15 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 665b0e7..3e69ba1 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -33,6 +33,7 @@
 #include <libgen.h>
 #endif
 
+#include "piglit-bitset.h"
 #include "piglit-util-gl-common.h"
 #include "piglit-vbo.h"
 
@@ -97,9 +98,8 @@ const char *vertex_data_start = NULL;
 const char *vertex_data_end = NULL;
 GLuint prog;
 size_t num_vbo_rows = 0;
+void *compilation_results = NULL;
 int compile_count = 0;
-int first_compile_success = 0;
-int first_compile_failure = 0;
 bool link_ok = false;
 bool prog_in_use = false;
 GLchar *saved_err_info = NULL;
@@ -268,18 +268,17 @@ compile_glsl(GLenum target, bool release_text)
        glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
 
        if (ok) {
-               if (first_compile_success == 0)
-                       first_compile_success = compile_count;
+               piglit_bitset_append(compilation_results, true);
        } else {
-               if (first_compile_failure == 0) {
+               if (piglit_bitset_is_all_set(compilation_results)) {
                        GLint size;
-                       first_compile_failure = compile_count;
 
                        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &size);
                        saved_err_info = malloc(size);
 
                        glGetShaderInfoLog(shader, size, NULL, saved_err_info);
                }
+               piglit_bitset_append(compilation_results, false);
        }
 
        if (release_text) {
@@ -753,7 +752,7 @@ link_and_use_shaders(void)
        if (((num_vertex_shaders == 0)
              && (num_fragment_shaders == 0)
              && (num_geometry_shaders == 0))
-           || (first_compile_failure > 0))
+           || (!piglit_bitset_is_all_set(compilation_results)))
                return;
 
        prog = glCreateProgram();
@@ -1645,10 +1644,24 @@ void
 all_compilations_must_succeed(void)
 {
        
-       if (first_compile_failure > 0) {
-               fprintf(stderr, "Failed to compile shader #%d:\n%s\n",
-                               first_compile_failure,
-                               saved_err_info);
+       if (!piglit_bitset_is_all_set(compilation_results)) {
+               unsigned int i;
+               bool err_shown = false;
+               for (i = 0;
+                    i < piglit_bitset_size(compilation_results);
+                    i++) {
+                       if (!piglit_bitset_is_set(compilation_results, i)) {
+                               if (!err_shown) {
+                                       fprintf(stderr, "Failed to compile 
shader #%d:\n%s\n",
+                                                       i + 1,
+                                                       saved_err_info);
+                                       err_shown = true;
+                               } else {
+                                       fprintf(stderr, "Failed to compile 
shader #%d\n",
+                                                       i + 1);
+                               }
+                       }
+               }
                piglit_report_result(PIGLIT_FAIL);
        }
 }
@@ -1657,10 +1670,17 @@ void
 all_compilations_must_fail(void)
 {
        
-       if (first_compile_success > 0) {
-               fprintf(stderr, "Shader #%d compiled successfully, "
-                               "but an error was expected!\n",
-                               first_compile_success);
+       if (!piglit_bitset_is_all_clear(compilation_results)) {
+               unsigned int i;
+               for (i = 0;
+                    i < piglit_bitset_size(compilation_results);
+                    i++) {
+                       if (piglit_bitset_is_set(compilation_results, i)) {
+                               fprintf(stderr, "Shader #%d compiled 
successfully, "
+                                               "but an error was expected!\n",
+                                               i + 1);
+                       }
+               }
                piglit_report_result(PIGLIT_FAIL);
        }
 }
@@ -2022,6 +2042,9 @@ piglit_init(int argc, char **argv)
                exit(1);
        }
 
+       compilation_results = piglit_bitset_create();
+       assert(compilation_results);
+
        process_test_script(argv[1]);
        link_and_use_shaders();
        if (vertex_data_start != NULL) {
-- 
1.7.10.4

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to