From eda87e60d69ff167b3f4bf969362bd5ac9efcfbe Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Mon, 19 May 2014 09:50:19 +0000
Subject: [PATCH] * add test case 02 for performance benchmarking of the
 softmodem

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5328 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair1/SIMULATION/LTE_PHY/ulsim.c | 150 ++++++++++++++++++++++++----
 targets/TEST/OAI/case11.py          |   2 +-
 targets/TEST/OAI/case12.py          |  21 ++--
 targets/TEST/OAI/case13.py          | 130 ++++++++++++++++++++++++
 targets/TEST/OAI/test02.py          |   7 +-
 5 files changed, 279 insertions(+), 31 deletions(-)
 create mode 100644 targets/TEST/OAI/case13.py

diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 81cc5377b4..b0ac815063 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -194,25 +194,28 @@ int main(int argc, char **argv) {
   unsigned int coded_bits_per_codeword,nsymb;
   int subframe=3;
   unsigned int tx_lev=0,tx_lev_dB,trials,errs[4]={0,0,0,0},round_trials[4]={0,0,0,0};
-  uint8_t transmission_mode=1,n_rx=1;
+  uint8_t transmission_mode=1,n_rx=1,n_tx=1;
  
-  FILE *bler_fd;
+  FILE *bler_fd=NULL;
   char bler_fname[512];
 
+  FILE *time_meas_fd=NULL;
+  char time_meas_fname[256];
+ 
   FILE *input_fdUL=NULL,*trch_out_fdUL=NULL;
   //  unsigned char input_file=0;
   char input_val_str[50],input_val_str2[50];
  
   //  FILE *rx_frame_file;
-  FILE *csv_fdUL;
+  FILE *csv_fdUL=NULL;
 
-  FILE *fperen;
+  FILE *fperen=NULL;
   char fperen_name[512];  
   
-  FILE *fmageren;
+  FILE *fmageren=NULL;
   char fmageren_name[512];
   
-  FILE *flogeren;
+  FILE *flogeren=NULL;
   char flogeren_name[512];
 
   /* FILE *ftxlev;
@@ -246,7 +249,11 @@ int main(int argc, char **argv) {
   uint32_t UL_alloc_pdu;
   int s,Kr,Kr_bytes;
   int dump_perf=0;
-
+  int test_perf=0;
+  
+  double effective_rate=0.0;
+  char channel_model_input[10];
+  
   uint8_t max_turbo_iterations=4;
   uint8_t llr8_flag=0;
   int nb_rb_set = 0;
@@ -260,7 +267,7 @@ int main(int argc, char **argv) {
 
   logInit();
 
-  while ((c = getopt (argc, argv, "hapbm:n:Y:X:s:w:e:q:d:D:c:r:i:f:y:c:oA:C:R:g:N:l:S:T:QB:PI:L")) != -1) {
+  while ((c = getopt (argc, argv, "hapbm:n:Y:X:x:s:w:e:q:d:D:O:c:r:i:f:y:c:oA:C:R:g:N:l:S:T:QB:PI:L")) != -1) {
     switch (c) {
     case 'a':
       channel_model = AWGN;
@@ -288,6 +295,7 @@ int main(int argc, char **argv) {
       abstx= atoi(optarg);
       break;  
     case 'g':
+      sprintf(channel_model_input,optarg,10);
       switch((char)*optarg) {
       case 'A': 
 	channel_model=SCM_A;
@@ -341,6 +349,10 @@ int main(int argc, char **argv) {
 	channel_model=Rice1;
 	chMod = 14;
 	break;
+      case 'N':
+	channel_model=AWGN;
+	chMod = 1;
+	break;
       default:
 	msg("Unsupported channel model!\n");
 	exit(-1);
@@ -356,6 +368,17 @@ int main(int argc, char **argv) {
     case 'e':
       input_snr_step= atof(optarg);
       break;
+    case 'x':
+      transmission_mode=atoi(optarg);
+      if ((transmission_mode!=1) &&
+	  (transmission_mode!=2)) {
+	msg("Unsupported transmission mode %d\n",transmission_mode);
+	exit(-1);
+      }
+      if (transmission_mode>1) {
+	n_tx = 1;
+      }
+      break;
     case 'y':
       n_rx = atoi(optarg);
       break;
@@ -428,6 +451,10 @@ int main(int argc, char **argv) {
       dump_perf=1;
       opp_enabled=1;
       break;
+    case 'O':
+      test_perf=atoi(optarg);
+      //print_perf =1;
+      break;
     case 'L':
       llr8_flag=1;
       break;
@@ -487,6 +514,13 @@ int main(int argc, char **argv) {
   bler_fd = fopen(bler_fname,"w");
  
   fprintf(bler_fd,"#SNR;mcs;nb_rb;TBS;rate;errors[0];trials[0];errors[1];trials[1];errors[2];trials[2];errors[3];trials[3]\n");
+
+  if (test_perf != 0) {
+    sprintf(time_meas_fname,"%s/TEST/OAI/PERF/time_meas_prb%d_mcs%d_antrx%d_channel%s_tx%d.csv",
+	    getenv("OPENAIR_TARGETS"),
+	    N_RB_DL,mcs,n_rx,channel_model_input,transmission_mode);
+    time_meas_fd = fopen(time_meas_fname,"w");
+  }
 	
   if(abstx){
     sprintf(fperen_name,"ULchan_estims_F_mcs%d_rb%d_chanMod%d_nframes%d_chanReal%d.m",mcs,nb_rb,chMod,n_frames,n_ch_rlz);
@@ -807,6 +841,7 @@ int main(int argc, char **argv) {
       }
 
       avg_iter = 0; iter_trials=0;
+      reset_meas(&PHY_vars_UE->phy_proc_tx);
       reset_meas(&PHY_vars_UE->ofdm_mod_stats);
       reset_meas(&PHY_vars_UE->ulsch_modulation_stats);
       reset_meas(&PHY_vars_UE->ulsch_encoding_stats);
@@ -815,6 +850,8 @@ int main(int argc, char **argv) {
       reset_meas(&PHY_vars_UE->ulsch_turbo_encoding_stats);
       reset_meas(&PHY_vars_UE->ulsch_segmentation_stats);
       reset_meas(&PHY_vars_UE->ulsch_multiplexing_stats);
+      
+      reset_meas(&PHY_vars_eNB->phy_proc_rx);
       reset_meas(&PHY_vars_eNB->ofdm_demod_stats);
       reset_meas(&PHY_vars_eNB->ulsch_channel_estimation_stats);
       reset_meas(&PHY_vars_eNB->ulsch_freq_offset_estimation_stats);
@@ -877,6 +914,9 @@ int main(int argc, char **argv) {
 	  ///////////////////////////////////////
 	
 	  if (input_fdUL == NULL) {
+
+	    start_meas(&PHY_vars_UE->phy_proc_tx);
+
 #ifdef OFDMA_ULSCH
 	    if (srs_flag)
 	      generate_srs_tx(PHY_vars_UE,0,AMP,subframe);
@@ -925,7 +965,7 @@ int main(int argc, char **argv) {
 			     PHY_vars_UE->ulsch_ue[0]);
 #endif
 	    stop_meas(&PHY_vars_UE->ulsch_modulation_stats);	      	      	  
-
+	    
 	    if (n_frames==1) {
 	      write_output("txsigF0UL.m","txsF0", &PHY_vars_UE->lte_ue_common_vars.txdataF[0][PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size*nsymb*subframe],PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size*nsymb,1,1);
 	      //write_output("txsigF1.m","txsF1", PHY_vars_UE->lte_ue_common_vars.txdataF[0],FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX,1,1);          
@@ -954,7 +994,7 @@ int main(int argc, char **argv) {
 #endif
 	    
 	      stop_meas(&PHY_vars_UE->ofdm_mod_stats);	      	      
-	  
+	      stop_meas(&PHY_vars_UE->phy_proc_tx); 
 	      tx_lev += signal_energy(&txdata[aa][PHY_vars_eNB->lte_frame_parms.samples_per_tti*subframe],
 				      PHY_vars_eNB->lte_frame_parms.samples_per_tti);
 	
@@ -1067,7 +1107,7 @@ int main(int argc, char **argv) {
 
 #endif      
 
-
+	  start_meas(&PHY_vars_eNB->phy_proc_rx);
 	  start_meas(&PHY_vars_eNB->ofdm_demod_stats);	      	      	  
 	  lte_eNB_I0_measurements(PHY_vars_eNB,
 				  0,
@@ -1123,7 +1163,7 @@ int main(int argc, char **argv) {
 			      1,  // Nbundled 
 			      llr8_flag);
 	  stop_meas(&PHY_vars_eNB->ulsch_decoding_stats);
-
+	  stop_meas(&PHY_vars_eNB->phy_proc_rx);
 	  if (cqi_flag > 0) {
 	    cqi_error = 0;
 	    if (PHY_vars_eNB->ulsch_eNB[0]->Or1 < 32) {
@@ -1215,22 +1255,24 @@ int main(int argc, char **argv) {
 	     dB_fixed(PHY_vars_eNB->lte_eNB_pusch_vars[0]->ulsch_power[1]),
 	     PHY_vars_eNB->PHY_measurements_eNB->n0_power_dB[0],
 	     PHY_vars_eNB->PHY_measurements_eNB->n0_power_dB[1]);
-    
+
+      effective_rate = ((double)(round_trials[0])/((double)round_trials[0] + round_trials[1] + round_trials[2] + round_trials[3]));
+  
       printf("Errors (%d/%d %d/%d %d/%d %d/%d), Pe = (%e,%e,%e,%e) => effective rate %f (%3.1f%%,%f), normalized delay %f (%f)\n",
 	     errs[0],
 	     round_trials[0],
 	     errs[1],
-	     round_trials[0],
+	     round_trials[1],
 	     errs[2],
-	     round_trials[0],
+	     round_trials[2],
 	     errs[3],
-	     round_trials[0],
+	     round_trials[3],
 	     (double)errs[0]/(round_trials[0]),
 	     (double)errs[1]/(round_trials[0]),
 	     (double)errs[2]/(round_trials[0]),
 	     (double)errs[3]/(round_trials[0]),
-	     rate*((double)(round_trials[0])/((double)round_trials[0] + round_trials[1] + round_trials[2] + round_trials[3])),
-	     100*((double)(round_trials[0])/((double)round_trials[0] + round_trials[1] + round_trials[2] + round_trials[3])),
+	     rate*effective_rate,
+	     100*effective_rate,
 	     rate,
 	     (1.0*(round_trials[0]-errs[0])+2.0*(round_trials[1]-errs[1])+3.0*(round_trials[2]-errs[2])+4.0*(round_trials[3]-errs[3]))/((double)round_trials[0])/(double)PHY_vars_eNB->ulsch_eNB[0]->harq_processes[harq_pid]->TBS,
 	     (1.0*(round_trials[0]-errs[0])+2.0*(round_trials[1]-errs[1])+3.0*(round_trials[2]-errs[2])+4.0*(round_trials[3]-errs[3]))/((double)round_trials[0]));
@@ -1263,6 +1305,7 @@ int main(int argc, char **argv) {
 
       if (dump_perf==1) {
 	printf("UE TX function statistics (per 1ms subframe)\n\n");
+	printf("Total PHY proc tx                 :%f us (%d trials)\n",(double)PHY_vars_UE->phy_proc_tx.diff/PHY_vars_UE->phy_proc_tx.trials/cpu_freq_GHz/1000.0,PHY_vars_UE->phy_proc_tx.trials);
 	printf("OFDM_mod time                     :%f us (%d trials)\n",(double)PHY_vars_UE->ofdm_mod_stats.diff/PHY_vars_UE->ofdm_mod_stats.trials/cpu_freq_GHz/1000.0,PHY_vars_UE->ofdm_mod_stats.trials);
 	printf("ULSCH modulation time             :%f us (%d trials)\n",(double)PHY_vars_UE->ulsch_modulation_stats.diff/PHY_vars_UE->ulsch_modulation_stats.trials/cpu_freq_GHz/1000.0,PHY_vars_UE->ulsch_modulation_stats.trials);
 	printf("ULSCH encoding time               :%f us (%d trials)\n",(double)PHY_vars_UE->ulsch_encoding_stats.diff/PHY_vars_UE->ulsch_encoding_stats.trials/cpu_freq_GHz/1000.0,PHY_vars_UE->ulsch_encoding_stats.trials);
@@ -1273,6 +1316,7 @@ int main(int argc, char **argv) {
 	printf("|__ ULSCH multiplexing time           :%f us (%d trials)\n",((double)PHY_vars_UE->ulsch_multiplexing_stats.trials/PHY_vars_UE->ulsch_encoding_stats.trials)*(double)PHY_vars_UE->ulsch_multiplexing_stats.diff/PHY_vars_UE->ulsch_multiplexing_stats.trials/cpu_freq_GHz/1000.0,PHY_vars_UE->ulsch_multiplexing_stats.trials);
 
 	printf("\n\neNB RX function statistics (per 1ms subframe)\n\n");
+	printf("Total PHY proc rx                                   :%f us (%d trials)\n",(double)PHY_vars_eNB->phy_proc_rx.diff/PHY_vars_eNB->phy_proc_rx.trials/cpu_freq_GHz/1000.0,PHY_vars_eNB->phy_proc_rx.trials);
 	printf("OFDM_demod time                   :%f us (%d trials)\n",(double)PHY_vars_eNB->ofdm_demod_stats.diff/PHY_vars_eNB->ofdm_demod_stats.trials/cpu_freq_GHz/1000.0,PHY_vars_eNB->ofdm_demod_stats.trials);
 	printf("ULSCH demodulation time           :%f us (%d trials)\n",(double)PHY_vars_eNB->ulsch_demodulation_stats.diff/PHY_vars_eNB->ulsch_demodulation_stats.trials/cpu_freq_GHz/1000.0,PHY_vars_eNB->ulsch_demodulation_stats.trials);
 	printf("ULSCH Decoding time (%.2f Mbit/s, avg iter %f)      :%f us (%d trials, max %f)\n",
@@ -1338,7 +1382,73 @@ int main(int argc, char **argv) {
 	 
       } //ABStraction
       
-     
+      if ( (test_perf != 0) && (100 * effective_rate > test_perf )) {
+	fprintf(time_meas_fd,"SNR; MCS; TBS; rate; err0; trials0; err1; trials1; err2; trials2; err3; trials3\n");
+  	fprintf(time_meas_fd,"%f;%d;%d;%f;%d;%d;%d;%d;%d;%d;%d;%d\n",
+		SNR,
+		mcs,
+		PHY_vars_eNB->ulsch_eNB[0]->harq_processes[harq_pid]->TBS, 
+		rate,
+		errs[0],
+		round_trials[0],
+		errs[1],
+		round_trials[1],
+		errs[2],
+		round_trials[2],
+		errs[3],
+		round_trials[3]);
+	
+	fprintf(time_meas_fd,"SNR; MCS; TBS; rate; err0; trials0; err1; trials1; err2; trials2; err3; trials3;ND;\n");
+	fprintf(time_meas_fd,"%f;%d;%d;%f(%2.1f%%,%f);%d;%d;%d;%d;%d;%d;%d;%d;(%e,%e,%e,%e);%f(%f);\n",
+		SNR,
+		mcs,
+		PHY_vars_eNB->ulsch_eNB[0]->harq_processes[harq_pid]->TBS, 
+		rate*effective_rate,
+		100*effective_rate,
+		rate,
+		errs[0],
+		round_trials[0],
+		errs[1],
+		round_trials[1],
+		errs[2],
+		round_trials[2],
+		errs[3],
+		round_trials[3],
+		(double)errs[0]/(round_trials[0]),
+		(double)errs[1]/(round_trials[0]),
+		(double)errs[2]/(round_trials[0]),
+		(double)errs[3]/(round_trials[0]),
+		(1.0*(round_trials[0]-errs[0])+2.0*(round_trials[1]-errs[1])+3.0*(round_trials[2]-errs[2])+4.0*(round_trials[3]-errs[3]))/((double)round_trials[0])/(double)PHY_vars_eNB->ulsch_eNB[0]->harq_processes[harq_pid]->TBS, 
+		(1.0*(round_trials[0]-errs[0])+2.0*(round_trials[1]-errs[1])+3.0*(round_trials[2]-errs[2])+4.0*(round_trials[3]-errs[3]))/((double)round_trials[0]));
+
+	fprintf(time_meas_fd,"UE_PROC_TX(%d); OFDM_MOD(%d); UL_MOD(%d); UL_ENC(%d); eNB_PROC_RX(%d); OFDM_DEMOD(%d); UL_DEMOD(%d); UL_DECOD(%d);\n",
+		PHY_vars_UE->phy_proc_tx.trials,
+		PHY_vars_UE->ofdm_mod_stats.trials,
+		PHY_vars_UE->ulsch_modulation_stats.trials,
+		PHY_vars_UE->ulsch_encoding_stats.trials,
+		PHY_vars_eNB->phy_proc_rx.trials,
+		PHY_vars_eNB->ofdm_demod_stats.trials,
+		PHY_vars_eNB->ulsch_demodulation_stats.trials,
+		PHY_vars_eNB->ulsch_decoding_stats.trials
+		);
+	fprintf(time_meas_fd,"%f;%f;%f;%f;%f;%f;%f;%f",
+		get_time_meas_us(&PHY_vars_UE->phy_proc_tx),
+		get_time_meas_us(&PHY_vars_UE->ofdm_mod_stats),
+		get_time_meas_us(&PHY_vars_UE->ulsch_modulation_stats),
+		get_time_meas_us(&PHY_vars_UE->ulsch_encoding_stats),
+		get_time_meas_us(&PHY_vars_eNB->phy_proc_rx),
+		get_time_meas_us(&PHY_vars_eNB->ofdm_demod_stats),
+		get_time_meas_us(&PHY_vars_eNB->ulsch_demodulation_stats),
+		get_time_meas_us(&PHY_vars_eNB->ulsch_decoding_stats)
+		);
+	
+      	printf("[passed] effective rate : %f  (%2.1f%%,%f)): log and break \n",rate*effective_rate, 100*effective_rate, rate );
+	break;
+      } else if (test_perf !=0 ){
+	printf("[continue] effective rate : %f  (%2.1f%%,%f)): increase snr \n",rate*effective_rate, 100*effective_rate, rate);
+      }
+
+
       if (((double)errs[0]/(round_trials[0]))<1e-2) 
 	break;
     } // SNR	
@@ -1377,6 +1487,8 @@ int main(int argc, char **argv) {
     fclose(csv_fdUL);
   }
   fclose(bler_fd);
+  if (test_perf !=0)
+    fclose (time_meas_fd);
   
   printf("Freeing channel I/O\n");
   for (i=0;i<2;i++) {
diff --git a/targets/TEST/OAI/case11.py b/targets/TEST/OAI/case11.py
index 6145fc6004..4e0cf7f253 100644
--- a/targets/TEST/OAI/case11.py
+++ b/targets/TEST/OAI/case11.py
@@ -42,7 +42,7 @@ makerr1 = '***'
 makerr2 = 'Error 1'
 
 
-def execute(oai, user, pw, logfile,logdir):
+def execute(oai, user, pw, logfile,logdir,debug):
     
     case = '101'
      
diff --git a/targets/TEST/OAI/case12.py b/targets/TEST/OAI/case12.py
index 965f2de835..8c2bb743b1 100644
--- a/targets/TEST/OAI/case12.py
+++ b/targets/TEST/OAI/case12.py
@@ -48,8 +48,8 @@ NUM_UE=2
 NUM_eNB=1
 NUM_TRIALS=3
 
-PRB=[25,50,75,100]
-MCS=[4,5,7,9,12,15,18,21,24,27]
+PRB=[25]#,50,75,100]
+MCS=[4,5]#,7,9,12,15,18,21,24,27]
 ANT_TX=2  # 2 
 ANT_RX=2  # 2 
 PDCCH=2 #, 2, 3, 4
@@ -57,12 +57,15 @@ CHANNEL=["N"] # A,B,C,D,E,F,
 TX_MODE=2 # 2, 
 MIN_SNR=2
 MAX_SNR=18
+PERF=80
+OPT="-L"
+FRAME=500
 
 #OPT="-L -d" # 8bit decoder , activate dci decoding at UE
 
 
 
-def execute(oai, user, pw, logfile,logdir):
+def execute(oai, user, pw, logfile,logdir,debug):
     
     case = '102'
     oai.send('cd $OPENAIR1_DIR;')     
@@ -94,8 +97,7 @@ def execute(oai, user, pw, logfile,logdir):
         name = 'Run oai.dlsim.perf.70%'
         diag = 'no diagnostic is available, check the log file'
         for i in range(len(PRB)):
-            #for j in range(len(MCS)):
-            for j in range(0,28):
+            for j in range(len(MCS)):
                 for k in range(1,ANT_TX):
                     for m in range (1,ANT_RX):
                         for n in range(1,PDCCH):
@@ -106,16 +108,17 @@ def execute(oai, user, pw, logfile,logdir):
                                             
                                         #conf = '-B' + str(PRB[i]) + ' -m'+str(MCS[j]) + ' -y'+str(k) + ' -z'+str(m) +' -c'+str(n) + ' -g'+str(CHANNEL[o]) + ' -x'+str(p) + ' -s'+str(q) + ' -w1.0 -f.1 -n500 -P -O80' #+ OPT  
                                         #trace = logdir + '/time_meas' + '_prb'+str(PRB[i])+'_mcs'+ str(MCS[j])+ '_anttx' + str(k)+ '_antrx' + str(m)  + '_pdcch' + str(n) + '_channel' +str(CHANNEL[o]) + '_tx' +str(p) + '_snr' +str(q)+'.'+case+str(test)+ '.log'
-                                        conf = '-B' + str(PRB[i]) + ' -m'+str(j) + ' -y'+str(k) + ' -z'+str(m) +' -c'+str(n) + ' -g'+str(CHANNEL[o]) + ' -x'+str(p) + ' -s'+str(q) + ' -w1.0 -f.1 -n500 -P -O80' #+ OPT  
-                                        trace = logdir + '/time_meas' + '_prb'+str(PRB[i])+'_mcs'+ str(j)+ '_anttx' + str(k)+ '_antrx' + str(m)  + '_pdcch' + str(n) + '_channel' +str(CHANNEL[o]) + '_tx' +str(p) + '_snr' +str(q)+'.'+case+str(test)+ '.log'
+                                        conf = '-B' + str(PRB[i]) + ' -m'+str(MCS[j]) + ' -y'+str(k) + ' -z'+str(m) +' -c'+str(n) + ' -g'+str(CHANNEL[o]) + ' -x'+str(p) + ' -s'+str(q) + ' -w1.0 -f.1 -P -n'+str(FRAME)+' -O'+str(PERF)+' '+ OPT    
+                                        trace = logdir + '/time_meas' + '_prb'+str(PRB[i])+'_mcs'+ str(MCS[j])+ '_anttx' + str(k)+ '_antrx' + str(m)  + '_pdcch' + str(n) + '_channel' +str(CHANNEL[o]) + '_tx' +str(p) + '_snr' +str(q)+'.'+case+str(test)+ '.log'
                                         tee = ' 2>&1 | tee ' + trace
                                         match = oai.send_expect_re('./dlsim.rel8 ' + conf + tee, 'passed', 0, 1000)
-                                        #print conf
+                                        if debug : 
+                                            print conf
                                         if match :
                                             log.ok(case, str(test), name, conf, '', logfile)
                                             MIN_SNR = q # just to speed up the test
                                             test+=1
-                                            break; # found smallest snr
+                                            break; # found the smallest snr
                                         else :
                                             try:  
                                                 if os.path.isfile(trace) :
diff --git a/targets/TEST/OAI/case13.py b/targets/TEST/OAI/case13.py
new file mode 100644
index 0000000000..f799ac6666
--- /dev/null
+++ b/targets/TEST/OAI/case13.py
@@ -0,0 +1,130 @@
+#******************************************************************************
+
+#  Eurecom OpenAirInterface
+#  Copyright(c) 1999 - 2013 Eurecom
+
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms and conditions of the GNU General Public License,
+#  version 2, as published by the Free Software Foundation.
+
+#  This program is distributed in the hope it will be useful, but WITHOUT
+#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+#  more details.
+
+#  You should have received a copy of the GNU General Public License along with
+#  this program; if not, write to the Free Software Foundation, Inc.,
+#  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+#  The full GNU General Public License is included in this distribution in
+#  the file called "COPYING".
+
+#  Contact Information
+#  Openair Admin: openair_admin@eurecom.fr
+#  Openair Tech : openair_tech@eurecom.fr
+#  Forums       : http://forums.eurecom.fsr/openairinterface
+#  Address      : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France
+
+#*****************************************************************************
+
+# \file case02.py
+# \brief test case 02 for OAI: executions
+# \author Navid Nikaein
+# \date 2013
+# \version 0.1
+# @ingroup _test
+
+import time
+import random
+import log
+import openair 
+import core
+import os
+
+
+import shutil # copy file 
+
+NUM_UE=2
+NUM_eNB=1
+NUM_TRIALS=3
+
+PRB=[25]#,50,75,100]
+MCS=[4,5,7,9,12,15,18,21,24,27]
+ANT_TX=1  # 2 
+ANT_RX=2  # 2 
+CHANNEL=["N"] # A,B,C,D,E,F,
+TX_MODE=2 # 2, 
+MIN_SNR=2
+MAX_SNR=34
+PERF=80
+OPT="-L"
+FRAME=500
+#OPT="-L -d" # 8bit decoder , activate dci decoding at UE
+
+
+
+def execute(oai, user, pw, logfile,logdir,debug):
+    
+    case = '103'
+    oai.send('cd $OPENAIR1_DIR;')     
+    oai.send('cd SIMULATION/LTE_PHY;')   
+    
+    try:
+        test = '0'
+        name = 'Run oai.ulsim.sanity'
+        conf = '-a -n 100'
+        diag = 'ulsim is not running normally (Segmentation fault / Exiting / FATAL), debugging might be needed'
+        trace = logdir + '/log_' + case + test + '_1.txt;'
+        tee = ' 2>&1 | tee ' + trace
+        oai.send_expect_false('./ulsim.rel8 ' + conf + tee, 'Segmentation fault', 30)
+        trace = logdir + '/log_' + case + test + '_2.txt;'
+        tee = ' 2>&1 | tee ' + trace
+        oai.send_expect_false('./ulsim.rel8 ' + conf + tee, 'Exiting', 30)
+        trace = logdir + '/log_' + case + test + '_3.txt;'
+        tee = ' 2>&1 | tee ' + trace
+        oai.send_expect_false('./ulsim.rel8 ' + conf + tee, 'FATAL', 30)
+
+    except log.err, e:
+        log.fail(case, test, name, conf, e.value, diag, logfile,trace)
+    else:
+        log.ok(case, test, name, conf, '', logfile)
+    
+    try:
+        test = 1
+        MIN_SNR=2
+        name = 'Run oai.ulsim.perf.'+str(PERF)+'%'
+        diag = 'no diagnostic is available, check the log file'
+        for i in range(len(PRB)):
+            for j in range(len(MCS)):
+                for m in range (1,ANT_RX):
+                    for o in range(len(CHANNEL)):
+                        for p in range(1,TX_MODE):
+                            for q in range(MIN_SNR,MAX_SNR): 
+                                        #if  if PRB[i] :
+                                
+                                conf = '-B' + str(PRB[i]) + ' -m'+str(MCS[j]) + ' -y'+str(m) + ' -g'+str(CHANNEL[o]) + ' -x'+str(p) + ' -s'+str(q) + ' -w1.0 -e.1 -P -n'+str(FRAME)+' -O'+str(PERF)+' '+ OPT  
+                                trace = logdir + '/time_meas' + '_prb'+str(PRB[i])+'_mcs'+ str(MCS[j])+ '_antrx' + str(m)  + '_channel' +str(CHANNEL[o]) + '_tx' +str(p) + '_snr' +str(q)+'.'+case+str(test)+ '.log'
+                                tee = ' 2>&1 | tee ' + trace
+                                match = oai.send_expect_re('./ulsim.rel8 ' + conf + tee, 'passed', 0, 1000)
+                                if debug :
+                                    print conf
+                                if q == MAX_SNR :
+                                    log.skip(case,str(test), name, conf,'','',logfile)
+                                    
+                                if match :
+                                    log.ok(case, str(test), name, conf, '', logfile)
+                                    MIN_SNR = q # just to speed up the test
+                                    test+=1
+                                    break; # found the smallest snr
+                                else :
+                                    try:  
+                                        if os.path.isfile(trace) :
+                                            os.remove(trace)
+                                    except OSError, e:  ## if failed, report it back to the user ##
+                                        print ("Error: %s - %s." % (e.filename,e.strerror))
+                                            
+    except log.err, e:
+        log.fail(case, str(test), name, conf, e.value, diag, logfile,trace)
+    #else:
+    #    log.ok(case, test, name, conf, '', logfile)
+        
diff --git a/targets/TEST/OAI/test02.py b/targets/TEST/OAI/test02.py
index 35a8650d22..c79f87aaa7 100644
--- a/targets/TEST/OAI/test02.py
+++ b/targets/TEST/OAI/test02.py
@@ -46,6 +46,7 @@ import math #from time import clock
 import log
 import case11
 import case12
+import case13
 
 
 from  openair import *
@@ -109,8 +110,10 @@ oai.kill(user, pw)
 #oai.rm_driver(oai,user,pw)
 
 # start te test cases 
-case11.execute(oai, user, pw, logfile,logdir)
-case12.execute(oai, user, pw, logfile,logdir)
+#case11.execute(oai, user, pw, logfile,logdir,debug)
+#case12.execute(oai, user, pw, logfile,logdir,debug)
+case13.execute(oai, user, pw, logfile,logdir,debug)
+
 
 oai.kill(user, pw) 
 #oai.rm_driver(oai,user,pw)
-- 
GitLab