Changeset 2078 for pjproject/trunk/pjsip-apps/src/test-pjsua/run.py
- Timestamp:
- Jun 27, 2008 9:12:12 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.