1
# $Id: runall.py 4183 2012-06-28 09:16:03Z nanang $
8
PYTHON = os.path.basename(sys.executable)
11
# runall.py [test-to-resume]
14
# Initialize test list
17
# Excluded tests (because they fail?)
18
excluded_tests = [ "svn",
20
"scripts-call/150_srtp_2_1", # SRTP optional 'cannot' call SRTP mandatory
21
"scripts-call/150_srtp_2_3.py", # temporarily disabled until #1267 done
22
"scripts-call/301_ice_public_a.py", # Unreliable, proxy returns 408 sometimes
23
"scripts-call/301_ice_public_b.py", # Doesn't work because OpenSER modifies SDP
24
"scripts-pres/200_publish.py", # Ok from cmdline, error from runall.py
25
"scripts-media-playrec/100_resample_lf_8_11.py", # related to clock-rate 11 kHz problem
26
"scripts-media-playrec/100_resample_lf_8_22.py", # related to clock-rate 22 kHz problem
27
"scripts-media-playrec/100_resample_lf_11" # related to clock-rate 11 kHz problem
31
for f in os.listdir("scripts-run"):
32
tests.append("mod_run.py scripts-run/" + f)
34
# Add basic call tests
35
for f in os.listdir("scripts-call"):
36
tests.append("mod_call.py scripts-call/" + f)
39
for f in os.listdir("scripts-pres"):
40
tests.append("mod_pres.py scripts-pres/" + f)
42
# Add mod_sendto tests
43
for f in os.listdir("scripts-sendto"):
44
tests.append("mod_sendto.py scripts-sendto/" + f)
46
# Add mod_media_playrec tests
47
for f in os.listdir("scripts-media-playrec"):
48
tests.append("mod_media_playrec.py scripts-media-playrec/" + f)
51
for f in os.listdir("scripts-pesq"):
52
tests.append("mod_pesq.py scripts-pesq/" + f)
55
for f in os.listdir("scripts-recvfrom"):
56
tests.append("mod_recvfrom.py scripts-recvfrom/" + f)
59
for f in os.listdir("scripts-sipp"):
60
if f.endswith(".xml"):
61
tests.append("mod_sipp.py scripts-sipp/" + f)
63
# Filter-out excluded tests
64
for pat in excluded_tests:
65
tests = [t for t in tests if t.find(pat)==-1]
74
if sys.argv[0]=='/h' or sys.argv[0]=='-h' or sys.argv[0]=='--help' or sys.argv[0]=='/help':
77
print " runall.py [OPTIONS] [run.py-OPTIONS]"
80
print " List the tests"
82
print " List the tests as XML format suitable for ccdash"
83
print " --resume,-r RESUME"
84
print " RESUME is string/substring to specify where to resume tests."
85
print " If this argument is omited, tests will start from the beginning."
86
print " --shell,-s SHELL"
87
print " Run the tests with the specified SHELL cmd. This can also be"
88
print " used to run the test with ccdash. Example:"
89
print " --shell '/bin/sh -c'"
90
print " run.py-OPTIONS are applicable here"
92
elif sys.argv[0] == '-r' or sys.argv[0] == '--resume':
94
resume_script=sys.argv[1]
99
sys.stderr.write("Error: argument value required")
101
elif sys.argv[0] == '--list':
106
elif sys.argv[0] == '--list-xml':
109
(mod,param) = t.split(None,2)
110
tname = mod[4:mod.find(".py")] + "_" + \
111
param[param.find("/")+1:param.rfind(".")]
114
c = " ".join(sys.argv) + " "
115
tcmd = PYTHON + ' run.py ' + c + t
116
print '\t\t<Test name="%s" cmd="%s" wdir="tests/pjsua" />' % (tname, tcmd)
118
elif sys.argv[0] == '-s' or sys.argv[0] == '--shell':
119
if len(sys.argv) > 1:
120
shell_cmd = sys.argv[1]
125
sys.stderr.write("Error: argument value required")
128
# should be run.py options
132
# Generate arguments for run.py
133
argv_st = " ".join(sys.argv) + " "
139
# Re-create "logs" directory
141
shutil.rmtree("logs")
143
print "Warning: failed in removing directory 'logs'"
148
print "Warning: failed in creating directory 'logs'"
151
total_cnt = len(tests)
153
if resume_script!="" and t.find(resume_script)==-1:
154
print "Skipping " + t +".."
155
total_cnt = total_cnt - 1
158
cmdline = "python run.py " + argv_st + t
160
cmdline = "%s '%s'" % (shell_cmd, cmdline)
162
msg = "Running %d/%d: %s..." % (tests_cnt+1, total_cnt, cmdline)
163
sys.stdout.write(msg)
165
ret = os.system(cmdline + " > output.log")
169
print " failed!! [" + str(dur) + "s]"
170
logname = re.search(".*\s+(.*)", t).group(1)
171
logname = re.sub("[\\\/]", "_", logname)
172
logname = re.sub("\.py$", ".log", logname)
173
logname = re.sub("\.xml$", ".log", logname)
174
logname = "logs/" + logname
175
shutil.move("output.log", logname)
176
print "Please see '" + logname + "' for the test log."
180
print " ok [" + str(dur) + "s]"
184
print "All " + str(tests_cnt) + " tests completed successfully"
186
print str(tests_cnt) + " tests completed, " + str(fails_cnt) + " test(s) failed"