From a055962b1ebec47ce56a5a1454c9333ece407f49 Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Mon, 19 May 2014 13:24:34 +0000
Subject: [PATCH] * update the oai test 02 for performance benchmarking

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5329 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 targets/TEST/OAI/case11.py  |  6 ++++--
 targets/TEST/OAI/case12.py  | 26 ++++++++++++++++----------
 targets/TEST/OAI/case13.py  | 18 +++++++++++-------
 targets/TEST/OAI/openair.py | 14 ++++++++++++++
 targets/TEST/OAI/test02.py  | 23 ++++++++++++++++++-----
 5 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/targets/TEST/OAI/case11.py b/targets/TEST/OAI/case11.py
index 4e0cf7f253..e8da76b3be 100644
--- a/targets/TEST/OAI/case11.py
+++ b/targets/TEST/OAI/case11.py
@@ -45,7 +45,7 @@ makerr2 = 'Error 1'
 def execute(oai, user, pw, logfile,logdir,debug):
     
     case = '101'
-     
+    rv  = 1; 
     oai.send('cd $OPENAIR1_DIR;')     
     oai.send('cd SIMULATION/LTE_PHY;')   
 
@@ -62,6 +62,7 @@ def execute(oai, user, pw, logfile,logdir,debug):
         oai.send('cp ./dlsim ./dlsim.rel8;')
     except log.err, e:
         log.fail(case, test, name, conf, e.value, diag, logfile,trace)
+        rv =0
     else:
         log.ok(case, test, name, conf, '', logfile)
 
@@ -78,7 +79,8 @@ def execute(oai, user, pw, logfile,logdir,debug):
         oai.send('cp ./ulsim ./ulsim.rel8;')
     except log.err, e:
         log.fail(case, test, name, conf, e.value, diag, logfile,trace)
+        rv = 0
     else:
         log.ok(case, test, name, conf, '', logfile)
     
-
+    return rv
diff --git a/targets/TEST/OAI/case12.py b/targets/TEST/OAI/case12.py
index 8c2bb743b1..aae71c8fda 100644
--- a/targets/TEST/OAI/case12.py
+++ b/targets/TEST/OAI/case12.py
@@ -49,15 +49,15 @@ NUM_eNB=1
 NUM_TRIALS=3
 
 PRB=[25]#,50,75,100]
-MCS=[4,5]#,7,9,12,15,18,21,24,27]
+MCS=[4,5,7,9,12,15,18,21,24,27]
 ANT_TX=2  # 2 
 ANT_RX=2  # 2 
 PDCCH=2 #, 2, 3, 4
 CHANNEL=["N"] # A,B,C,D,E,F,
 TX_MODE=2 # 2, 
 MIN_SNR=2
-MAX_SNR=18
-PERF=80
+MAX_SNR=34
+PERF=75
 OPT="-L"
 FRAME=500
 
@@ -94,7 +94,7 @@ def execute(oai, user, pw, logfile,logdir,debug):
     try:
         test = 1
         MIN_SNR = 2
-        name = 'Run oai.dlsim.perf.70%'
+        name = 'Run oai.dlsim.perf.'+str(PERF)+'%'
         diag = 'no diagnostic is available, check the log file'
         for i in range(len(PRB)):
             for j in range(len(MCS)):
