Changeset 2025 for pjproject/trunk/pjsip-apps/src/test-pjsua/run.py
- Timestamp:
- Jun 15, 2008 7:43:43 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/run.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 6 6 import time 7 7 8 import inc_param as param9 8 import inc_const as const 10 9 11 10 # Defaults 12 G_ECHO=True13 G_TRACE=False14 11 G_EXE="..\\..\\bin\\pjsua_vc6d.exe" 15 12 … … 28 25 trace_enabled = False 29 26 name = "" 27 inst_param = None 30 28 rh = re.compile(const.DESTROYED) 31 29 ra = re.compile(const.ASSERT, re.I) 32 30 rr = re.compile(const.STDOUT_REFRESH) 33 def __init__(self, name, exe, args="", echo=G_ECHO, trace_enabled=G_TRACE): 34 self.name = name 35 self.echo = echo 36 self.trace_enabled = trace_enabled 37 fullcmd = exe + " " + args + " --stdout-refresh=5 --stdout-refresh-text=" + const.STDOUT_REFRESH 31 def __init__(self, inst_param): 32 self.inst_param = inst_param 33 self.name = inst_param.name 34 self.echo = inst_param.echo_enabled 35 self.trace_enabled = inst_param.trace_enabled 36 fullcmd = G_EXE + " " + inst_param.arg + " --stdout-refresh=5 --stdout-refresh-text=" + const.STDOUT_REFRESH 38 37 self.trace("Popen " + fullcmd) 39 38 self.proc = subprocess.Popen(fullcmd, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) … … 70 69 if r.search(line) != None: 71 70 return line 71 72 def sync_stdout(self): 73 self.trace("sync_stdout") 74 self.send("echo 1") 75 self.expect("echo 1") 76 72 77 def wait(self): 73 78 self.trace("wait") … … 83 88 time.sleep(1) 84 89 for p in t.process: 90 p.send("q") 85 91 p.send("q") 86 92 p.expect(const.DESTROYED, False) … … 108 114 sys.exit(1) 109 115 110 if len(script.test. run) == 0:116 if len(script.test.inst_params) == 0: 111 117 print "Error: test doesn't contain pjsua run descriptions" 112 118 sys.exit(1) … … 114 120 # Instantiate pjsuas 115 121 print "====== Running " + script.test.title + " ======" 116 for run in script.test.run:122 for inst_param in script.test.inst_params: 117 123 try: 118 p = Expect(run.name, G_EXE, args=run.args, echo=run.echo, trace_enabled=run.trace) 119 # Wait until initialized 124 # Create pjsua's Expect instance from the param 125 p = Expect(inst_param) 126 # Wait until registration completes 127 if inst_param.have_reg: 128 p.expect(inst_param.uri+".*registration success") 129 # Synchronize stdout 130 p.send("") 120 131 p.expect(const.PROMPT) 121 132 p.send("echo 1") … … 124 135 # add running instance 125 136 script.test.process.append(p) 126 # run initial script127 for cmd in run.cmds:128 if len(cmd) >= 3 and cmd[2]!="":129 print "====== " + cmd[2] + " ======"130 if len(cmd) >= 1 and cmd[0]!="":131 p.send(cmd[0])132 if len(cmd) >= 2 and cmd[1]!="":133 p.expect(cmd[1])134 137 135 138 except TestError, e: … … 146 149 time.sleep(2) 147 150 for p in script.test.process: 151 # Unregister if we have_reg to make sure that next tests 152 # won't wail 153 if p.inst_param.have_reg: 154 p.send("ru") 155 p.expect(p.inst_param.uri+".*unregistration success") 156 p.send("q") 148 157 p.send("q") 149 158 time.sleep(0.5)
Note: See TracChangeset
for help on using the changeset viewer.