test02.py 4.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#******************************************************************************

#  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 test01.py
# \brief test 02 for OAI: downlink and uplink performance and profiler
# \author Navid Nikaein
# \date 2014
# \version 0.1
# @ingroup _test


import sys
import wave
import os
import time
import datetime
import getpass
import math #from time import clock 

import log
import case11
import case12
49
import case13
50 51 52 53 54 55 56 57


from  openair import *

debug = 0
prompt = '$'
pw =''
i = 0
58 59
clean = 0 
start_case  = 0
60 61 62 63 64 65 66 67 68
for arg in sys.argv:
    if arg == '-d':
        debug = 1
    elif arg == '-dd':
        debug = 2
    elif arg == '-p' :
        prompt = sys.argv[i+1]
    elif arg == '-w' :
        pw = sys.argv[i+1]
69 70 71 72
    elif arg == '-c' :
        clean = 1
    elif arg == '-s' :
        start_case = sys.argv[i+1]
73 74 75 76 77
    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"
78
        print "-c: clean the log directory "
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
        sys.exit()
    i= i + 1     

# get the oai object
oai = openair('localdomain','localhost')
#start_time = time.time()  # datetime.datetime.now()
try: 
    user = getpass.getuser()
    print '\n******* Note that the user <'+user+'> should be a sudoer *******\n'
    print '******* Connecting to the localhost to perform the test *******\n'
   
    if not pw :
        print "username: " + user 
        pw = getpass.getpass() 
    else :
        print "username: " + user 
        #print "password: " + pw 
    print "prompt:   " + prompt
    
    oai.connect(user,pw,prompt)
    #oai.get_shell()
except :
    print 'Fail to connect to the local host'
    sys.exit(1)


test = 'test02'
ctime=datetime.datetime.utcnow().strftime("%Y-%m-%d.%Hh%M")
logdir = os.getcwd() + '/PERF';
logfile = logdir+'/'+user+'.'+test+'.'+ctime+'.txt'  
oai.send_nowait('mkdir -p -m 755' + logdir + ';')
  
#print '=================start the ' + test + ' at ' + ctime + '=================\n'
#print 'Results will be reported in log file : ' + logfile
log.writefile(logfile,'====================start'+test+' at ' + ctime + '=======================\n')
log.set_debug_level(debug)

116 117 118 119
oai.kill(user, pw)
if clean == 1 :
    oai.cleandir(logdir,debug)   

120 121 122
#oai.rm_driver(oai,user,pw)

# start te test cases 
123 124 125 126 127 128 129
#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'
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

oai.kill(user, pw) 
#oai.rm_driver(oai,user,pw)

# perform the stats
log.statistics(logfile)


oai.disconnect()

ctime=datetime.datetime.utcnow().strftime("%Y-%m-%d_%Hh%M")
log.writefile(logfile,'====================end the '+ test + ' at ' + ctime +'====================')
print 'Test results can be found in : ' + logfile 
#print '\nThis test took %f minutes\n' % math.ceil((time.time() - start_time)/60) 

#print '\n=====================end the '+ test + ' at ' + ctime + '====================='