]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test.c
use the hashtables in the IR
[xonotic/gmqcc.git] / test.c
diff --git a/test.c b/test.c
index e710e0ced26dcc0296f8824a08f31309a8e288e2..00080689540bdcc1744c52132aa9226052803706 100644 (file)
--- a/test.c
+++ b/test.c
@@ -516,7 +516,6 @@ task_template_t *task_template_compile(const char *file, const char *dir) {
         if (!template->executeflags) {
             /* default to $null */
             template->executeflags = util_strdup("$null");
-            goto failure;
         }
         if (!template->comparematch) {
             con_err("template compile error: %s missing `M:` tag (use `$null` for exclude)\n", file);
@@ -572,8 +571,6 @@ void task_template_destroy(task_template_t **template) {
      * checks will fail if template pointer is reused.
      */
     mem_d(*template);
-    task_template_nullify(*template);
-    *template = NULL;
 }
 
 /*
@@ -623,8 +620,11 @@ bool task_propogate(const char *curdir) {
          * actually a directory, so it must be a file :)
          */
         if (strstr(files->d_name, ".tmpl") == &files->d_name[strlen(files->d_name) - (sizeof(".tmpl") - 1)]) {
-            util_debug("TEST", "compiling task template: %s/%s\n", curdir, files->d_name);
             task_template_t *template = task_template_compile(files->d_name, curdir);
+            char             buf[4096]; /* one page should be enough */
+            task_t           task;
+            
+            util_debug("TEST", "compiling task template: %s/%s\n", curdir, files->d_name);
             if (!template) {
                 con_err("error compiling task template: %s\n", files->d_name);
                 success = false;
@@ -641,7 +641,6 @@ bool task_propogate(const char *curdir) {
              * which will be refered to with a handle in the task for
              * reading the data from the pipe.
              */
-            char     buf[4096]; /* one page should be enough */
             memset  (buf,0,sizeof(buf));
             snprintf(buf,  sizeof(buf), "%s %s/%s %s -o %s",
                 task_bins[TASK_COMPILE],
@@ -655,7 +654,6 @@ bool task_propogate(const char *curdir) {
              * The task template was compiled, now lets create a task from
              * the template data which has now been propogated.
              */
-            task_t task;
             task.template = template;
             if (!(task.runhandles = task_popen(buf, "r"))) {
                 con_err("error opening pipe to process for test: %s\n", template->description);
@@ -862,6 +860,8 @@ bool task_execute(task_template_t *template) {
              */
             success = !!!(strcmp(data, template->comparematch[compare++]));
         }
+        mem_d(data);
+        data = NULL;
     }
     pclose(execute);
     return success;
@@ -873,18 +873,17 @@ bool task_execute(task_template_t *template) {
  * execution this takes more work since a task needs to be generated
  * from thin air and executed INLINE.
  */
-void task_schedualize(const char *curdir) {
+void task_schedualize() {
     bool   execute  = false;
-    char  *back     = NULL;
     char  *data     = NULL;
     size_t size     = 0;
     size_t i;
     
     for (i = 0; i < vec_size(task_tasks); i++) {
         /*
-        * Generate a task from thin air if it requires execution in
-        * the QCVM.
-        */
+         * Generate a task from thin air if it requires execution in
+         * the QCVM.
+         */
         if (!strcmp(task_tasks[i].template->proceduretype, "-execute"))
             execute = true;
             
@@ -899,12 +898,10 @@ void task_schedualize(const char *curdir) {
          * then we do the same for stderr.
          */    
         while (util_getline(&data, &size, task_tasks[i].runhandles[1]) != EOF) {
-            back = data;
             fputs(data, task_tasks[i].stdoutlog);
             fflush(task_tasks[i].stdoutlog);
         }
         while (util_getline(&data, &size, task_tasks[i].runhandles[2]) != EOF) {
-            back = data;
             /*
              * If a string contains an error we just dissalow execution
              * of it in the vm.
@@ -922,9 +919,6 @@ void task_schedualize(const char *curdir) {
             fflush(task_tasks[i].stdoutlog);
         }
         
-        if (back)
-            mem_d(back);
-        
         /*
          * If we can execute we do so after all data has been read and
          * this paticular task has coupled execution in its procedure type
@@ -953,8 +947,7 @@ void task_schedualize(const char *curdir) {
             task_tasks[i].template->successmessage  : "unknown"
         );
     }
-    if (back)
-        mem_d(back);
+    mem_d(data);
 }
 
 /*
@@ -985,7 +978,7 @@ bool test_perform(const char *curdir) {
      * it's designed to prevent lock contention, and possible syncronization
      * issues.
      */
-    task_schedualize(curdir);
+    task_schedualize();
     task_destroy(curdir);
     
     return true;