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
=== modified file 'lava_android_test/adb.py'
--- lava_android_test/adb.py 2012-07-02 01:52:32 +0000
+++ lava_android_test/adb.py 2013-06-03 08:38:28 +0000
@@ -198,6 +198,9 @@
198 return 0198 return 0
199 if target_file is None:199 if target_file is None:
200 return 0200 return 0
201 if not self.exists(source_file):
202 return 0
203
201 ret_code = self.shell("dd if=%s of=%s" % (source_file, target_file))204 ret_code = self.shell("dd if=%s of=%s" % (source_file, target_file))
202 return ret_code205 return ret_code
203206
204207
=== modified file 'lava_android_test/test_definitions/cts.py'
--- lava_android_test/test_definitions/cts.py 2013-05-18 06:29:22 +0000
+++ lava_android_test/test_definitions/cts.py 2013-06-03 08:38:28 +0000
@@ -27,30 +27,39 @@
27"""27"""
2828
29import os29import os
30import lava_android_test.testdef30
31from lava_android_test.testdef import (Attachment,
32 AndroidTest,
33 AndroidTestInstaller,
34 AndroidTestRunner,
35 AndroidTestParser)
3136
32test_name = 'cts'37test_name = 'cts'
3338
34curdir = os.path.realpath(os.path.dirname(__file__))39curdir = os.path.realpath(os.path.dirname(__file__))
3540
36RUN_STEPS_HOST_PRE = ['python %s/cts/cts_wrapper.py $(SERIAL) $(OPTIONS)' % curdir]41RUN_STEPS_HOST_PRE = ['python %s/cts/cts_wrapper.py $(SERIAL) $(OPTIONS)' % (
42 curdir)]
3743
38inst = lava_android_test.testdef.AndroidTestInstaller()44inst = AndroidTestInstaller()
39run = lava_android_test.testdef.AndroidTestRunner(45run = AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
40 steps_host_pre=RUN_STEPS_HOST_PRE)
4146
42#01-16 14:24:16 I/0123456789ABCDEF: android.telephony.cts.47#01-16 14:24:16 I/0123456789ABCDEF: android.telephony.cts.
43#TelephonyManagerTest#testGetNetworkCountryIso PASS48#TelephonyManagerTest#testGetNetworkCountryIso PASS
44pattern = ("\s*[\d-]+\s+[\d:]+\s+I\/\S+\:\s+(?P<test_case_id>\S+#\S+)"49pattern = ("\s*[\d-]+\s+[\d:]+\s+I\/\S+\:\s+(?P<test_case_id>\S+#\S+)"
45 "\s+(?P<result>\S+)\s*$")50 "\s+(?P<result>\S+)\s*$")
46parser = lava_android_test.testdef.AndroidTestParser(pattern=pattern,51parser = AndroidTestParser(pattern=pattern,
47 fixupdict={'PASS': 'pass', 'FAIL': 'fail'})52 fixupdict={'PASS': 'pass', 'FAIL': 'fail'})
4853
49attachments = [lava_android_test.testdef.Attachment(54attachments = [
50 pathname="/data/local/tmp/cts-results.zip",55 Attachment(pathname="/data/local/tmp/logcat.log",
51 mime_type="application/zip")56 mime_type="text/plain"),
57 Attachment(pathname="/data/local/tmp/kmsg.log",
58 mime_type="text/plain"),
59 Attachment(pathname="/data/local/tmp/cts-results.zip",
60 mime_type="application/zip")
52 ]61 ]
53testobj = lava_android_test.testdef.AndroidTest(testname=test_name,62testobj = AndroidTest(testname=test_name,
54 installer=inst,63 installer=inst,
55 runner=run,64 runner=run,
56 parser=parser,65 parser=parser,
5766
=== modified file 'lava_android_test/test_definitions/cts/cts_wrapper.py'
--- lava_android_test/test_definitions/cts/cts_wrapper.py 2013-05-18 06:29:22 +0000
+++ lava_android_test/test_definitions/cts/cts_wrapper.py 2013-06-03 08:38:28 +0000
@@ -57,8 +57,10 @@
57 target_dir = os.path.join(os.getcwd(),57 target_dir = os.path.join(os.getcwd(),
58 './android-cts/repository/results/')58 './android-cts/repository/results/')
59 for zip_f in find_files(target_dir, '.zip'):59 for zip_f in find_files(target_dir, '.zip'):
60 adb.push(zip_f, '/data/local/tmp/cts-results.zip')60 ret_code = adb.push(zip_f, '/data/local/tmp/cts-results.zip')[0]
6161 if ret_code != 0:
62 print "Failed to push file %s to device(%s)" % (zip_f,
63 adb.get_serial())
62 return result64 return result
6365
6466
@@ -203,15 +205,21 @@
203 return logs205 return logs
204206
205207
206def print_log(logs=[]):208def push_log(logs=[]):
207 for log in logs:209 for log in logs:
208 log_file = log.get('output_file')210 log_file = log.get('output_file')
211 base_name = os.path.basename(log_file)
209 if log_file:212 if log_file:
210 with open(log_file) as log_fd:213 ret_code = adb.push(log_file, '/data/local/tmp/%s' % base_name)[0]
211 print '=========Log file [%s] starts=========>>>>>' % log_file214 if ret_code != 0:
212 for line in log_fd.readlines():215 print "Failed to push file %s to device(%s)" % (log_file,
213 print line.rstrip()216 adb.get_serial())
214 print '<<<<<=========Log file [%s] ends=========' % log_file217 with open(log_file) as log_fd:
218 print '=========Log file [%s] starts=========>>>>>' % (
219 log_file)
220 for line in log_fd.readlines():
221 print line.rstrip()
222 print '<<<<<=========Log file [%s] ends=========' % log_file
215223
216224
217def get_all_packages(plan_file=None):225def get_all_packages(plan_file=None):
@@ -301,7 +309,7 @@
301 if pid:309 if pid:
302 adb.run_cmd_host('kill -9 %s' % pid)310 adb.run_cmd_host('kill -9 %s' % pid)
303311
304 print_log(logs)312 push_log(logs)
305313
306 sys.exit(0)314 sys.exit(0)
307315

Subscribers

People subscribed via source and target branches