Merge lp:~liuyq0307/lava-android-test/check-before-copy into lp:lava-android-test

Proposed by Yongqin Liu
Status: Merged
Merged at revision: 255
Proposed branch: lp:~liuyq0307/lava-android-test/check-before-copy
Merge into: lp:lava-android-test
Diff against target: 121 lines (+40/-20)
3 files modified
lava_android_test/adb.py (+3/-0)
lava_android_test/test_definitions/cts.py (+20/-11)
lava_android_test/test_definitions/cts/cts_wrapper.py (+17/-9)
To merge this branch: bzr merge lp:~liuyq0307/lava-android-test/check-before-copy
Reviewer Review Type Date Requested Status
Yongqin Liu self test Approve
Review via email: mp+167003@code.launchpad.net

Description of the change

Some improvement for CTS test:
1. add check after push in the cts_wrapper.py and add check before copy in the copy function of adb.copy
2. change to store the kmsg.log and logcat.log as attachments instead of output in the log

To post a comment you must log in.
Revision history for this message
Yongqin Liu (liuyq0307) :
review: Approve (self test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_android_test/adb.py'
2--- lava_android_test/adb.py 2012-07-02 01:52:32 +0000
3+++ lava_android_test/adb.py 2013-06-03 08:38:28 +0000
4@@ -198,6 +198,9 @@
5 return 0
6 if target_file is None:
7 return 0
8+ if not self.exists(source_file):
9+ return 0
10+
11 ret_code = self.shell("dd if=%s of=%s" % (source_file, target_file))
12 return ret_code
13
14
15=== modified file 'lava_android_test/test_definitions/cts.py'
16--- lava_android_test/test_definitions/cts.py 2013-05-18 06:29:22 +0000
17+++ lava_android_test/test_definitions/cts.py 2013-06-03 08:38:28 +0000
18@@ -27,30 +27,39 @@
19 """
20
21 import os
22-import lava_android_test.testdef
23+
24+from lava_android_test.testdef import (Attachment,
25+ AndroidTest,
26+ AndroidTestInstaller,
27+ AndroidTestRunner,
28+ AndroidTestParser)
29
30 test_name = 'cts'
31
32 curdir = os.path.realpath(os.path.dirname(__file__))
33
34-RUN_STEPS_HOST_PRE = ['python %s/cts/cts_wrapper.py $(SERIAL) $(OPTIONS)' % curdir]
35+RUN_STEPS_HOST_PRE = ['python %s/cts/cts_wrapper.py $(SERIAL) $(OPTIONS)' % (
36+ curdir)]
37
38-inst = lava_android_test.testdef.AndroidTestInstaller()
39-run = lava_android_test.testdef.AndroidTestRunner(
40- steps_host_pre=RUN_STEPS_HOST_PRE)
41+inst = AndroidTestInstaller()
42+run = AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
43
44 #01-16 14:24:16 I/0123456789ABCDEF: android.telephony.cts.
45 #TelephonyManagerTest#testGetNetworkCountryIso PASS
46 pattern = ("\s*[\d-]+\s+[\d:]+\s+I\/\S+\:\s+(?P<test_case_id>\S+#\S+)"
47 "\s+(?P<result>\S+)\s*$")
48-parser = lava_android_test.testdef.AndroidTestParser(pattern=pattern,
49- fixupdict={'PASS': 'pass', 'FAIL': 'fail'})
50+parser = AndroidTestParser(pattern=pattern,
51+ fixupdict={'PASS': 'pass', 'FAIL': 'fail'})
52
53-attachments = [lava_android_test.testdef.Attachment(
54- pathname="/data/local/tmp/cts-results.zip",
55- mime_type="application/zip")
56+attachments = [
57+ Attachment(pathname="/data/local/tmp/logcat.log",
58+ mime_type="text/plain"),
59+ Attachment(pathname="/data/local/tmp/kmsg.log",
60+ mime_type="text/plain"),
61+ Attachment(pathname="/data/local/tmp/cts-results.zip",
62+ mime_type="application/zip")
63 ]
64-testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
65+testobj = AndroidTest(testname=test_name,
66 installer=inst,
67 runner=run,
68 parser=parser,
69
70=== modified file 'lava_android_test/test_definitions/cts/cts_wrapper.py'
71--- lava_android_test/test_definitions/cts/cts_wrapper.py 2013-05-18 06:29:22 +0000
72+++ lava_android_test/test_definitions/cts/cts_wrapper.py 2013-06-03 08:38:28 +0000
73@@ -57,8 +57,10 @@
74 target_dir = os.path.join(os.getcwd(),
75 './android-cts/repository/results/')
76 for zip_f in find_files(target_dir, '.zip'):
77- adb.push(zip_f, '/data/local/tmp/cts-results.zip')
78-
79+ ret_code = adb.push(zip_f, '/data/local/tmp/cts-results.zip')[0]
80+ if ret_code != 0:
81+ print "Failed to push file %s to device(%s)" % (zip_f,
82+ adb.get_serial())
83 return result
84
85
86@@ -203,15 +205,21 @@
87 return logs
88
89
90-def print_log(logs=[]):
91+def push_log(logs=[]):
92 for log in logs:
93 log_file = log.get('output_file')
94+ base_name = os.path.basename(log_file)
95 if log_file:
96- with open(log_file) as log_fd:
97- print '=========Log file [%s] starts=========>>>>>' % log_file
98- for line in log_fd.readlines():
99- print line.rstrip()
100- print '<<<<<=========Log file [%s] ends=========' % log_file
101+ ret_code = adb.push(log_file, '/data/local/tmp/%s' % base_name)[0]
102+ if ret_code != 0:
103+ print "Failed to push file %s to device(%s)" % (log_file,
104+ adb.get_serial())
105+ with open(log_file) as log_fd:
106+ print '=========Log file [%s] starts=========>>>>>' % (
107+ log_file)
108+ for line in log_fd.readlines():
109+ print line.rstrip()
110+ print '<<<<<=========Log file [%s] ends=========' % log_file
111
112
113 def get_all_packages(plan_file=None):
114@@ -301,7 +309,7 @@
115 if pid:
116 adb.run_cmd_host('kill -9 %s' % pid)
117
118- print_log(logs)
119+ push_log(logs)
120
121 sys.exit(0)
122

Subscribers

People subscribed via source and target branches