From 66a8a6be64a89e80427b17dfea8672916dbf5373 Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Mon, 26 Oct 2015 16:01:38 +0100
Subject: [PATCH] adding testcases for dlsim TM2 adding error checks in dlsim

---
 cmake_targets/autotests/README.txt         |  2 ++
 cmake_targets/autotests/test_case_list.xml | 12 ++++++++----
 openair1/SIMULATION/LTE_PHY/dlsim.c        | 22 +++++++++++++++++-----
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/cmake_targets/autotests/README.txt b/cmake_targets/autotests/README.txt
index a623be4751..c983933125 100644
--- a/cmake_targets/autotests/README.txt
+++ b/cmake_targets/autotests/README.txt
@@ -73,6 +73,8 @@ Obj.#   Case#   Test#	Description
                         (Test 10: 5 MHz, R6.FDD (MCS 25), EVA5, 17.4 dB (70%)),
                         (Test 10b: 5 MHz, R6-1.FDD (MCS 24,18 PRB), EVA5, 17.5dB (70%)),
                         (Test 11: 10 MHz, R7.FDD (MCS 25), EVA5, 17.7dB (70%))
+		        (TM2 Test 1 10 MHz, R.11 FDD (MCS 14), EVA5, 6.8 dB (70%)),
+		        (TM2 Test 1b 20 MHz, R.11-2 FDD (MCS 13), EVA5, 5.9 dB (70%)),
 01      51      01      ulsim Test cases. (Test 1, 5 MHz, FDD (MCS 5), AWGN, 6dB), 
                         (Test 2, 5 MHz, FDD (MCS 16), AWGN , 12dB (70%)),
                         (Test 3, 10 MHz, R3.FDD (MCS 5), AWGN, 6dB (70%)),
diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml
index 1d2d3d6626..5d24cd46d7 100644
--- a/cmake_targets/autotests/test_case_list.xml
+++ b/cmake_targets/autotests/test_case_list.xml
@@ -754,6 +754,8 @@
       (Test 10, 5 MHz, R6.FDD (MCS 25), EVA5, 17.4 dB (70%)),
       (Test 10b, 5 MHz, R6-1.FDD (MCS 24,18 PRB), EVA5, 17.5dB (70%)),
       (Test 11, 10 MHz, R7.FDD (MCS 25), EVA5, 17.7dB (70%))
+      (TM2 Test 1 10 MHz, R.11 FDD (MCS 14), EVA5, 6.8 dB (70%)),
+      (TM2 Test 1b 20 MHz, R.11-2 FDD (MCS 13), EVA5, 5.9 dB (70%)),
        </desc>
       <pre_compile_prog></pre_compile_prog>
       <compile_prog>dlsim</compile_prog>
@@ -769,11 +771,13 @@
                        -m14 -gG -s1.4 -w1.0 -f.2 -n500 -B25 -c3 -z2 -O30 -L
                        -m25 -gF -s17.4 -w1.0 -f.2 -n500 -B25 -c3 -z2 -O70 -L
                        -m25 -gF -s17.5 -w1.0 -f.2 -n500 -B25 -c3 -z2 -r1022 -O70 -L
-                       -m26 -gF -s17.7 -w1.0 -f.2 -n500 -B50 -c2 -z2 -O70 -L</main_exec_args>
-      <tags>test1 test5 test6 test6b test7 test7b test10 test10b test11</tags>
+                       -m26 -gF -s17.7 -w1.0 -f.2 -n500 -B50 -c2 -z2 -O70 -L
+		       -m14 -gF -s6.8  -w1.0 -f.2 -n500 -B50 -c2 -x2 -y2 -z2 -O70 -L
+                       -m13 -gF -s5.9  -w1.0 -f.2 -n500 -B25 -c3 -x2 -y2 -z2 -O70 -L</main_exec_args>
+      <tags>test1 test5 test6 test6b test7 test7b test10 test10b test11 TM2_test1 TM2_test1b</tags>
       <search_expr_true>"passed"</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
-      <nruns>3</nruns>
+      <nruns>1</nruns>
     </testCase>
 
     <testCase id="015101">
@@ -799,7 +803,7 @@
      <tags>test1 test2 test3 test4 test5 test6</tags>
       <search_expr_true>"passed"</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
-      <nruns>3</nruns>
+      <nruns>1</nruns>
     </testCase>
 
 
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index 28e7bc8216..0e0dce370c 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -777,6 +777,10 @@ int main(int argc, char **argv)
     sprintf(bler_fname,"bler_tx%d_chan%d_nrx%d_mcs%d.csv",transmission_mode,channel_model,n_rx,mcs1);
 
   bler_fd = fopen(bler_fname,"w");
+  if (bler_fd==NULL) {
+    fprintf(stderr,"Cannot create file %s!\n",bler_fname);
+    exit(-1);
+  }
   fprintf(bler_fd,"SNR; MCS; TBS; rate; err0; trials0; err1; trials1; err2; trials2; err3; trials3; dci_err\n");
 
   if (test_perf != 0) {
@@ -784,12 +788,16 @@ int main(int argc, char **argv)
     hostname[1023] = '\0';
     gethostname(hostname, 1023);
     printf("Hostname: %s\n", hostname);
-    char dirname[FILENAME_MAX];
-    sprintf(dirname, "%s/SIMU/USER/pre-ci-logs-%s", getenv("OPENAIR_TARGETS"),hostname );
-    sprintf(time_meas_fname,"%s/time_meas_prb%d_mcs%d_anttx%d_antrx%d_pdcch%d_channel%s_tx%d.csv",
-            dirname,N_RB_DL,mcs1,n_tx,n_rx,num_pdcch_symbols,channel_model_input,transmission_mode);
-    mkdir(dirname,0777);
+    //char dirname[FILENAME_MAX];
+    //sprintf(dirname, "%s/SIMU/USER/pre-ci-logs-%s", getenv("OPENAIR_TARGETS"),hostname );
+    sprintf(time_meas_fname,"time_meas_prb%d_mcs%d_anttx%d_antrx%d_pdcch%d_channel%s_tx%d.csv",
+            N_RB_DL,mcs1,n_tx,n_rx,num_pdcch_symbols,channel_model_input,transmission_mode);
+    //mkdir(dirname,0777);
     time_meas_fd = fopen(time_meas_fname,"w");
+    if (time_meas_fd==NULL) {
+      fprintf(stderr,"Cannot create file %s!\n",time_meas_fname);
+      exit(-1);
+    }
   }
 
   if(abstx) {
@@ -797,6 +805,10 @@ int main(int argc, char **argv)
     sprintf(csv_fname,"dataout_tx%d_u2%d_mcs%d_chan%d_nsimus%d_R%d.m",transmission_mode,dual_stream_UE,mcs1,channel_model,n_frames,num_rounds);
     csv_fd = fopen(csv_fname,"w");
     fprintf(csv_fd,"data_all%d=[",mcs1);
+    if (csv_fd==NULL) {
+      fprintf(stderr,"Cannot create file %s!\n",csv_fname);
+      exit(-1);
+    }
   }
 
   /*
-- 
2.26.2