test: handle accumulators
authorDavid Schleef <ds@schleef.org>
Thu, 25 Jun 2009 00:43:02 +0000 (17:43 -0700)
committerDavid Schleef <ds@schleef.org>
Thu, 25 Jun 2009 00:43:02 +0000 (17:43 -0700)
orc-test/orctest.c

index a06dfda..4df6ab9 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+//#include <time.h>
 
 
 void
@@ -16,6 +17,8 @@ orc_test_init (void)
   orc_init ();
 
   setvbuf (stdout, NULL, _IONBF, 0);
+
+  //srand (time(NULL));
 }
 
 
@@ -534,6 +537,9 @@ orc_test_compare_output (OrcProgram *program)
   int k;
   int have_dest = FALSE;
   OrcCompileResult result;
+  int have_acc = FALSE;
+  int acc_exec = 0, acc_emul = 0;
+  int ret = ORC_TEST_OK;
 
   result = orc_program_compile (program);
   if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
@@ -563,9 +569,6 @@ orc_test_compare_output (OrcProgram *program)
       orc_executor_set_param (ex, i, 2);
     }
   }
-  if (!have_dest) {
-    return ORC_TEST_INDETERMINATE;
-  }
 
   orc_executor_run (ex);
 
@@ -573,6 +576,10 @@ orc_test_compare_output (OrcProgram *program)
     if (program->vars[i].vartype == ORC_VAR_TYPE_DEST) {
       orc_executor_set_array (ex, i, dest_emul[i]);
     }
+    if (program->vars[i].vartype == ORC_VAR_TYPE_ACCUMULATOR) {
+      acc_exec = ex->accumulators[0];
+      have_acc = TRUE;
+    }
   }
   orc_executor_emulate (ex);
 
@@ -604,24 +611,37 @@ orc_test_compare_output (OrcProgram *program)
           printf("\n");
         }
 
-        printf("%s", orc_program_get_asm_code (program));
-
-        return FALSE;
+        ret = ORC_TEST_FAILED;
       }
       if (!check_bounds (dest_exec[k], n, program->vars[k].size)) {
         printf("out of bounds failure\n");
 
-        return FALSE;
+        ret = ORC_TEST_FAILED;
       }
 
       free (ptr_exec[k]);
       free (ptr_emul[k]);
     }
+    if (program->vars[k].vartype == ORC_VAR_TYPE_ACCUMULATOR) {
+      acc_emul = ex->accumulators[0];
+    }
+  }
+
+  if (have_acc) {
+    printf("acc %d %d\n", acc_emul, acc_exec);
+    printf("n %d\n", n);
+    if (acc_emul != acc_exec) {
+      ret = ORC_TEST_FAILED;
+    }
+  }
+
+  if (ret == ORC_TEST_FAILED) {
+    printf("%s", orc_program_get_asm_code (program));
   }
 
   orc_executor_free (ex);
 
-  return TRUE;
+  return ret;
 }
 
 OrcProgram *