r300g/tests: Exit test runner with a valid status code
authorTom Stellard <thomas.stellard@amd.com>
Sun, 10 Feb 2013 05:15:10 +0000 (00:15 -0500)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 22 Feb 2013 03:07:27 +0000 (22:07 -0500)
This way make check can report whether or not the tests pass.

NOTE: This is a candidate for the stable branches.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c
src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.h
src/gallium/drivers/r300/compiler/tests/radeon_compiler_util_tests.c
src/gallium/drivers/r300/compiler/tests/unit_test.c
src/gallium/drivers/r300/compiler/tests/unit_test.h

index 4b98e38..cc4725a 100644 (file)
 
 #include "r300_compiler_tests.h"
 
+#include <stdlib.h>
+
 int main(int argc, char ** argv)
 {
-       radeon_compiler_util_run_tests();
+       unsigned pass = 1;
+       pass &= radeon_compiler_optimize_run_tests();
+       pass &= radeon_compiler_util_run_tests();
+
+       if (pass) {
+               return EXIT_SUCCESS;
+       } else {
+               return EXIT_FAILURE;
+       }
 }
index b671955..266addf 100644 (file)
@@ -25,4 +25,5 @@
  *
  */
 
-void radeon_compiler_util_run_tests(void);
+unsigned radeon_compiler_optimize_run_tests(void);
+unsigned radeon_compiler_util_run_tests(void);
index 25220ec..33b27fc 100644 (file)
@@ -94,11 +94,11 @@ static void test_runner_rc_inst_can_use_presub(struct test_result * result)
                "MAD temp[0].xyz, temp[2].xyz_, -temp[3].xxx_, input[5].xyz_;");
 }
 
-void radeon_compiler_util_run_tests()
+unsigned radeon_compiler_util_run_tests()
 {
        struct test tests[] = {
                {"rc_inst_can_use_presub()", test_runner_rc_inst_can_use_presub},
                {NULL, NULL}
        };
-       run_tests(tests);
+       return run_tests(tests);
 }
index ac6bded..a014d78 100644 (file)
 
 #include "unit_test.h"
 
-void run_tests(struct test tests[])
+unsigned run_tests(struct test tests[])
 {
        int i;
+       unsigned pass = 1;
        for (i = 0; tests[i].name; i++) {
                printf("Test %s\n", tests[i].name);
                memset(&tests[i].result, 0, sizeof(tests[i].result));
                tests[i].test_func(&tests[i].result);
                printf("Test %s (%d/%d) pass\n", tests[i].name,
                        tests[i].result.pass, tests[i].result.test_count);
+               if (tests[i].result.pass != tests[i].result.test_count) {
+                       pass = 0;
+               }
        }
+       return pass;
 }
 
 void test_begin(struct test_result * result)
index 9a69fd7..4a95843 100644 (file)
@@ -37,7 +37,7 @@ struct test {
        struct test_result result;
 };
 
-void run_tests(struct test tests[]);
+unsigned run_tests(struct test tests[]);
 
 void test_begin(struct test_result * result);
 void test_check(struct test_result * result, int cond);