]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test.c
operator &~= must not cause the generated binstore to free the destination twice
[xonotic/gmqcc.git] / test.c
diff --git a/test.c b/test.c
index acaa1bd841e1d747dec8e7e7225bfe7df3826a2d..bbbeabe9350f2b39c99d49ba3dfaa531937b5c5a 100644 (file)
--- a/test.c
+++ b/test.c
@@ -593,12 +593,13 @@ task_t *task_tasks = NULL;
  * Read a directory and searches for all template files in it
  * which is later used to run all tests.
  */
-bool task_propogate(const char *curdir) {
+bool task_propagate(const char *curdir) {
     bool             success = true;
     DIR             *dir;
     struct dirent   *files;
     struct stat      directory;
     char             buffer[4096];
+    size_t           found = 0;
     
     dir = opendir(curdir);
     
@@ -625,6 +626,7 @@ bool task_propogate(const char *curdir) {
             task_t           task;
             
             util_debug("TEST", "compiling task template: %s/%s\n", curdir, files->d_name);
+            found ++;
             if (!template) {
                 con_err("error compiling task template: %s\n", files->d_name);
                 success = false;
@@ -652,7 +654,7 @@ 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.
+             * the template data which has now been propagated.
              */
             task.template = template;
             if (!(task.runhandles = task_popen(buf, "r"))) {
@@ -687,6 +689,11 @@ bool task_propogate(const char *curdir) {
         }
     }
     
+    util_debug("TEST", "compiled %d task template files out of %d\n",
+        vec_size(task_tasks),
+        found
+    );
+    
     closedir(dir);
     return success;
 }
@@ -879,7 +886,10 @@ void task_schedualize() {
     size_t size     = 0;
     size_t i;
     
+    util_debug("TEST", "found %d tasks, preparing to execute\n", vec_size(task_tasks));
+    
     for (i = 0; i < vec_size(task_tasks); i++) {
+        util_debug("TEST", "executing task: %d: %s\n", i, task_tasks[i].template->description);
         /*
          * Generate a task from thin air if it requires execution in
          * the QCVM.
@@ -899,6 +909,10 @@ void task_schedualize() {
          */    
         while (util_getline(&data, &size, task_tasks[i].runhandles[1]) != EOF) {
             fputs(data, task_tasks[i].stdoutlog);
+            
+            if (strstr(data, "failed to open file"))
+                execute = false;
+            
             fflush(task_tasks[i].stdoutlog);
         }
         while (util_getline(&data, &size, task_tasks[i].runhandles[2]) != EOF) {
@@ -919,18 +933,11 @@ void task_schedualize() {
             fflush(task_tasks[i].stdoutlog);
         }
         
-        /*
-         * If we can execute we do so after all data has been read and
-         * this paticular task has coupled execution in its procedure type
-         */
-        if (!execute)
-            continue;
-        
         /*
          * If we made it here that concludes the task is to be executed
          * in the virtual machine.
          */
-        if (!task_execute(task_tasks[i].template)) {
+        if (!execute || !task_execute(task_tasks[i].template)) {
             con_err("test failure: `%s` [%s] see %s.stdout and %s.stderr\n",
                 task_tasks[i].template->description,
                 (task_tasks[i].template->failuremessage) ?
@@ -953,26 +960,26 @@ void task_schedualize() {
 /*
  * This is the heart of the whole test-suite process.  This cleans up
  * any existing temporary files left behind as well as log files left
- * behind.  Then it propogates a list of tests from `curdir` by scaning
+ * behind.  Then it propagates a list of tests from `curdir` by scaning
  * it for template files and compiling them into tasks, in which it
  * schedualizes them (executes them) and actually reports errors and
  * what not.  It then proceeds to destroy the tasks and return memory
  * it's the engine :)
  * 
- * It returns true of tests could be propogated, otherwise it returns
+ * It returns true of tests could be propagated, otherwise it returns
  * false.
  * 
  * It expects con_init() was called before hand.
  */
 bool test_perform(const char *curdir) {
     task_precleanup(curdir);
-    if (!task_propogate(curdir)) {
-        con_err("error: failed to propogate tasks\n");
+    if (!task_propagate(curdir)) {
+        con_err("error: failed to propagate tasks\n");
         task_destroy(curdir);
         return false;
     }
     /*
-     * If we made it here all tasks where propogated from their resultant
+     * If we made it here all tasks where propagated from their resultant
      * template file.  So we can start the FILO scheduler, this has been
      * designed in the most thread-safe way possible for future threading
      * it's designed to prevent lock contention, and possible syncronization
@@ -1015,8 +1022,9 @@ static bool parsecmd(const char *optname, int *argc_, char ***argv_, char **out,
 }
 
 int main(int argc, char **argv) {
-    char *redirout = (char*)stdout;
-    char *redirerr = (char*)stderr;
+    char         *redirout = (char*)stdout;
+    char         *redirerr = (char*)stderr;
+    
     con_init();
     
     /*