Changeset 2078
- Timestamp:
- Jun 27, 2008 9:12:12 PM (16 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/test-pjsua
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/inc_cfg.py
r2066 r2078 1 1 # $Id$ 2 2 import random 3 from config_site import *4 3 5 4 DEFAULT_ECHO = True 6 5 DEFAULT_TRACE = True 7 6 DEFAULT_START_SIP_PORT = 50000 7 8 # Shared vars 9 ARGS = [] # arguments containing script module & config 10 HAS_SND_DEV = 1 # specify 1 if system has sound device and prefer to use sound device in the tests 8 11 9 12 # Individual pjsua instance configuration class … … 76 79 test_func = None 77 80 post_func = None 78 user_data = None79 81 def __init__( self, 80 82 title, # Test title … … 82 84 func=None, 83 85 skip=False, 84 post_func=None, 85 user_data=None): 86 post_func=None): 86 87 self.title = title 87 88 self.inst_params = inst_params … … 89 90 self.test_func = func 90 91 self.post_func = post_func 91 self.user_data = user_data92 92 93 93 -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_call.py
r2071 r2078 7 7 8 8 # Load configuration 9 cfg_file = imp.load_source("cfg_file", sys.argv[2])9 cfg_file = imp.load_source("cfg_file", ARGS[1]) 10 10 11 11 # Check media flow between ua1 and ua2 … … 21 21 22 22 # Test body function 23 def test_func(t , user_data):23 def test_func(t): 24 24 callee = t.process[0] 25 25 caller = t.process[1] -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_media_playrec.py
r2052 r2078 15 15 import subprocess 16 16 import inc_const as const 17 from inc_cfg import * 17 18 18 19 # Load configuration 19 cfg_file = imp.load_source("cfg_file", sys.argv[2])20 cfg_file = imp.load_source("cfg_file", ARGS[1]) 20 21 21 22 # WAV similarity calculator … … 25 26 COMPARE_THRESHOLD = 2 26 27 27 # UserData 28 class mod_media_playrec_user_data: 29 input_filename = "" 30 output_filename = "" 28 # COMPARE params 29 input_filename = "" # Input filename 30 output_filename = "" # Output filename 31 31 32 32 # Test body function 33 33 def test_func(t, ud): 34 global input_filename 35 global output_filename 36 34 37 endpt = t.process[0] 35 38 … … 68 71 # Post body function 69 72 def post_func(t, ud): 73 global input_filename 74 global output_filename 75 70 76 endpt = t.process[0] 71 77 … … 94 100 test.test_func = test_func 95 101 test.post_func = post_func 96 test.user_data = mod_media_playrec_user_data() -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
r2075 r2078 22 22 23 23 # Load configuration 24 cfg_file = imp.load_source("cfg_file", sys.argv[2])24 cfg_file = imp.load_source("cfg_file", ARGS[1]) 25 25 26 26 # PESQ configs 27 # PESQ_THRESHOLD specifies the minimum acceptable PESQ MOS value, so test can be declared successful 28 PESQ = "tools/pesq.exe" 29 PESQ_DEFAULT_THRESHOLD = 3.4 27 PESQ = "tools/pesq.exe" # PESQ executable path 28 PESQ_DEFAULT_THRESHOLD = 3.4 # Default minimum acceptable PESQ MOS value 30 29 31 # UserData 32 class mod_pesq_user_data: 33 # Sample rate option for PESQ 34 pesq_sample_rate_opt = "" 35 # Input/Reference filename 36 input_filename = "" 37 # Output/Degraded filename 38 output_filename = "" 30 # PESQ params 31 pesq_sample_rate_opt = "" # Sample rate option for PESQ 32 input_filename = "" # Input/Reference filename 33 output_filename = "" # Output/Degraded filename 34 39 35 40 36 # Test body function 41 def test_func(t, user_data): 37 def test_func(t): 38 global pesq_sample_rate_opt 39 global input_filename 40 global output_filename 42 41 43 42 ua1 = t.process[0] … … 45 44 46 45 # Get input file name 47 user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1)46 input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1) 48 47 49 48 # Get output file name 50 user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1)49 output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 51 50 52 51 # Get WAV input length, in seconds 53 fin = wave.open( user_data.input_filename, "r")52 fin = wave.open(input_filename, "r") 54 53 if fin == None: 55 54 raise TestError("Failed opening input WAV file") … … 60 59 61 60 # Get clock rate of the output 62 mo_clock_rate = re.compile("\.(\d+)\.wav").search( user_data.output_filename)61 mo_clock_rate = re.compile("\.(\d+)\.wav").search(output_filename) 63 62 if (mo_clock_rate==None): 64 63 raise TestError("Cannot compare input & output, incorrect output filename format") … … 73 72 # (PESQ evaluates only files whose same clock rate & channel count) 74 73 if channel_count == 2: 75 if re.search("\.\d+\.\d+\.wav", user_data.input_filename) != None: 76 user_data.input_filename = re.sub("\.\d+\.\d+\.wav", 77 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 74 if re.search("\.\d+\.\d+\.wav", input_filename) != None: 75 input_filename = re.sub("\.\d+\.\d+\.wav", "." + str(channel_count) + "."+clock_rate+".wav", input_filename) 78 76 else: 79 user_data.input_filename = re.sub("\.\d+\.wav", 80 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 77 input_filename = re.sub("\.\d+\.wav", "." + str(channel_count) + "."+clock_rate+".wav", input_filename) 81 78 82 79 if (clock_rate != "8") & (clock_rate != "16"): … … 84 81 85 82 # Get conference clock rate of UA2 for PESQ sample rate option 86 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000"83 pesq_sample_rate_opt = "+" + clock_rate + "000" 87 84 88 85 # UA1 making call … … 114 111 115 112 # Post body function 116 def post_func(t, user_data): 113 def post_func(t): 114 global pesq_sample_rate_opt 115 global input_filename 116 global output_filename 117 117 118 endpt = t.process[0] 118 119 119 120 # Execute PESQ 120 fullcmd = PESQ + " " + user_data.pesq_sample_rate_opt + " " + user_data.input_filename + " " + user_data.output_filename121 fullcmd = PESQ + " " + pesq_sample_rate_opt + " " + input_filename + " " + output_filename 121 122 endpt.trace("Popen " + fullcmd) 122 123 pesq_proc = subprocess.Popen(fullcmd, stdout=subprocess.PIPE, universal_newlines=True) … … 147 148 test.test_func = test_func 148 149 test.post_func = post_func 149 test.user_data = mod_pesq_user_data()150 150 -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pres.py
r2070 r2078 4 4 import sys 5 5 import inc_const as const 6 from inc_cfg import * 6 7 7 8 # Load configuration 8 cfg_file = imp.load_source("cfg_file", sys.argv[2])9 cfg_file = imp.load_source("cfg_file", ARGS[1]) 9 10 10 11 11 12 # Test body function 12 def test_func(t , user_data):13 def test_func(t): 13 14 u1 = t.process[0] 14 15 uri1 = cfg_file.test_param.inst_params[0].uri -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_run.py
r2025 r2078 1 # $Id :$1 # $Id$ 2 2 import imp 3 3 import sys 4 4 5 from inc_cfg import * 5 6 6 7 # Read configuration 7 cfg_file = imp.load_source("cfg_file", sys.argv[2])8 cfg_file = imp.load_source("cfg_file", ARGS[1]) 8 9 9 10 # Here where it all comes together -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_sendto.py
r2066 r2078 8 8 9 9 # Read configuration 10 cfg_file = imp.load_source("cfg_file", sys.argv[2])10 cfg_file = imp.load_source("cfg_file", ARGS[1]) 11 11 12 12 # Test body function 13 def test_func(t , userdata):13 def test_func(t): 14 14 pjsua = t.process[0] 15 15 # Create dialog -
pjproject/trunk/pjsip-apps/src/test-pjsua/run.py
r2069 r2078 7 7 import random 8 8 import time 9 import getopt 9 10 10 11 import inc_const as const 11 from inc_cfg import * 12 import inc_cfg as inc 13 14 # Vars 15 G_EXE = "" # pjsua executable path 16 G_INUNIX = False # flags that test is running in Unix 17 18 19 # Usage string 20 usage = \ 21 """ 22 run.py - Automated test driver 23 24 Usage: 25 run.py [options] MODULE CONFIG 26 Options: 27 --exe, -e pjsua executable path 28 --null-audio, -n use null audio 29 Sample: 30 run.py -n mod_run.py scripts-run/100_simple.py 31 """ 32 33 # Parse arguments 34 try: 35 opts, args = getopt.getopt(sys.argv[1:], "hne:", ["help", "null-audio", "exe="]) 36 except getopt.GetoptError, err: 37 print str(err) 38 print usage 39 sys.exit(2) 40 for o, a in opts: 41 if o in ("-h", "--help"): 42 print usage 43 sys.exit() 44 elif o in ("-n", "--null-audio"): 45 inc.HAS_SND_DEV = 0 46 elif o in ("-e", "--exe"): 47 G_EXE = a 48 else: 49 print "Unknown options" 50 sys.exit(2) 51 52 if len(args) != 2: 53 print "Invalid arguments" 54 print usage 55 sys.exit(2) 56 57 # Set global ARGS to be used by modules 58 inc.ARGS = args 12 59 13 60 # Get the pjsua executable name 14 if sys.platform.find("win32")!=-1: 15 e = "../../bin/pjsua_vc6d.exe" 16 st1 = os.stat(e) 17 if st1 != None: 18 G_EXE = e 19 e = "../../bin/pjsua_vc6d.exe" 20 st2 = os.stat(e) 21 if st2 != None and st2.st_mtime > st1.st_mtime: 22 G_EXE = e 23 st1 = st2 24 if G_EXE=="": 25 print "Unable to find valid pjsua. Please build pjsip first" 26 sys.exit(1) 27 G_INUNIX = False 28 else: 29 f = open("../../../build.mak", "r") 30 while True: 31 line = f.readline() 32 if not line: 33 break 34 if line.find("TARGET_NAME")!=-1: 35 print line 36 G_EXE="../../bin/pjsua-" + line.split(":= ")[1] 37 break 38 if G_EXE=="": 39 print "Unable to find ../../../build.mak. Please build pjsip first" 40 sys.exit(1) 41 G_INUNIX = True 61 if G_EXE == "": 62 if sys.platform.find("win32")!=-1: 63 e = "../../bin/pjsua_vc6d.exe" 64 st1 = os.stat(e) 65 if st1 != None: 66 G_EXE = e 67 e = "../../bin/pjsua_vc6d.exe" 68 st2 = os.stat(e) 69 if st2 != None and st2.st_mtime > st1.st_mtime: 70 G_EXE = e 71 st1 = st2 72 if G_EXE=="": 73 print "Unable to find valid pjsua. Please build pjsip first" 74 sys.exit(1) 75 G_INUNIX = False 76 else: 77 f = open("../../../build.mak", "r") 78 while True: 79 line = f.readline() 80 if not line: 81 break 82 if line.find("TARGET_NAME")!=-1: 83 print line 84 G_EXE="../../bin/pjsua-" + line.split(":= ")[1] 85 break 86 if G_EXE=="": 87 print "Unable to find ../../../build.mak. Please build pjsip first" 88 sys.exit(1) 89 G_INUNIX = True 42 90 43 91 … … 75 123 line = self.proc.stdout.readline() 76 124 if line == "": 77 raise TestError(self.name + ": Premature EOF")125 raise inc.TestError(self.name + ": Premature EOF") 78 126 # Print the line if echo is ON 79 127 if self.echo: … … 82 130 if self.ra.search(line) != None: 83 131 if raise_on_error: 84 raise TestError(self.name + ": " + line)132 raise inc.TestError(self.name + ": " + line) 85 133 else: 86 134 return None … … 91 139 self.trace("Timed-out!") 92 140 if raise_on_error: 93 raise TestError(self.name + " " + title + ": Timeout expecting pattern: \"" + pattern + "\"")141 raise inc.TestError(self.name + " " + title + ": Timeout expecting pattern: \"" + pattern + "\"") 94 142 else: 95 143 return None # timeout … … 131 179 # MAIN 132 180 133 if len(sys.argv)!=3:134 print "Usage: run.py MODULE CONFIG"135 print "Sample:"136 print " run.py mod_run.py scripts-run/100_simple.py"137 sys.exit(1)138 139 140 181 # Import the test script 141 script = imp.load_source("script", sys.argv[1])182 script = imp.load_source("script", inc.ARGS[0]) 142 183 143 184 # Init random seed … … 177 218 script.test.process.append(p) 178 219 179 except TestError, e:220 except inc.TestError, e: 180 221 handle_error(e.desc, script.test) 181 222 … … 183 224 if script.test.test_func != None: 184 225 try: 185 script.test.test_func(script.test , script.test.user_data)186 except TestError, e:226 script.test.test_func(script.test) 227 except inc.TestError, e: 187 228 handle_error(e.desc, script.test) 188 229 … … 204 245 if script.test.post_func != None: 205 246 try: 206 script.test.post_func(script.test , script.test.user_data)207 except TestError, e:247 script.test.post_func(script.test) 248 except inc.TestError, e: 208 249 handle_error(e.desc, script.test, False) 209 250 -
pjproject/trunk/pjsip-apps/src/test-pjsua/runall.py
r2071 r2078 3 3 import sys 4 4 import time 5 import re 6 import shutil 7 5 8 6 9 # Usage: … … 54 57 resume_script="" 55 58 if len(sys.argv) > 1: 56 if sys.argv[1][0]=='-' or sys.argv[1][0]=='/': 59 if sys.argv[1]=='-r' or sys.argv[1]=='--resume': 60 resume_script=sys.argv[2] 61 if sys.argv[1]=='/h' or sys.argv[1]=='-h' or sys.argv[1]=='--help' or sys.argv[1]=='/help': 57 62 print "Usage:" 58 print " runall.py [RESUME]" 59 print "where" 60 print " RESUME is string/substring to specify where to resume tests." 61 print " If this argument is omited, tests will start from the beginning." 63 print " runall.py [OPTIONS] [run.py OPTIONS]" 64 print "Options:" 65 print " --resume,-r RESUME" 66 print " where" 67 print " RESUME is string/substring to specify where to resume tests." 68 print " If this argument is omited, tests will start from the beginning." 62 69 sys.exit(0) 63 resume_script=sys.argv[1]64 70 71 72 # Generate arguments for run.py 73 argv = sys.argv 74 argv_to_skip = 1 75 if resume_script != "": 76 argv_to_skip += 2 77 argv_st = "" 78 for a in argv: 79 if argv_to_skip > 0: 80 argv_to_skip -= 1 81 else: 82 argv_st += a + " " 83 84 85 # Init vars 86 failed_cnt = 0 87 88 # Create "logs" directory 89 try: 90 os.mkdir("logs") 91 except: 92 print 65 93 66 94 # Now run the tests … … 70 98 continue 71 99 resume_script="" 72 cmdline = "python run.py " + t100 cmdline = "python run.py " + argv_st + t 73 101 t0 = time.time() 74 102 print "Running " + cmdline + "...", … … 78 106 dur = int(t1 - t0) 79 107 print " failed!! [" + str(dur) + "s]" 80 print "Please see 'output.log' for the test log." 81 sys.exit(1) 108 logname = re.search(".*\s+(.*)", t).group(1) 109 logname = re.sub("[\\\/]", "_", logname) 110 logname = "logs/" + logname 111 shutil.move("output.log", logname) 112 print "Please see '" + logname + "' for the test log." 82 113 else: 83 114 dur = int(t1 - t0) 84 115 print " ok [" + str(dur) + "s]" 85 116 86 print "All tests completed successfully" 117 if failed_cnt == 0: 118 print "All tests completed successfully" 119 else: 120 print "Tests completed, with " + str(failed_cnt) + " test(s) failed" 121
Note: See TracChangeset
for help on using the changeset viewer.