aboutsummaryrefslogtreecommitdiff
path: root/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/skia.py
blob: 8edbaee4eabe127a4138fa639c2845dc1a4674e8 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright (c) 2012 Linaro

# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
#
# This file is part of LAVA Android Test.
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
Runs the skia benchmark to test 2D graphics performance.

**URL:** https://sites.google.com/site/skiadocs/

**Default options:** None
"""

import re
import lava_android_test.testdef

test_name = 'skia'

DEFAULT_OPTIONS = '1000'

INSTALL_STEPS_ADB_PRE = []
# Skia can do many more benchmarks, but it becomes almost too much data
# to make a nice chart for. The -match limits the ones we run
ADB_SHELL_STEPS = ['logcat -c',
                 'skia_bench -repeat $(OPTIONS) -timers w -config 565 -match bitmap',
                 'skia_bench -repeat $(OPTIONS) -timers w -config 565 -match rects',
                 'skia_bench -repeat $(OPTIONS) -timers w -config 565 -match repeat',
                  'logcat -d -s "skia:*"']


class SkiaTestParser(lava_android_test.testdef.AndroidTestParser):

    def parse(self, result_filename=None, output_filename=None,
              test_name=test_name):
        pat_test = re.compile(r'running bench \[.*?\]\W+(?P<test>\w+)\W+$')
        pat_type = re.compile(
                r'\d+\):\W+(?P<type>\w+):\W+msecs =\W+(?P<time>\d+.\d+)')

        test = None
        with open(output_filename, 'r') as stream:
            for lineno, line in enumerate(stream, 1):
                match = pat_test.search(line)
                if match:
                    test = match.group('test')
                else:
                    match = pat_type.search(line)
                    if match:
                        data = {}
                        data['test_case_id'] = "%s_%s" % (test,
                                                          match.group('type'))
                        data['measurement'] = match.group('time')
                        data['result'] = 'pass'
                        data['units'] = 'ms'
                        data['log_filename'] = result_filename
                        data['log_lineno'] = lineno
                        self.results['test_results'].append(data)

        if self.fixupdict:
            self.fixresults(self.fixupdict)
        if self.appendall:
            self.appendtoall(self.appendall)
        self.fixmeasurements()
        self.fixids()

inst = lava_android_test.testdef.AndroidTestInstaller(
                                steps_adb_pre=INSTALL_STEPS_ADB_PRE)
run = lava_android_test.testdef.AndroidTestRunner(
                                    adbshell_steps=ADB_SHELL_STEPS)
parser = SkiaTestParser()
testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
                                    installer=inst,
                                    runner=run,
                                    parser=parser,
                                    default_options=DEFAULT_OPTIONS)