Merge lp:~liuyq0307/lava-android-test/monkeyrunner-parser into lp:lava-android-test

Proposed by Yongqin Liu
Status: Merged
Merged at revision: 200
Proposed branch: lp:~liuyq0307/lava-android-test/monkeyrunner-parser
Merge into: lp:lava-android-test
Diff against target: 66 lines (+41/-1)
1 file modified
lava_android_test/commands.py (+41/-1)
To merge this branch: bzr merge lp:~liuyq0307/lava-android-test/monkeyrunner-parser
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Vishal Pending
Review via email: mp+120724@code.launchpad.net

Description of the change

add parser for monkeyrunner test to parse the result that genereated by monkeyrunner script
has been tested locally, and the result is here:
http://staging.validation.linaro.org/dashboard/streams/anonymous/bundles/d3b71cc31a3432bd1b7c193da45c5d31d963e3c4/

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

not tested yet, will change the status to "Needs review" after tested.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I assume you have tested this now? It seems OK, but this bit:

        self.pattern = ("^\s*(?P<test_case_id>.*?)\s*="
                        "\s*(?P<measure_units>.+)\s*$")
        try:
            pat = re.compile(self.pattern)
        except Exception as strerror:
            raise RuntimeError(("MonkeyrunnerTestParser - Invalid regular"
                   " expression '%s'- %s") % (self.pattern, strerror))

seems overly complicated. Surely just "pat = re.compile(...)" is fine?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_android_test/commands.py'
2--- lava_android_test/commands.py 2012-08-17 02:03:02 +0000
3+++ lava_android_test/commands.py 2012-08-23 03:22:20 +0000
4@@ -580,6 +580,8 @@
5 self.say_begin(tip_msg)
6 bundles = []
7 for script in script_list:
8+ if "monkeycommon.py" == os.path.basename(script):
9+ continue
10 sub_bundle = {}
11 from datetime import datetime
12 starttime = datetime.utcnow()
13@@ -624,7 +626,9 @@
14 inst = AndroidTestInstaller()
15 run = AndroidTestRunner(steps_host_pre=[
16 'monkeyrunner %s %s' % (script, serial)])
17- parser = AndroidTestParser()
18+ parser = MonkeyrunnerTestParser()
19+ parser.monkeyrunner_result = os.path.join(os.path.dirname(script),
20+ 'results.txt')
21 test = AndroidTest(testname='monkeyrunner',
22 installer=inst, runner=run, parser=parser)
23 test.parser.results = {'test_results': []}
24@@ -656,6 +660,42 @@
25 return bundle
26
27
28+class MonkeyrunnerTestParser(AndroidTestParser):
29+ '''
30+ Before this method is called, self.monkeyrunner_result must be set
31+ to the right value
32+ '''
33+
34+
35+ def real_parse(self, result_filename=None, output_filename=None,
36+ test_name=''):
37+ self.pattern = ("^\s*(?P<test_case_id>.*?)\s*="
38+ "\s*(?P<measure_units>.+)\s*$")
39+ try:
40+ pat = re.compile(self.pattern)
41+ except Exception as strerror:
42+ raise RuntimeError(("MonkeyrunnerTestParser - Invalid regular"
43+ " expression '%s'- %s") % (self.pattern, strerror))
44+ if not os.path.exists(self.monkeyrunner_result):
45+ return
46+ with open(self.monkeyrunner_result) as stream:
47+ for lineno, line in enumerate(stream, 1):
48+ match = pat.search(line)
49+ if not match:
50+ continue
51+ data = match.groupdict()
52+ data["log_filename"] = result_filename
53+ data["log_lineno"] = lineno
54+ if data.get('result') is None:
55+ data['result'] = 'pass'
56+ measure_units = data["measure_units"].strip().split()
57+ data["measurement"] = measure_units[0]
58+ if len(measure_units) >= 2:
59+ data['units'] = measure_units[1]
60+ del(data["measure_units"])
61+ self.results['test_results'].append(data)
62+
63+
64 class parse(AndroidResultsCommand):
65 """
66 Parse the results of previous test that run on the specified device

Subscribers

People subscribed via source and target branches