]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test.c
Some testing for valgrind in the makefile
[xonotic/gmqcc.git] / test.c
diff --git a/test.c b/test.c
index 357f3d397bf150322c337332548862ccec523bbc..d3132e25c342f807529630552c4480d406a11c47 100644 (file)
--- a/test.c
+++ b/test.c
@@ -27,8 +27,6 @@
 
 #include "gmqcc.h"
 
-opts_cmd_t opts;
-
 static const char *task_bins[] = {
     "./gmqcc",
     "./qcvm"
@@ -689,9 +687,12 @@ static bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
      */
     while ((files = fs_dir_read(dir))) {
         util_asprintf(&claim, "%s/%s", curdir, files->d_name);
-        if (stat(claim, &directory) == -1)
+        if (stat(claim, &directory) == -1) {
+            fs_dir_close(dir);
+            mem_d(claim);
             return false;
-        
+        }
+
         if (S_ISDIR(directory.st_mode) && files->d_name[0] != '.') {
             vec_push(directories, claim);
         } else {
@@ -1108,7 +1109,7 @@ static const char *task_type(task_template_t *tmpl) {
  * from thin air and executed INLINE.
  */
 #include <math.h>
-static void task_schedualize(size_t *pad) {
+static size_t task_schedualize(size_t *pad) {
     char   space[2][64];
     bool   execute  = false;
     char  *data     = NULL;
@@ -1116,6 +1117,7 @@ static void task_schedualize(size_t *pad) {
     size_t size     = 0;
     size_t i        = 0;
     size_t j        = 0;
+    size_t failed   = 0;
 
     util_snprintf(space[0], sizeof(space[0]), "%d", (int)vec_size(task_tasks));
 
@@ -1180,6 +1182,7 @@ static void task_schedualize(size_t *pad) {
                 (pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen("(failed to compile)") - pad[2]),
                 "(failed to compile)"
             );
+            failed++;
             continue;
         }
 
@@ -1257,6 +1260,7 @@ static void task_schedualize(size_t *pad) {
             for (j = 0; j < vec_size(match); j++)
                 mem_d(match[j]);
             vec_free(match);
+            failed++;
             continue;
         }
         
@@ -1274,6 +1278,7 @@ static void task_schedualize(size_t *pad) {
         );
     }
     mem_d(data);
+    return failed;
 }
 
 /*
@@ -1291,6 +1296,7 @@ static void task_schedualize(size_t *pad) {
  * It expects con_init() was called before hand.
  */
 static GMQCC_WARN bool test_perform(const char *curdir, const char *defs) {
+    size_t             failed       = false;
     static const char *default_defs = "defs.qh";
 
     size_t pad[] = {
@@ -1320,10 +1326,12 @@ static GMQCC_WARN bool test_perform(const char *curdir, const char *defs) {
      * it's designed to prevent lock contention, and possible syncronization
      * issues.
      */
-    task_schedualize(pad);
+    failed = task_schedualize(pad);
+    if (failed)
+        con_out("%u out of %u tests failed\n", failed, vec_size(task_tasks));
     task_destroy();
 
-    return true;
+    return (failed) ? false : true;
 }
 
 /*