-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py~
49 lines (42 loc) · 1.29 KB
/
run.py~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import os,time traceback
from xml.etree import ElementTree
case = []
start_time = time.strftime('%Y%m%d_%H%M%S',time.localtime(time.time()))
result_dir = "./Result/"+start_time
tcRoot = ElementTree.parse("./testCases.xml")
cn = tcRoot.findall("case")
for i in cn:
cases.append(i.text)
caseList = list(set(cases))
caseList.sort(key=cases.index)
for caseName in caseList:
case_result_dir = result_dir+"/"+caseName
os.popen("mkdir -p %s"%(case_result_dir))
try:
os.sys.path.append("TestCases/MRD8/")
a = __import__('%s.case' %caseName)#import case in the dir
reload(a.case)#reload the imported case
except ImportError, e:
print "can't find case:", caseName
continue
f = open(case_result_dir+"/"+caseName+".txt","aw")
try:
result = a.case.exe()
print result
if type(result)== str:
f.write(result+"\n")
f.flush()
except Exception, e:
print Exception,':',e
traceback.print_exc(file=f)
f.flush()
f.close()
else:
f.write("No exception Raise\n")
f.flush()
f.close()
finally:
f.close()
os.popen("adb pull /mnt/sdcard/logs %s/logs_adb"%(result_dir))
os.popen("adb pull /logs %s/crashLogs"%(result_dir))