Skip to content

Commit a87f0bb

Browse files
author
Brendan Jackman
committed
ubsystemuijanktests: Add UbSytemUiJankTests workload
1 parent cd49a9c commit a87f0bb

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright (C) 2017, Arm Limited and contributors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
import re
19+
20+
from devlib.utils.android import grant_app_permissions
21+
22+
from wa import ApkWorkload, Parameter, WorkloadError
23+
24+
class UbSystemUiJankTests(ApkWorkload):
25+
"""
26+
AOSP UbSystemUiJankTests tests
27+
28+
Performs actions on the System UI (launcher, settings, etc) so that UI
29+
responsiveness can be evaluated.
30+
31+
The .apk can be built with `make UbSystemUiJankTests` in the AOSP tree.
32+
33+
Reports metrics the metrics reported by instrumentation system - these will
34+
likely overlap with those reported by the 'fps' instrument, but should be
35+
more accurately recorded.
36+
"""
37+
38+
name = 'ubsystemuijanktests'
39+
40+
package_names = ['android.platform.systemui.tests.jank']
41+
42+
tests = [
43+
'LauncherJankTests#testOpenAllAppsContainer',
44+
'LauncherJankTests#testAllAppsContainerSwipe',
45+
'LauncherJankTests#testHomeScreenSwipe',
46+
'LauncherJankTests#testWidgetsContainerFling',
47+
'SettingsJankTests#testSettingsFling',
48+
'SystemUiJankTests#testRecentAppsFling',
49+
'SystemUiJankTests#testRecentAppsDismiss',
50+
'SystemUiJankTests#testNotificationListPull',
51+
'SystemUiJankTests#testNotificationListPull_manyNotifications',
52+
'SystemUiJankTests#testQuickSettingsPull',
53+
'SystemUiJankTests#testUnlock',
54+
'SystemUiJankTests#testExpandGroup',
55+
'SystemUiJankTests#testClearAll',
56+
'SystemUiJankTests#testChangeBrightness',
57+
'SystemUiJankTests#testNotificationAppear',
58+
'SystemUiJankTests#testCameraFromLockscreen',
59+
'SystemUiJankTests#testAmbientWakeUp',
60+
'SystemUiJankTests#testGoToFullShade',
61+
'SystemUiJankTests#testInlineReply',
62+
'SystemUiJankTests#testPinAppearance',
63+
'SystemUiJankTests#testLaunchSettings',
64+
]
65+
66+
parameters = [
67+
Parameter('test', default=tests[0], allowed_values=tests,
68+
description='Which of the System UI jank tests to run')
69+
]
70+
71+
def setup(self, context):
72+
# Override the default setup method, as it calls
73+
# self.apk.start_activity. We dont want to do that.
74+
75+
self.apk.initialize_package(context)
76+
self.target.execute('am kill-all') # kill all *background* activities
77+
grant_app_permissions(self.target, self.package)
78+
79+
self.target.clear_logcat()
80+
81+
jclass = '{}.{}'.format(self.package, self.test)
82+
self.command = 'am instrument -e iterations 1 -e class {} -w {}'.format(
83+
jclass, self.package)
84+
85+
def run(self, context):
86+
self.output = self.target.execute(self.command)
87+
88+
# You see 'FAILURES' if an exception is thrown.
89+
# You see 'Process crashed' if it doesn't recognise the class for some
90+
# reason.
91+
# But neither reports an error in the exit code, so check explicitly.
92+
if 'FAILURES' in self.output or 'Process crashed' in self.output:
93+
raise WorkloadError('Failed to run workload: {}'.format(self.output))
94+
95+
def update_output(self, context):
96+
# The 'am instrument' command dumps the instrumentation results into
97+
# stdout. It also gets written by the autotester to a storage file - on
98+
# my devices that is /storage/emulated/0/results.log, but I dont know if
99+
# that's the same for every device.
100+
#
101+
# AOSP probably provides standard tooling for parsing this, but I don't
102+
# know how to use it. Anyway, for this use-case just parsing stdout
103+
# works fine.
104+
105+
regex = re.compile('INSTRUMENTATION_STATUS: (?P<key>[\w-]+)=(?P<value>[0-9\.]+)')
106+
107+
for line in self.output.splitlines():
108+
match = regex.match(line)
109+
if match:
110+
key = match.group('key')
111+
value = float(match.group('value'))
112+
113+
name = 'instrumentation_{}'.format(key)
114+
context.add_metric(name, value, lower_is_better=True)

0 commit comments

Comments
 (0)