Merge lp:~chengjie-he/lava-android-test/bluetooth into lp:lava-android-test

Proposed by Chengjie HE
Status: Merged
Merged at revision: 148
Proposed branch: lp:~chengjie-he/lava-android-test/bluetooth
Merge into: lp:lava-android-test
Diff against target: 87 lines (+83/-0)
1 file modified
lava_android_test/test_definitions/bluetooth.py (+83/-0)
To merge this branch: bzr merge lp:~chengjie-he/lava-android-test/bluetooth
Reviewer Review Type Date Requested Status
Yongqin Liu Approve
Review via email: mp+102857@code.launchpad.net

Description of the change

this is a script for test bluetooth functionalities

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

Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'lava_android_test/test_definitions/bluetooth.py'
2--- lava_android_test/test_definitions/bluetooth.py 1970-01-01 00:00:00 +0000
3+++ lava_android_test/test_definitions/bluetooth.py 2012-04-20 13:33:54 +0000
4@@ -0,0 +1,83 @@
5+# copyright (C) 2011-2012 Linaro Limited
6+#
7+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
8+#
9+# This file is part of LAVA Android Test.
10+#
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU General Public License as published by
14+# the Free Software Foundation, either version 3 of the License, or
15+# (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU General Public License for more details.
21+#
22+# You should have received a copy of the GNU General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+import re
25+import lava_android_test.testdef
26+
27+test_name = 'bluetooth'
28+
29+cmd = ("am instrument -r -w "
30+ "com.android.bluetooth.tests/android.bluetooth.BluetoothTestRunner")
31+RUN_ADB_SHELL_STEPS = [cmd]
32+
33+
34+class BluetoothTestTestParser(lava_android_test.testdef.AndroidTestParser):
35+
36+ def parse(self, result_filename='stdout.log', output_filename='stdout.log',
37+ test_name=test_name):
38+ """Parse test output to gather results
39+ Use the pattern specified when the class was instantiated to look
40+ through the results line-by-line and find lines that match it.
41+ Results are then stored in self.results. If a fixupdict was supplied
42+ it is used to convert test result strings to a standard format.
43+ """
44+ pat_test = re.compile(
45+ r'^\s*INSTRUMENTATION_STATUS:\s*test=(?P<test_case_id>.+)\s*$')
46+ pat_status_code = re.compile(
47+ r'^\s*INSTRUMENTATION_STATUS_CODE:\s*(?P<status_code>[\d-]+)\s*$')
48+ data = {}
49+ with open(output_filename, 'r') as stream:
50+ for lineno, line in enumerate(stream, 1):
51+ match = pat_test.search(line)
52+ if match:
53+ data['test_case_id'] = match.group('test_case_id')
54+ continue
55+
56+ match = pat_status_code.search(line)
57+ if match:
58+ status_code = match.group('status_code')
59+ if status_code == '1':
60+ # test case started
61+ data = {}
62+ elif data['test_case_id']:
63+ if status_code == '0':
64+ data['result'] = 'pass'
65+ else:
66+ data['result'] = 'fail'
67+ data["log_filename"] = result_filename
68+ data["log_lineno"] = lineno
69+ self.results['test_results'].append(data)
70+ data = {}
71+ continue
72+
73+ if self.fixupdict:
74+ self.fixresults(self.fixupdict)
75+ if self.appendall:
76+ self.appendtoall(self.appendall)
77+ self.fixmeasurements()
78+ self.fixids()
79+
80+inst = lava_android_test.testdef.AndroidTestInstaller()
81+run = lava_android_test.testdef.AndroidTestRunner(
82+ adbshell_steps=RUN_ADB_SHELL_STEPS)
83+parser = BluetoothTestTestParser()
84+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
85+ installer=inst,
86+ runner=run,
87+ parser=parser)

Subscribers

People subscribed via source and target branches