@@ -105,21 +105,24 @@ def execute(oai, user, pw, logfile,logdir,debug):
                                 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(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(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    
+                                                                          
+                                        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)
                                         if debug : 
                                             print conf
+                                                                              
                                         if match :
                                             log.ok(case, str(test), name, conf, '', logfile)
-                                            MIN_SNR = q # just to speed up the test
+                                            MIN_SNR = q -1 # just to speed up the test
                                             test+=1
-                                            break; # found the smallest snr
+                                            break # found the smallest snr
                                         else :
+                                            if q == MAX_SNR -1 :
+                                                log.skip(case,str(test), name, conf,'','',logfile) 
+                                                test+=1
+                                                break # do not remove the last log file
                                             try:  
                                                 if os.path.isfile(trace) :
                                                     os.remove(trace)
@@ -127,6 +130,9 @@ def execute(oai, user, pw, logfile,logdir,debug):
                                             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:
diff --git a/targets/TEST/OAI/case13.py b/targets/TEST/OAI/case13.py
index f799ac6666..113d72e733 100644
--- a/targets/TEST/OAI/case13.py
+++ b/targets/TEST/OAI/case13.py
@@ -56,7 +56,7 @@ CHANNEL=["N"] # A,B,C,D,E,F,
 TX_MODE=2 # 2, 
 MIN_SNR=2
 MAX_SNR=34
-PERF=80
+PERF=75
 OPT="-L"
 FRAME=500
 #OPT="-L -d" # 8bit decoder , activate dci decoding at UE
@@ -102,26 +102,30 @@ def execute(oai, user, pw, logfile,logdir,debug):
                             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  
+                                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
+                                    MIN_SNR = q - 1 # just to speed up the test
                                     test+=1
-                                    break; # found the smallest snr
+                                    break # found the smallest snr
                                 else :
+                                    if q == MAX_SNR -1 :
+                                        log.skip(case,str(test), name, conf,'','',logfile) 
+                                        test+=1
+                                        break
                                     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)
diff --git a/targets/TEST/OAI/openair.py b/targets/TEST/OAI/openair.py
index 8713aefcae..84e09ac41b 100644
--- a/targets/TEST/OAI/openair.py
+++ b/targets/TEST/OAI/openair.py
@@ -170,3 +170,17 @@ class openair(core):
             oai.send_nowait('cd '+ pwd)  
         except Error, val:
             print "Error inserting oai network driver module:", val
+    
+    def cleandir (self, logdir,debug) :
+        
+        for filename in os.listdir(logdir):
+            filepath = os.path.join(logdir, filename)
+            if debug == 2 :
+                print 'logdir is ' + logdir
+                print 'filepath is ' + filepath 
+            try:
+                shutil.rmtree(filepath)
+            except OSError:
+                os.remove(filepath)
+                #print 'Could not remove the filepath'+ filepath + ' with error ' + OSError
+    
diff --git a/targets/TEST/OAI/test02.py b/targets/TEST/OAI/test02.py
index c79f87aaa7..beb9d67efe 100644
--- a/targets/TEST/OAI/test02.py
+++ b/targets/TEST/OAI/test02.py
@@ -55,6 +55,8 @@ debug = 0
 prompt = '$'
 pw =''
 i = 0
+clean = 0 
+start_case  = 0
 for arg in sys.argv:
     if arg == '-d':
         debug = 1
@@ -64,11 +66,16 @@ for arg in sys.argv:
         prompt = sys.argv[i+1]
     elif arg == '-w' :
         pw = sys.argv[i+1]
+    elif arg == '-c' :
+        clean = 1
+    elif arg == '-s' :
+        start_case = sys.argv[i+1]
     elif arg == '-h' :
         print "-d:  low debug level"
         print "-dd: high debug level"
         print "-p:  set the prompt"
         print "-w:  set the password for ssh to localhost"
+        print "-c: clean the log directory "
         sys.exit()
     i= i + 1     
 
@@ -106,14 +113,20 @@ oai.send_nowait('mkdir -p -m 755' + logdir + ';')
 log.writefile(logfile,'====================start'+test+' at ' + ctime + '=======================\n')
 log.set_debug_level(debug)
 
-oai.kill(user, pw)   
+oai.kill(user, pw)
+if clean == 1 :
+    oai.cleandir(logdir,debug)   
+
 #oai.rm_driver(oai,user,pw)
 
 # start te test cases 
-#case11.execute(oai, user, pw, logfile,logdir,debug)
-#case12.execute(oai, user, pw, logfile,logdir,debug)
-case13.execute(oai, user, pw, logfile,logdir,debug)
-
+#compile 
+rv=case11.execute(oai, user, pw, logfile,logdir,debug)
+if rv != 0 :
+    case12.execute(oai, user, pw, logfile,logdir,debug)
+    case13.execute(oai, user, pw, logfile,logdir,debug)
+else :
+    print 'Compilation error: skip case 12 and 13'
 
 oai.kill(user, pw) 
 #oai.rm_driver(oai,user,pw)
-- 
GitLab