Changeset 4183 for pjproject/trunk/tests/pjsua/mod_sipp.py
- Timestamp:
- Jun 28, 2012 9:16:03 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/tests/pjsua/mod_sipp.py
r4179 r4183 17 17 G_INUNIX = True 18 18 19 # /dev/null handle, for redirecting output when SIPP is not in background mode 20 FDEVNULL = None 21 19 22 # SIPp executable path and param 20 23 #SIPP_PATH = '"C:\\Program Files (x86)\\Sipp_3.2\\sipp.exe"' … … 25 28 # On non-BG mode, on win, it needs env var: "TERMINFO=c:\cygwin\usr\share\terminfo" 26 29 # TODO: on unix with BG mode, waitpid() always fails, need to be fixed 27 #SIPP_BG_MODE = True28 SIPP_BG_MODE = not G_INUNIX30 SIPP_BG_MODE = False 31 #SIPP_BG_MODE = not G_INUNIX 29 32 30 33 # Will be updated based on configuration file (a .py file whose the same name as SIPp XML file) … … 80 83 sipp_proc = subprocess.Popen(fullcmd, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=G_INUNIX, universal_newlines=False) 81 84 else: 82 sipp_proc = subprocess.Popen(fullcmd, shell=G_INUNIX) 85 # redirect output to NULL 86 global FDEVNULL 87 FDEVNULL = open(os.devnull, 'w') 88 sipp_proc = subprocess.Popen(fullcmd, shell=G_INUNIX, stdout=FDEVNULL, stderr=FDEVNULL) 83 89 84 90 if not SIPP_BG_MODE: … … 115 121 def wait_sipp(sipp): 116 122 if not SIPP_BG_MODE: 123 global FDEVNULL 117 124 sipp.wait() 125 FDEVNULL.close() 118 126 return sipp.returncode 119 127 … … 176 184 # Ideally the poll should be done contiunously until SIPp process is 177 185 # terminated. 178 ua[0].expect(inc_const.STDOUT_REFRESH, raise_on_error = False) 186 for ua_idx in range(len(ua)): 187 ua[ua_idx].expect(inc_const.STDOUT_REFRESH, raise_on_error = False) 179 188 180 189 return ua_err_st 190 191 192 def sipp_err_to_str(err_code): 193 if err_code == 0: 194 return "All calls were successful" 195 elif err_code == 1: 196 return "At least one call failed" 197 elif err_code == 97: 198 return "exit on internal command. Calls may have been processed" 199 elif err_code == 99: 200 return "Normal exit without calls processed" 201 elif err_code == -1: 202 return "Fatal error (timeout)" 203 elif err_code == -2: 204 return "Fatal error binding a socket" 205 else: 206 return "Unknown error" 181 207 182 208 … … 199 225 200 226 if sipp_ret_code: 201 raise TestError("SIPp returned error " + str(sipp_ret_code)) 227 rc = ctypes.c_byte(sipp_ret_code).value 228 raise TestError("SIPp returned error " + str(rc) + ": " + sipp_err_to_str(rc)) 202 229 203 230
Note: See TracChangeset
for help on using the changeset viewer.