From a33922cbd484044fa7e39353f600a6f4aa368a27 Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu>
Date: Mon, 5 Apr 2021 18:24:47 -0500
Subject: [PATCH] Adding exit(1) for failed tests

---
 hpvm/projects/hpvm-tensor-rt/tests/tests.h | 38 ++++++----------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/hpvm/projects/hpvm-tensor-rt/tests/tests.h b/hpvm/projects/hpvm-tensor-rt/tests/tests.h
index d9bf90a6c5..e2cf1d70de 100644
--- a/hpvm/projects/hpvm-tensor-rt/tests/tests.h
+++ b/hpvm/projects/hpvm-tensor-rt/tests/tests.h
@@ -70,6 +70,13 @@ public:
     for (int i = 0; i < failed_test_ids.size(); i++) {
       printf("*** Test = %s \n", failed_test_ids[i].c_str());
     }
+
+    if (failed_test_ids.size() > 0){
+      
+      printf("Some Tests Failed. Aborting");
+      exit(1);
+    }
+    
   }
 };
 
@@ -82,44 +89,19 @@ void testSampleFilter() {
   printf("***** Tensor Sample Filter ***** \n\n");
   Tensor *input =
       (Tensor *)create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 2, 2, 3, 3);
-  // fillTensorWithVal(input, 3);
+
   fillWithOnesAndTwos(input);
 
   Tensor *input2 = (Tensor *)create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW,
                                             3, 2, 32, 32);
   fillTensorWithVal(input2, 1);
-
-  /*  float* host_ptr = (float*) ((struct Tensor*) input)->host_data;
-  host_ptr[0] = -0.1;
-  host_ptr[1] = -25;
-  host_ptr[2] = 0.2;
-  host_ptr[3] = -0.4;
-  host_ptr[4] = 1.7;
-  host_ptr[5] = -2.9;
-  host_ptr[6] = 0.7;
-  host_ptr[7] = 0.99;
-  */
-
   printTensorValues(input);
 
-  /*  printf("\n\n");
-
-  hpvm_request_tensor(input, DEVICE);
-
-  sampleFilter(input, 2, 1);
-
-  hpvm_request_tensor(input, HOST);
-
-  printTensorValues(input);
-  */
-
   void *exact_res = tensorConvolution(input2, input, 0, 0, 1, 1, 1, 1);
   printTensorValues(exact_res);
 
   void *res = tensorConvSampSim(input2, input, 0, 0, 1, 1, 1, 1, 4, 0);
 
-  // void* res = tensorConvApprox(input2, input, 0, 0, 1, 1, 1, 1, 1, 1, 4, 3);
-
   printTensorValues(res);
 }
 
@@ -160,7 +142,7 @@ void testPerforationCalls(void *input, void *filter, int pad_h, int pad_w,
     printTensorValues(res_sim);
 
     void *res = tensorConvApprox(input, filter, pad_h, pad_w, stride_h,
-                                 stride_w, 1, 1, row, col, 1, offset);
+                                  stride_w, 1, 1, row, col, 1, offset);
 
     printf("\nConvApprox Result :");
     printTensorValues(res);
@@ -199,7 +181,7 @@ void testPerforationCalls(void *input, void *filter, int pad_h, int pad_w,
 
     std::string fp16_test_name = std::string("PERF_FP16 ") + suffix;
     unitTestResults.compareTensors((Tensor *)res_half, (Tensor *)res_sim, 0.1,
-                                   fp16_test_name);
+                                    fp16_test_name);
 
     std::string cpu_test_name = std::string("PERF_CPU ") + suffix;
     unitTestResults.compareTensors((Tensor *)res_cpu, (Tensor *)res_sim, 0.05,
-- 
GitLab