Merge lp:~cjohnston/ubuntu-test-cases/convergence into lp:ubuntu-test-cases/touch
- convergence
- Merge into touch
Status: | Work in progress |
---|---|
Proposed branch: | lp:~cjohnston/ubuntu-test-cases/convergence |
Merge into: | lp:ubuntu-test-cases/touch |
Diff against target: |
4030 lines (+3238/-2) 147 files modified
jenkins/setup_jenkins.py (+237/-0) jenkins/templates/touch-address-book-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-autopilot-base.xml.jinja2 (+23/-0) jenkins/templates/touch-base.xml.jinja2 (+87/-0) jenkins/templates/touch-calendar-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-camera-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-default.xml.jinja2 (+6/-0) jenkins/templates/touch-dialer-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-eventstat.xml.jinja2 (+21/-0) jenkins/templates/touch-friends-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-gallery-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-install-and-boot.xml.jinja2 (+29/-0) jenkins/templates/touch-master.xml.jinja2 (+54/-0) jenkins/templates/touch-mediaplayer-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-memevent.xml.jinja2 (+9/-0) jenkins/templates/touch-messaging-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-music-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-notes-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-phone-app-connected-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-sdk.xml.jinja2 (+20/-0) jenkins/templates/touch-security.xml.jinja2 (+20/-0) jenkins/templates/touch-setup.xml.jinja2 (+5/-0) jenkins/templates/touch-share-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-smem.xml.jinja2 (+20/-0) jenkins/templates/touch-ubuntu-calculator-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-clock-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-clock-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-docviewer-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-filemanager-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-rssreader-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-terminal-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-ubuntu-weather-app-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-unity8-autopilot.xml.jinja2 (+6/-0) jenkins/templates/touch-upgrade.xml.jinja2 (+28/-0) jenkins/templates/touch-webbrowser-app-autopilot.xml.jinja2 (+6/-0) scripts/get-adb-id (+32/-0) scripts/jenkins.sh (+111/-0) scripts/provision.sh (+41/-0) scripts/run-touch-upgrade.sh (+46/-0) scripts/run-touch-utah-runlist.sh (+66/-0) tests/address-book-app-autopilot/master.run (+15/-0) tests/address-book-app-autopilot/ts_control (+1/-0) tests/address-book-app-autopilot/tslist.auto (+4/-0) tests/calendar-app-autopilot/master.run (+15/-0) tests/calendar-app-autopilot/ts_control (+1/-0) tests/calendar-app-autopilot/tslist.auto (+4/-0) tests/camera-app-autopilot/master.run (+15/-0) tests/camera-app-autopilot/ts_control (+1/-0) tests/camera-app-autopilot/tslist.auto (+4/-0) tests/default/master.run (+2/-2) tests/dialer-app-autopilot/master.run (+15/-0) tests/dialer-app-autopilot/ts_control (+1/-0) tests/dialer-app-autopilot/tslist.auto (+4/-0) tests/friends-app-autopilot/master.run (+15/-0) tests/friends-app-autopilot/ts_control (+1/-0) tests/friends-app-autopilot/tslist.auto (+4/-0) tests/gallery-app-autopilot/master.run (+15/-0) tests/gallery-app-autopilot/ts_control (+1/-0) tests/gallery-app-autopilot/tslist.auto (+4/-0) tests/mediaplayer-app-autopilot/master.run (+15/-0) tests/mediaplayer-app-autopilot/ts_control (+1/-0) tests/mediaplayer-app-autopilot/tslist.auto (+4/-0) tests/memevent/master.run (+5/-0) tests/memevent/setup.sh (+8/-0) tests/memevent/ts_control (+1/-0) tests/memevent/tslist.auto (+7/-0) tests/memevent/ubuntu_test_cases/__init__.py (+6/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/__init__.py (+1/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/__init__.py (+21/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/browser.py (+103/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/camera.py (+58/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/gallery.py (+41/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/media_player.py (+53/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/matchers.py (+37/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/probes.py (+170/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/smem-tabs (+687/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/__init__.py (+1/-0) tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/test_memory_usage.py (+79/-0) tests/messaging-app-autopilot/master.run (+15/-0) tests/messaging-app-autopilot/ts_control (+1/-0) tests/messaging-app-autopilot/tslist.auto (+4/-0) tests/music-app-autopilot/master.run (+15/-0) tests/music-app-autopilot/ts_control (+1/-0) tests/music-app-autopilot/tslist.auto (+4/-0) tests/notes-app-autopilot/master.run (+15/-0) tests/notes-app-autopilot/ts_control (+1/-0) tests/notes-app-autopilot/tslist.auto (+4/-0) tests/phone-app-connected-autopilot/master.run (+5/-0) tests/phone-app-connected-autopilot/setup.sh (+36/-0) tests/phone-app-connected-autopilot/sms_self.py (+34/-0) tests/phone-app-connected-autopilot/testnumbers.cfg (+23/-0) tests/phone-app-connected-autopilot/ts_control (+1/-0) tests/phone-app-connected-autopilot/tslist.auto (+4/-0) tests/share-app-autopilot/master.run (+15/-0) tests/share-app-autopilot/ts_control (+1/-0) tests/share-app-autopilot/tslist.auto (+4/-0) tests/systemsettle/systemsettle-after/tc_control (+9/-0) tests/systemsettle/systemsettle-before/tc_control (+9/-0) tests/systemsettle/systemsettle.sh (+119/-0) tests/systemsettle/tslist.run (+2/-0) tests/touch-smoke-boot.run (+6/-0) tests/touch-smoke-sdk.run (+4/-0) tests/touch-smoke-security.run (+4/-0) tests/ubuntu-calculator-app-autopilot/master.run (+15/-0) tests/ubuntu-calculator-app-autopilot/ts_control (+1/-0) tests/ubuntu-calculator-app-autopilot/tslist.auto (+4/-0) tests/ubuntu-clock-app-autopilot/master.run (+15/-0) tests/ubuntu-clock-app-autopilot/ts_control (+1/-0) tests/ubuntu-clock-app-autopilot/tslist.auto (+4/-0) tests/ubuntu-docviewer-app-autopilot/master.run (+15/-0) tests/ubuntu-docviewer-app-autopilot/ts_control (+1/-0) tests/ubuntu-docviewer-app-autopilot/tslist.auto (+4/-0) tests/ubuntu-filemanager-app-autopilot/master.run (+15/-0) tests/ubuntu-filemanager-app-autopilot/ts_control (+1/-0) tests/ubuntu-filemanager-app-autopilot/tslist.auto (+4/-0) tests/ubuntu-rssreader-app-autopilot/master.run (+15/-0) tests/ubuntu-rssreader-app-autopilot/ts_control (+1/-0) tests/ubuntu-rssreader-app-autopilot/tslist.auto (+4/-0) tests/ubuntu-terminal-app-autopilot/master.run (+15/-0) tests/ubuntu-terminal-app-autopilot/ts_control (+1/-0) tests/ubuntu-terminal-app-autopilot/tslist.auto (+4/-0) tests/ubuntu-weather-app-autopilot/master.run (+15/-0) tests/ubuntu-weather-app-autopilot/ts_control (+1/-0) tests/ubuntu-weather-app-autopilot/tslist.auto (+4/-0) tests/unity8-autopilot/master.run (+15/-0) tests/unity8-autopilot/setup.sh (+6/-0) tests/unity8-autopilot/ts_control (+2/-0) tests/unity8-autopilot/tslist.auto (+4/-0) tests/upgrade/README (+3/-0) tests/upgrade/install_old/run.sh (+27/-0) tests/upgrade/install_old/tc_control (+9/-0) tests/upgrade/master.run (+5/-0) tests/upgrade/tslist.run (+2/-0) tests/upgrade/upgrade/tc_control (+9/-0) tests/upgrade/upgrade/upgrade.sh (+79/-0) tests/webbrowser-app-autopilot/master.run (+15/-0) tests/webbrowser-app-autopilot/ts_control (+1/-0) tests/webbrowser-app-autopilot/tslist.auto (+4/-0) utils/host/adb-shell (+20/-0) utils/host/autopilot-list (+18/-0) utils/host/autopilot-run (+3/-0) utils/host/prepare-autopilot-test.sh (+5/-0) utils/target/autopilot-list (+13/-0) utils/target/autopilot-run (+4/-0) utils/target/prepare-autopilot-test.sh (+17/-0) utils/target/unlock_screen.py (+87/-0) utils/target/unlock_screen.sh (+7/-0) |
To merge this branch: | bzr merge lp:~cjohnston/ubuntu-test-cases/convergence |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Test Case Developers | Pending | ||
Review via email: mp+183269@code.launchpad.net |
This proposal supersedes a proposal from 2013-08-30.
Commit message
Description of the change
Changelog:
Merge in lp:~canonical-platform-qa/ubuntu-test-runlists/touch-runlists
Merge in lp:ubuntu-test-cases/smoke-touch-apps
Add --host to setup-jenkins.sh for defining what host to drive the tests
- 26. By Chris Johnston
-
Move run-touch-upgrade to scripts
Andy Doan (doanac) wrote : | # |
tests/touch-
Andy Doan (doanac) wrote : | # |
actually tests/touch-
Andy Doan (doanac) wrote : | # |
This pastebin fixes the issue I brought up in my last two comments:
- 27. By Chris Johnston
-
Applying patch
Andy Doan (doanac) wrote : | # |
=== modified file 'scripts/
--- scripts/jenkins.sh 2013-08-30 19:55:39 +0000
+++ scripts/jenkins.sh 2013-08-30 20:45:38 +0000
@@ -17,7 +17,7 @@
ANDROID_
-TESTSUITE_
+TESTSUITE_
TESTSUITE_
TESTSUITE_
- 28. By Chris Johnston
-
Fix path issue
Paul Larson (pwlars) wrote : | # |
1005 + if [ -z $FROM_HOST ] ; then
1006 + echo "launching test on the target...."
1007 + test_from_target
1008 + else
1009 + echo "launching test from the host...."
1010 + test_from_host
1011 + fi
I think we can do this as a separate branch, but I'd like to take all these crazy env options and just use getopts. We can keep the env var optionalso, but having an argument you can pass makes running from a shell so much easier.
- 29. By Chris Johnston
-
Update branches
Paul Larson (pwlars) wrote : | # |
+${BZRDIR}
This kind of thing is often necessary for test scaffolding before it's merged, but will obviously have to change...
- 30. By Chris Johnston
-
Fix path for from host
- 31. By Chris Johnston
-
Merge trunk
Unmerged revisions
- 31. By Chris Johnston
-
Merge trunk
- 30. By Chris Johnston
-
Fix path for from host
- 29. By Chris Johnston
-
Update branches
- 28. By Chris Johnston
-
Fix path issue
- 27. By Chris Johnston
-
Applying patch
Preview Diff
1 | === added directory 'jenkins' |
2 | === added file 'jenkins/setup_jenkins.py' |
3 | --- jenkins/setup_jenkins.py 1970-01-01 00:00:00 +0000 |
4 | +++ jenkins/setup_jenkins.py 2013-09-05 19:05:51 +0000 |
5 | @@ -0,0 +1,237 @@ |
6 | +#!/usr/bin/env python |
7 | + |
8 | +# Ubuntu Testing Automation Harness |
9 | +# Copyright 2013 Canonical Ltd. |
10 | + |
11 | +# This program is free software: you can redistribute it and/or modify it |
12 | +# under the terms of the GNU General Public License version 3, as published |
13 | +# by the Free Software Foundation. |
14 | + |
15 | +# This program is distributed in the hope that it will be useful, but |
16 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
17 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
18 | +# PURPOSE. See the GNU General Public License for more details. |
19 | + |
20 | +# You should have received a copy of the GNU General Public License along |
21 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | + |
23 | +import argparse |
24 | +import collections |
25 | +import jenkins |
26 | +import jinja2 |
27 | +import logging |
28 | +import os |
29 | + |
30 | +from distro_info import UbuntuDistroInfo |
31 | +DEV_SERIES = UbuntuDistroInfo().devel() |
32 | + |
33 | + |
34 | +SYSTEM_IMAGE = os.environ.get('SYSTEM_IMAGE', False) |
35 | + |
36 | +Test = collections.namedtuple('Test', ['name', 'fmt', 'restrict_to']) |
37 | + |
38 | + |
39 | +if SYSTEM_IMAGE: |
40 | + def _test(name, fmt='{prefix}{series}-touch_ro-{type}-smoke-{testname}', |
41 | + restrict_to=None): |
42 | + return Test(name, fmt, restrict_to) |
43 | +else: |
44 | + def _test(name, fmt='{prefix}{series}-touch-{type}-smoke-{testname}', |
45 | + restrict_to=None): |
46 | + return Test(name, fmt, restrict_to) |
47 | + |
48 | + |
49 | +TESTS = [ |
50 | + _test('install-and-boot'), |
51 | + _test('default'), |
52 | + _test('mediaplayer-app-autopilot'), |
53 | + _test('gallery-app-autopilot'), |
54 | + _test('webbrowser-app-autopilot'), |
55 | + _test('unity8-autopilot'), |
56 | + _test('friends-app-autopilot'), |
57 | + _test('notes-app-autopilot'), |
58 | + _test('camera-app-autopilot'), |
59 | + _test('dialer-app-autopilot'), |
60 | + _test('messaging-app-autopilot'), |
61 | + _test('address-book-app-autopilot'), |
62 | + _test('phone-app-connected-autopilot', restrict_to=['maguro-02']), |
63 | + _test('share-app-autopilot'), |
64 | + _test('calendar-app-autopilot'), |
65 | + _test('music-app-autopilot'), |
66 | + _test('ubuntu-calculator-app-autopilot'), |
67 | + _test('ubuntu-clock-app-autopilot'), |
68 | + #_test('ubuntu-docviewer-app-autopilot'), |
69 | + _test('ubuntu-filemanager-app-autopilot'), |
70 | + _test('ubuntu-rssreader-app-autopilot'), |
71 | + _test('ubuntu-terminal-app-autopilot'), |
72 | + _test('ubuntu-weather-app-autopilot'), |
73 | + _test('sdk'), |
74 | + _test('security'), |
75 | +] |
76 | + |
77 | +DEVICES = [ |
78 | + "mako-01", |
79 | + "maguro-01", |
80 | + "manta-01", |
81 | + "grouper-02", |
82 | +] |
83 | + |
84 | + |
85 | +if SYSTEM_IMAGE: |
86 | + #TESTS = [_test('upgrade')] + TESTS |
87 | + TESTS += [ |
88 | + _test('smem', |
89 | + '{prefix}{testname}-{series}-' |
90 | + 'touch_ro-armhf-install-idle-{type}'), |
91 | + _test('memevent', |
92 | + '{prefix}{testname}-{series}-touch_ro-armhf-default-{type}'), |
93 | + ] |
94 | + DEVICES = ['mako-05', 'maguro-02'] |
95 | +else: |
96 | + TESTS += [ |
97 | + _test('smem', |
98 | + '{prefix}{testname}-{series}-touch-armhf-install-idle-{type}'), |
99 | + _test('memevent', |
100 | + '{prefix}{testname}-{series}-touch-armhf-default-{type}'), |
101 | + ] |
102 | + |
103 | + |
104 | +def _get_parser(): |
105 | + """Create and return command line parser. |
106 | + |
107 | + :returns: command line parser |
108 | + :rtype: argparse.ArgumentParser |
109 | + |
110 | + """ |
111 | + parser = argparse.ArgumentParser( |
112 | + description='Create/Update upgrade testing jenkins jobs.') |
113 | + parser.add_argument("-d", "--dryrun", action="store_true", |
114 | + help="Dry run mode. Don't execute jenkins commands.") |
115 | + parser.add_argument("-u", "--username", |
116 | + help="username to use when logging into Jenkins.") |
117 | + parser.add_argument("-P", "--publish", action="store_true", |
118 | + help="Publish at the end of the job") |
119 | + parser.add_argument("-p", "--password", |
120 | + help="username to use when logging into Jenkins") |
121 | + parser.add_argument("--prefix", |
122 | + help="Prefix to add to the beginning of the job name") |
123 | + parser.add_argument("-j", "--jenkins", default="http://10.98.0.1:8080/", |
124 | + help="URL of jenkins instance to configure jobs in.") |
125 | + parser.add_argument("-n", "--name", action='append', |
126 | + help=("Device names where the job should be executed." |
127 | + " Can be used more than once.")) |
128 | + parser.add_argument("--host", default='phoenix', |
129 | + help=("Host name where the jobs should be executed.")) |
130 | + parser.add_argument("-s", "--series", default=DEV_SERIES, |
131 | + help=("series of Ubuntu to download " |
132 | + "(default=%(default)s)")) |
133 | + return parser |
134 | + |
135 | + |
136 | +def _get_jenkins(url, username, password): |
137 | + logging.info('Attempting to login to jenkins at %s', url) |
138 | + if username is not None: |
139 | + logging.info('...with authentication as user: %s', username) |
140 | + instance = jenkins.Jenkins(url, username=username, password=password) |
141 | + else: |
142 | + logging.info('...without authentication') |
143 | + instance = jenkins.Jenkins(url) |
144 | + |
145 | + return instance |
146 | + |
147 | + |
148 | +def _get_environment(): |
149 | + base = os.path.join(os.path.dirname(__file__), 'templates') |
150 | + return jinja2.Environment( |
151 | + loader=jinja2.FileSystemLoader(base), |
152 | + undefined=jinja2.StrictUndefined, |
153 | + trim_blocks=True) |
154 | + |
155 | + |
156 | +def _get_job_name(args, device, test): |
157 | + prefix = "" |
158 | + if(args.prefix): |
159 | + prefix = args.prefix + "-" |
160 | + return test.fmt.format(prefix=prefix, |
161 | + series=args.series, |
162 | + testname=test.name, |
163 | + type=device[:device.index("-")]) |
164 | + |
165 | + |
166 | +def _publish(instance, env, args, template, jobname, **params): |
167 | + tmpl = env.get_template(template) |
168 | + cfg = tmpl.render(**params) |
169 | + if args.dryrun: |
170 | + _dryrun_func(jobname, cfg) |
171 | + return |
172 | + if instance.job_exists(jobname): |
173 | + logging.info('reconfiguring job %s', jobname) |
174 | + instance.reconfig_job(jobname, cfg) |
175 | + else: |
176 | + logging.info('creating job %s', jobname) |
177 | + instance.create_job(jobname, cfg) |
178 | + |
179 | + |
180 | +def _configure_job(instance, env, args, device, test): |
181 | + tmpl_name = 'touch-{}.xml.jinja2'.format(test.name) |
182 | + params = { |
183 | + 'host': args.host, |
184 | + 'name': device, |
185 | + 'publish': args.publish |
186 | + } |
187 | + params['system_image'] = True if SYSTEM_IMAGE else False |
188 | + jobname = _get_job_name(args, device, test) |
189 | + _publish(instance, env, args, tmpl_name, jobname, **params) |
190 | + |
191 | + |
192 | +def _configure_master(instance, env, args, device, projects): |
193 | + device_type = device[:device.index("-")] |
194 | + trigger_url = ('http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/' |
195 | + 'pending/MD5SUMS') |
196 | + if SYSTEM_IMAGE: |
197 | + fmt = 'http://system-image.ubuntu.com/daily-proposed/{}/index.json' |
198 | + trigger_url = fmt.format(device_type) |
199 | + |
200 | + params = { |
201 | + 'host': args.host, |
202 | + 'name': device, |
203 | + 'publish': args.publish, |
204 | + 'projects': projects, |
205 | + 'trigger_url': trigger_url |
206 | + } |
207 | + jobname = _get_job_name(args, device, _test('master')) |
208 | + _publish(instance, env, args, 'touch-master.xml.jinja2', jobname, **params) |
209 | + |
210 | + |
211 | +def _dryrun_func(jobname, config): |
212 | + logging.debug(jobname) |
213 | + logging.debug(config) |
214 | + |
215 | + |
216 | +def main(): |
217 | + logging.basicConfig(level=logging.DEBUG) |
218 | + args = _get_parser().parse_args() |
219 | + |
220 | + jenkins_inst = _get_jenkins(args.jenkins, args.username, args.password) |
221 | + if args.dryrun: |
222 | + jenkins_inst.create_job = _dryrun_func |
223 | + jenkins_inst.reconfig_job = _dryrun_func |
224 | + |
225 | + env = _get_environment() |
226 | + |
227 | + device_list = args.name if args.name else DEVICES |
228 | + |
229 | + for device in device_list: |
230 | + projects = [] |
231 | + for test in TESTS: |
232 | + logging.debug("configuring job for %s", test.name) |
233 | + if not test.restrict_to or device in test.restrict_to: |
234 | + _configure_job(jenkins_inst, env, args, device, test) |
235 | + projects.append(_get_job_name(args, device, test)) |
236 | + else: |
237 | + logging.info('%s not configured for %s', device, test.name) |
238 | + |
239 | + _configure_master(jenkins_inst, env, args, device, projects) |
240 | + |
241 | +if __name__ == '__main__': |
242 | + main() |
243 | |
244 | === added directory 'jenkins/templates' |
245 | === added file 'jenkins/templates/touch-address-book-app-autopilot.xml.jinja2' |
246 | --- jenkins/templates/touch-address-book-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
247 | +++ jenkins/templates/touch-address-book-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
248 | @@ -0,0 +1,6 @@ |
249 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
250 | +<?xml version='1.0' encoding='UTF-8'?> |
251 | + |
252 | +{% block apptest %} |
253 | +export APP="address-book-app-autopilot" |
254 | +{% endblock %} |
255 | |
256 | === added file 'jenkins/templates/touch-autopilot-base.xml.jinja2' |
257 | --- jenkins/templates/touch-autopilot-base.xml.jinja2 1970-01-01 00:00:00 +0000 |
258 | +++ jenkins/templates/touch-autopilot-base.xml.jinja2 2013-09-05 19:05:51 +0000 |
259 | @@ -0,0 +1,23 @@ |
260 | +{% extends "touch-base.xml.jinja2" %} |
261 | +<?xml version='1.0' encoding='UTF-8'?> |
262 | +{% block triggers %} |
263 | + <triggers class="vector"/> |
264 | +{% endblock %} |
265 | +{% block timeout %} |
266 | + <timeoutMinutes>30</timeoutMinutes> |
267 | +{% endblock timeout %} |
268 | + |
269 | +{% block shellcmds %} |
270 | + <command>set -e |
271 | +rm -rf * |
272 | +{% include "touch-setup.xml.jinja2" %} |
273 | + |
274 | +{% block apptest %}{% endblock %} |
275 | + |
276 | +${BZRDIR}/scripts/jenkins.sh |
277 | + </command> |
278 | +{% endblock %} |
279 | + |
280 | +{% block artifacts %} |
281 | + <artifacts>clientlogs/*, **/jenkins.sh</artifacts> |
282 | +{% endblock %} |
283 | |
284 | === added file 'jenkins/templates/touch-base.xml.jinja2' |
285 | --- jenkins/templates/touch-base.xml.jinja2 1970-01-01 00:00:00 +0000 |
286 | +++ jenkins/templates/touch-base.xml.jinja2 2013-09-05 19:05:51 +0000 |
287 | @@ -0,0 +1,87 @@ |
288 | +<?xml version='1.0' encoding='UTF-8'?> |
289 | +<project> |
290 | + <actions/> |
291 | + <description> |
292 | +<pre> |
293 | +#NOTE: Automatically created from a script as part of daily smoke testing
 |
294 | + lp:~canonical-platform-qa/ubuntu-test-runlists/touch-runlists
 |
295 | +</pre> |
296 | + </description> |
297 | + <keepDependencies>false</keepDependencies> |
298 | + <properties> |
299 | + <hudson.plugins.throttleconcurrents.ThrottleJobProperty> |
300 | + <maxConcurrentPerNode>0</maxConcurrentPerNode> |
301 | + <maxConcurrentTotal>0</maxConcurrentTotal> |
302 | + <throttleEnabled>false</throttleEnabled> |
303 | + <throttleOption>project</throttleOption> |
304 | + </hudson.plugins.throttleconcurrents.ThrottleJobProperty> |
305 | + <hudson.plugins.build__publisher.ExternalProjectProperty/> |
306 | + </properties> |
307 | + <scm class="hudson.scm.NullSCM"/> |
308 | + <assignedNode>{{ host }}</assignedNode> |
309 | + <canRoam>false</canRoam> |
310 | + <disabled>false</disabled> |
311 | + <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> |
312 | + <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> |
313 | +{% block triggers %}{% endblock %} |
314 | + <concurrentBuild>false</concurrentBuild> |
315 | + <builders> |
316 | +{% block shellblock %} |
317 | + <hudson.tasks.Shell> |
318 | +{% block shellcmds %}{% endblock %} |
319 | + </hudson.tasks.Shell> |
320 | +{% endblock %} |
321 | +{% block extrasteps %}{% endblock %} |
322 | + </builders> |
323 | + <publishers> |
324 | +{% block artifactblock %} |
325 | + <hudson.tasks.ArtifactArchiver> |
326 | +{% block artifacts %}{% endblock %} |
327 | + <latestOnly>false</latestOnly> |
328 | + </hudson.tasks.ArtifactArchiver> |
329 | +{% endblock %} |
330 | +{% block descriptionsetter %} |
331 | + <hudson.plugins.descriptionsetter.DescriptionSetterPublisher> |
332 | + <regexp>^= TOUCH IMAGE VERSION:([0-9]+.*)</regexp> |
333 | + <regexpForFailed>^= TOUCH IMAGE VERSION:([0-9]+.*)</regexpForFailed> |
334 | + <setForMatrix>false</setForMatrix> |
335 | + </hudson.plugins.descriptionsetter.DescriptionSetterPublisher> |
336 | +{% endblock %} |
337 | +{% block mailer %} |
338 | + <hudson.tasks.Mailer> |
339 | + <recipients>paul.larson@canonical.com</recipients> |
340 | + <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild> |
341 | + <sendToIndividuals>false</sendToIndividuals> |
342 | + </hudson.tasks.Mailer> |
343 | +{% endblock %} |
344 | +{% if publish %} |
345 | +{% block buildpublisher %} |
346 | + <hudson.plugins.build__publisher.BuildPublisher> |
347 | + <publishUnstableBuilds>true</publishUnstableBuilds> |
348 | + <publishFailedBuilds>true</publishFailedBuilds> |
349 | + <postActions class="vector"/> |
350 | + </hudson.plugins.build__publisher.BuildPublisher> |
351 | +{% endblock %} |
352 | +{% endif %} |
353 | +{% block buildtrigger %}{% endblock %} |
354 | + </publishers> |
355 | + <buildWrappers> |
356 | + <hudson.plugins.build__timeout.BuildTimeoutWrapper> |
357 | + {% block timeout %}{% endblock %} |
358 | + <failBuild>true</failBuild> |
359 | + <writingDescription>false</writingDescription> |
360 | + <timeoutPercentage>0</timeoutPercentage> |
361 | + <timeoutType>absolute</timeoutType> |
362 | + <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault> |
363 | + </hudson.plugins.build__timeout.BuildTimeoutWrapper> |
364 | +{% block locks %} |
365 | + <hudson.plugins.locksandlatches.LockWrapper> |
366 | + <locks> |
367 | + <hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig> |
368 | + <name>{{name}}</name> |
369 | + </hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig> |
370 | + </locks> |
371 | + </hudson.plugins.locksandlatches.LockWrapper> |
372 | +{% endblock %} |
373 | + </buildWrappers> |
374 | +</project> |
375 | |
376 | === added file 'jenkins/templates/touch-calendar-app-autopilot.xml.jinja2' |
377 | --- jenkins/templates/touch-calendar-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
378 | +++ jenkins/templates/touch-calendar-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
379 | @@ -0,0 +1,6 @@ |
380 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
381 | +<?xml version='1.0' encoding='UTF-8'?> |
382 | + |
383 | +{% block apptest %} |
384 | +export APP="calendar-app-autopilot" |
385 | +{% endblock %} |
386 | |
387 | === added file 'jenkins/templates/touch-camera-app-autopilot.xml.jinja2' |
388 | --- jenkins/templates/touch-camera-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
389 | +++ jenkins/templates/touch-camera-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
390 | @@ -0,0 +1,6 @@ |
391 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
392 | +<?xml version='1.0' encoding='UTF-8'?> |
393 | + |
394 | +{% block apptest %} |
395 | +export APP="camera-app-autopilot" |
396 | +{% endblock %} |
397 | |
398 | === added file 'jenkins/templates/touch-default.xml.jinja2' |
399 | --- jenkins/templates/touch-default.xml.jinja2 1970-01-01 00:00:00 +0000 |
400 | +++ jenkins/templates/touch-default.xml.jinja2 2013-09-05 19:05:51 +0000 |
401 | @@ -0,0 +1,6 @@ |
402 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
403 | +<?xml version='1.0' encoding='UTF-8'?> |
404 | + |
405 | +{% block apptest %} |
406 | +export APP="default" |
407 | +{% endblock %} |
408 | |
409 | === added file 'jenkins/templates/touch-dialer-app-autopilot.xml.jinja2' |
410 | --- jenkins/templates/touch-dialer-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
411 | +++ jenkins/templates/touch-dialer-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
412 | @@ -0,0 +1,6 @@ |
413 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
414 | +<?xml version='1.0' encoding='UTF-8'?> |
415 | + |
416 | +{% block apptest %} |
417 | +export APP="dialer-app-autopilot" |
418 | +{% endblock %} |
419 | |
420 | === added file 'jenkins/templates/touch-eventstat.xml.jinja2' |
421 | --- jenkins/templates/touch-eventstat.xml.jinja2 1970-01-01 00:00:00 +0000 |
422 | +++ jenkins/templates/touch-eventstat.xml.jinja2 2013-09-05 19:05:51 +0000 |
423 | @@ -0,0 +1,21 @@ |
424 | +{% extends "touch-base.xml.jinja2" %} |
425 | +<?xml version='1.0' encoding='UTF-8'?> |
426 | +{% block triggers %} |
427 | + <triggers class="vector"/> |
428 | +{% endblock %} |
429 | +{% block timeout %} |
430 | + <timeoutMinutes>45</timeoutMinutes> |
431 | +{% endblock timeout %} |
432 | + |
433 | +{% block shellcmds %} |
434 | + <command>rm -rf * |
435 | +{% include "touch-setup.xml.jinja2" %} |
436 | + |
437 | +bzr branch lp:~ubuntu-test-case-dev/ubuntu-test-cases/qa-baseline-testing |
438 | + |
439 | +qa-baseline-testing/jenkins/run-touch-eventstat.sh -s $ANDROID_SERIAL</command> |
440 | +{% endblock %} |
441 | + |
442 | +{% block artifacts %} |
443 | + <artifacts>results/**/*</artifacts> |
444 | +{% endblock %} |
445 | |
446 | === added file 'jenkins/templates/touch-friends-app-autopilot.xml.jinja2' |
447 | --- jenkins/templates/touch-friends-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
448 | +++ jenkins/templates/touch-friends-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
449 | @@ -0,0 +1,6 @@ |
450 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
451 | +<?xml version='1.0' encoding='UTF-8'?> |
452 | + |
453 | +{% block apptest %} |
454 | +export APP="friends-app-autopilot" |
455 | +{% endblock %} |
456 | |
457 | === added file 'jenkins/templates/touch-gallery-app-autopilot.xml.jinja2' |
458 | --- jenkins/templates/touch-gallery-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
459 | +++ jenkins/templates/touch-gallery-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
460 | @@ -0,0 +1,6 @@ |
461 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
462 | +<?xml version='1.0' encoding='UTF-8'?> |
463 | + |
464 | +{% block apptest %} |
465 | +export APP="gallery-app-autopilot" |
466 | +{% endblock %} |
467 | |
468 | === added file 'jenkins/templates/touch-install-and-boot.xml.jinja2' |
469 | --- jenkins/templates/touch-install-and-boot.xml.jinja2 1970-01-01 00:00:00 +0000 |
470 | +++ jenkins/templates/touch-install-and-boot.xml.jinja2 2013-09-05 19:05:51 +0000 |
471 | @@ -0,0 +1,29 @@ |
472 | +{% extends "touch-base.xml.jinja2" %} |
473 | +<?xml version='1.0' encoding='UTF-8'?> |
474 | +{% block triggers %} |
475 | + <triggers class="vector"/> |
476 | +{% endblock %} |
477 | +{% block timeout %} |
478 | + <timeoutMinutes>30</timeoutMinutes> |
479 | +{% endblock timeout %} |
480 | + |
481 | +{% block shellcmds %} |
482 | + <command>set -e |
483 | +rm -rf * |
484 | + |
485 | +{% include "touch-setup.xml.jinja2" %} |
486 | + |
487 | +{% if system_image %} |
488 | +export TOUCH_IMAGE=--ubuntu-bootstrap |
489 | +{% endif %} |
490 | +#Wait for images to actually show up on cdimage |
491 | +sleep 300 |
492 | +${BZRDIR}/scripts/provision.sh |
493 | + |
494 | +${BZRDIR}/scripts/run-touch-utah-runlist.sh -s $ANDROID_SERIAL -r lp:~cjohnston/ubuntu-test-cases/convergence/tests/touch-smoke-boot.run |
495 | + </command> |
496 | +{% endblock %} |
497 | + |
498 | +{% block artifacts %} |
499 | + <artifacts>clientlogs/*</artifacts> |
500 | +{% endblock %} |
501 | |
502 | === added file 'jenkins/templates/touch-master.xml.jinja2' |
503 | --- jenkins/templates/touch-master.xml.jinja2 1970-01-01 00:00:00 +0000 |
504 | +++ jenkins/templates/touch-master.xml.jinja2 2013-09-05 19:05:51 +0000 |
505 | @@ -0,0 +1,54 @@ |
506 | +{% extends "touch-base.xml.jinja2" %} |
507 | +{% block triggers %} |
508 | + <triggers class="vector"> |
509 | + <com.redfin.hudson.UrlChangeTrigger> |
510 | + <spec></spec> |
511 | + <url>{{trigger_url}}</url> |
512 | + </com.redfin.hudson.UrlChangeTrigger> |
513 | + </triggers> |
514 | +{% endblock %} |
515 | +{% block shellblock %}{% endblock %} |
516 | +{% block extrasteps %} |
517 | +{% for project in projects %} |
518 | + <hudson.plugins.parameterizedtrigger.TriggerBuilder> |
519 | + <configs> |
520 | + <hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig> |
521 | + <configs class="java.util.Collections$EmptyList"/> |
522 | + <projects>{{project}}</projects> |
523 | + <condition>ALWAYS</condition> |
524 | + <triggerWithNoParameters>false</triggerWithNoParameters> |
525 | + <block> |
526 | +{% if "install-and-boot" in project %} |
527 | + <buildStepFailureThreshold> |
528 | + <name>FAILURE</name> |
529 | + <ordinal>2</ordinal> |
530 | + <color>RED</color> |
531 | + </buildStepFailureThreshold> |
532 | +{% endif %} |
533 | + <unstableThreshold> |
534 | + <name>UNSTABLE</name> |
535 | + <ordinal>1</ordinal> |
536 | + <color>YELLOW</color> |
537 | + </unstableThreshold> |
538 | +{% if "install-and-boot" in project or "default" in project %} |
539 | + <failureThreshold> |
540 | + <name>FAILURE</name> |
541 | + <ordinal>2</ordinal> |
542 | + <color>RED</color> |
543 | + </failureThreshold> |
544 | +{% endif %} |
545 | + </block> |
546 | + <buildAllNodesWithLabel>false</buildAllNodesWithLabel> |
547 | + </hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig> |
548 | + </configs> |
549 | + </hudson.plugins.parameterizedtrigger.TriggerBuilder> |
550 | +{% endfor %} |
551 | +{% endblock %} |
552 | +{% block timeout %} |
553 | + <timeoutMinutes>300</timeoutMinutes> |
554 | +{% endblock timeout %} |
555 | +{% block artifactblock %}{% endblock %} |
556 | +{% block descriptionsetter %}{% endblock %} |
557 | +{% block buildpublisher %}{% endblock %} |
558 | +{% block mailer %}{% endblock %} |
559 | +{% block locks %}{% endblock %} |
560 | |
561 | === added file 'jenkins/templates/touch-mediaplayer-app-autopilot.xml.jinja2' |
562 | --- jenkins/templates/touch-mediaplayer-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
563 | +++ jenkins/templates/touch-mediaplayer-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
564 | @@ -0,0 +1,6 @@ |
565 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
566 | +<?xml version='1.0' encoding='UTF-8'?> |
567 | + |
568 | +{% block apptest %} |
569 | +export APP="mediaplayer-app-autopilot" |
570 | +{% endblock %} |
571 | |
572 | === added file 'jenkins/templates/touch-memevent.xml.jinja2' |
573 | --- jenkins/templates/touch-memevent.xml.jinja2 1970-01-01 00:00:00 +0000 |
574 | +++ jenkins/templates/touch-memevent.xml.jinja2 2013-09-05 19:05:51 +0000 |
575 | @@ -0,0 +1,9 @@ |
576 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
577 | +<?xml version='1.0' encoding='UTF-8'?> |
578 | +{% block timeout %} |
579 | + <timeoutMinutes>30</timeoutMinutes> |
580 | +{% endblock timeout %} |
581 | + |
582 | +{% block apptest %} |
583 | +export APP="memevent" |
584 | +{% endblock %} |
585 | |
586 | === added file 'jenkins/templates/touch-messaging-app-autopilot.xml.jinja2' |
587 | --- jenkins/templates/touch-messaging-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
588 | +++ jenkins/templates/touch-messaging-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
589 | @@ -0,0 +1,6 @@ |
590 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
591 | +<?xml version='1.0' encoding='UTF-8'?> |
592 | + |
593 | +{% block apptest %} |
594 | +export APP="messaging-app-autopilot" |
595 | +{% endblock %} |
596 | |
597 | === added file 'jenkins/templates/touch-music-app-autopilot.xml.jinja2' |
598 | --- jenkins/templates/touch-music-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
599 | +++ jenkins/templates/touch-music-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
600 | @@ -0,0 +1,6 @@ |
601 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
602 | +<?xml version='1.0' encoding='UTF-8'?> |
603 | + |
604 | +{% block apptest %} |
605 | +export APP="music-app-autopilot" |
606 | +{% endblock %} |
607 | |
608 | === added file 'jenkins/templates/touch-notes-app-autopilot.xml.jinja2' |
609 | --- jenkins/templates/touch-notes-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
610 | +++ jenkins/templates/touch-notes-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
611 | @@ -0,0 +1,6 @@ |
612 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
613 | +<?xml version='1.0' encoding='UTF-8'?> |
614 | + |
615 | +{% block apptest %} |
616 | +export APP="notes-app-autopilot" |
617 | +{% endblock %} |
618 | |
619 | === added file 'jenkins/templates/touch-phone-app-connected-autopilot.xml.jinja2' |
620 | --- jenkins/templates/touch-phone-app-connected-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
621 | +++ jenkins/templates/touch-phone-app-connected-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
622 | @@ -0,0 +1,6 @@ |
623 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
624 | +<?xml version='1.0' encoding='UTF-8'?> |
625 | + |
626 | +{% block apptest %} |
627 | +export APP="phone-app-connected-autopilot" |
628 | +{% endblock %} |
629 | |
630 | === added file 'jenkins/templates/touch-sdk.xml.jinja2' |
631 | --- jenkins/templates/touch-sdk.xml.jinja2 1970-01-01 00:00:00 +0000 |
632 | +++ jenkins/templates/touch-sdk.xml.jinja2 2013-09-05 19:05:51 +0000 |
633 | @@ -0,0 +1,20 @@ |
634 | +{% extends "touch-base.xml.jinja2" %} |
635 | +<?xml version='1.0' encoding='UTF-8'?> |
636 | +{% block triggers %} |
637 | + <triggers class="vector"/> |
638 | +{% endblock %} |
639 | +{% block timeout %} |
640 | + <timeoutMinutes>30</timeoutMinutes> |
641 | +{% endblock timeout %} |
642 | + |
643 | +{% block shellcmds %} |
644 | + <command>rm -rf * |
645 | +{% include "touch-setup.xml.jinja2" %} |
646 | + |
647 | +${BZRDIR}/scripts/run-touch-utah-runlist.sh -s $ANDROID_SERIAL -r lp:~cjohnston/ubuntu-test-cases/convergence/tests/touch-smoke-sdk.run |
648 | +</command> |
649 | +{% endblock %} |
650 | + |
651 | +{% block artifacts %} |
652 | + <artifacts>clientlogs/*</artifacts> |
653 | +{% endblock %} |
654 | |
655 | === added file 'jenkins/templates/touch-security.xml.jinja2' |
656 | --- jenkins/templates/touch-security.xml.jinja2 1970-01-01 00:00:00 +0000 |
657 | +++ jenkins/templates/touch-security.xml.jinja2 2013-09-05 19:05:51 +0000 |
658 | @@ -0,0 +1,20 @@ |
659 | +{% extends "touch-base.xml.jinja2" %} |
660 | +<?xml version='1.0' encoding='UTF-8'?> |
661 | +{% block triggers %} |
662 | + <triggers class="vector"/> |
663 | +{% endblock %} |
664 | +{% block timeout %} |
665 | + <timeoutMinutes>30</timeoutMinutes> |
666 | +{% endblock timeout %} |
667 | + |
668 | +{% block shellcmds %} |
669 | + <command>rm -rf * |
670 | +{% include "touch-setup.xml.jinja2" %} |
671 | + |
672 | +${BZRDIR}/scripts/run-touch-utah-runlist.sh -s $ANDROID_SERIAL -r lp:~cjohnston/ubuntu-test-cases/convergence/tests/touch-smoke-security.run |
673 | +</command> |
674 | +{% endblock %} |
675 | + |
676 | +{% block artifacts %} |
677 | + <artifacts>clientlogs/*</artifacts> |
678 | +{% endblock %} |
679 | |
680 | === added file 'jenkins/templates/touch-setup.xml.jinja2' |
681 | --- jenkins/templates/touch-setup.xml.jinja2 1970-01-01 00:00:00 +0000 |
682 | +++ jenkins/templates/touch-setup.xml.jinja2 2013-09-05 19:05:51 +0000 |
683 | @@ -0,0 +1,5 @@ |
684 | +BRANCH="lp:~cjohnston/ubuntu-test-cases/convergence" |
685 | +BZRDIR=`echo "$BRANCH" | awk -F/ '{ print $(NF) }'` |
686 | +bzr branch ${BRANCH} ${BZRDIR} |
687 | + |
688 | +export ANDROID_SERIAL=$(${BZRDIR}/scripts/get-adb-id {{name}}) |
689 | |
690 | === added file 'jenkins/templates/touch-share-app-autopilot.xml.jinja2' |
691 | --- jenkins/templates/touch-share-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
692 | +++ jenkins/templates/touch-share-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
693 | @@ -0,0 +1,6 @@ |
694 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
695 | +<?xml version='1.0' encoding='UTF-8'?> |
696 | + |
697 | +{% block apptest %} |
698 | +export APP="share-app-autopilot" |
699 | +{% endblock %} |
700 | |
701 | === added file 'jenkins/templates/touch-smem.xml.jinja2' |
702 | --- jenkins/templates/touch-smem.xml.jinja2 1970-01-01 00:00:00 +0000 |
703 | +++ jenkins/templates/touch-smem.xml.jinja2 2013-09-05 19:05:51 +0000 |
704 | @@ -0,0 +1,20 @@ |
705 | +{% extends "touch-base.xml.jinja2" %} |
706 | + |
707 | +{% block triggers %} |
708 | + <triggers class="vector"/> |
709 | +{% endblock %} |
710 | +{% block timeout %} |
711 | + <timeoutMinutes>60</timeoutMinutes> |
712 | +{% endblock timeout %} |
713 | + |
714 | +{% block shellcmds %} |
715 | + <command>rm -rf * |
716 | +{% include "touch-setup.xml.jinja2" %} |
717 | + |
718 | +${BZRDIR}/scripts/run-touch-utah-runlist.sh -s $ANDROID_SERIAL -p /tmp/results -r lp:~ubuntu-test-case-dev/ubuntu-test-cases/qa-baseline-testing/runlists/smem.run |
719 | +</command> |
720 | +{% endblock %} |
721 | + |
722 | +{% block artifacts %} |
723 | + <artifacts>clientlogs/*,results/**/*</artifacts> |
724 | +{% endblock %} |
725 | |
726 | === added file 'jenkins/templates/touch-ubuntu-calculator-app-autopilot.xml.jinja2' |
727 | --- jenkins/templates/touch-ubuntu-calculator-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
728 | +++ jenkins/templates/touch-ubuntu-calculator-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
729 | @@ -0,0 +1,6 @@ |
730 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
731 | +<?xml version='1.0' encoding='UTF-8'?> |
732 | + |
733 | +{% block apptest %} |
734 | +export APP="ubuntu-calculator-app-autopilot" |
735 | +{% endblock %} |
736 | |
737 | === added file 'jenkins/templates/touch-ubuntu-clock-app-autopilot.xml.jinja2' |
738 | --- jenkins/templates/touch-ubuntu-clock-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
739 | +++ jenkins/templates/touch-ubuntu-clock-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
740 | @@ -0,0 +1,6 @@ |
741 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
742 | +<?xml version='1.0' encoding='UTF-8'?> |
743 | + |
744 | +{% block apptest %} |
745 | +export APP="ubuntu-clock-app-autopilot" |
746 | +{% endblock %} |
747 | |
748 | === added file 'jenkins/templates/touch-ubuntu-clock-autopilot.xml.jinja2' |
749 | --- jenkins/templates/touch-ubuntu-clock-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
750 | +++ jenkins/templates/touch-ubuntu-clock-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
751 | @@ -0,0 +1,6 @@ |
752 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
753 | +<?xml version='1.0' encoding='UTF-8'?> |
754 | + |
755 | +{% block apptest %} |
756 | +export APP="ubuntu-clock-autopilot" |
757 | +{% endblock %} |
758 | |
759 | === added file 'jenkins/templates/touch-ubuntu-docviewer-app-autopilot.xml.jinja2' |
760 | --- jenkins/templates/touch-ubuntu-docviewer-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
761 | +++ jenkins/templates/touch-ubuntu-docviewer-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
762 | @@ -0,0 +1,6 @@ |
763 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
764 | +<?xml version='1.0' encoding='UTF-8'?> |
765 | + |
766 | +{% block apptest %} |
767 | +export APP="ubuntu-docviewer-app-autopilot" |
768 | +{% endblock %} |
769 | |
770 | === added file 'jenkins/templates/touch-ubuntu-filemanager-app-autopilot.xml.jinja2' |
771 | --- jenkins/templates/touch-ubuntu-filemanager-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
772 | +++ jenkins/templates/touch-ubuntu-filemanager-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
773 | @@ -0,0 +1,6 @@ |
774 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
775 | +<?xml version='1.0' encoding='UTF-8'?> |
776 | + |
777 | +{% block apptest %} |
778 | +export APP="ubuntu-filemanager-app-autopilot" |
779 | +{% endblock %} |
780 | |
781 | === added file 'jenkins/templates/touch-ubuntu-rssreader-app-autopilot.xml.jinja2' |
782 | --- jenkins/templates/touch-ubuntu-rssreader-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
783 | +++ jenkins/templates/touch-ubuntu-rssreader-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
784 | @@ -0,0 +1,6 @@ |
785 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
786 | +<?xml version='1.0' encoding='UTF-8'?> |
787 | + |
788 | +{% block apptest %} |
789 | +export APP="ubuntu-rssreader-app-autopilot" |
790 | +{% endblock %} |
791 | |
792 | === added file 'jenkins/templates/touch-ubuntu-terminal-app-autopilot.xml.jinja2' |
793 | --- jenkins/templates/touch-ubuntu-terminal-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
794 | +++ jenkins/templates/touch-ubuntu-terminal-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
795 | @@ -0,0 +1,6 @@ |
796 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
797 | +<?xml version='1.0' encoding='UTF-8'?> |
798 | + |
799 | +{% block apptest %} |
800 | +export APP="ubuntu-terminal-app-autopilot" |
801 | +{% endblock %} |
802 | |
803 | === added file 'jenkins/templates/touch-ubuntu-weather-app-autopilot.xml.jinja2' |
804 | --- jenkins/templates/touch-ubuntu-weather-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
805 | +++ jenkins/templates/touch-ubuntu-weather-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
806 | @@ -0,0 +1,6 @@ |
807 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
808 | +<?xml version='1.0' encoding='UTF-8'?> |
809 | + |
810 | +{% block apptest %} |
811 | +export APP="ubuntu-weather-app-autopilot" |
812 | +{% endblock %} |
813 | |
814 | === added file 'jenkins/templates/touch-unity8-autopilot.xml.jinja2' |
815 | --- jenkins/templates/touch-unity8-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
816 | +++ jenkins/templates/touch-unity8-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
817 | @@ -0,0 +1,6 @@ |
818 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
819 | +<?xml version='1.0' encoding='UTF-8'?> |
820 | + |
821 | +{% block apptest %} |
822 | +export APP="unity8-autopilot" |
823 | +{% endblock %} |
824 | |
825 | === added file 'jenkins/templates/touch-upgrade.xml.jinja2' |
826 | --- jenkins/templates/touch-upgrade.xml.jinja2 1970-01-01 00:00:00 +0000 |
827 | +++ jenkins/templates/touch-upgrade.xml.jinja2 2013-09-05 19:05:51 +0000 |
828 | @@ -0,0 +1,28 @@ |
829 | +{% extends "touch-base.xml.jinja2" %} |
830 | +<?xml version='1.0' encoding='UTF-8'?> |
831 | +{% block triggers %} |
832 | + <triggers class="vector"/> |
833 | +{% endblock %} |
834 | +{% block timeout %} |
835 | + <timeoutMinutes>30</timeoutMinutes> |
836 | +{% endblock timeout %} |
837 | + |
838 | +{% block shellcmds %} |
839 | + <command>rm -rf * |
840 | +{% include "touch-setup.xml.jinja2" %} |
841 | + |
842 | +${BZRDIR}/scrips/run-touch-upgrade.sh |
843 | +</command> |
844 | +{% endblock %} |
845 | + |
846 | +{% block artifacts %} |
847 | + <artifacts>clientlogs/*, **/jenkins.sh</artifacts> |
848 | +{% endblock %} |
849 | + |
850 | +{% block descriptionsetter %} |
851 | + <hudson.plugins.descriptionsetter.DescriptionSetterPublisher> |
852 | + <regexp>^UPGRADED TO VERSION: (.*)</regexp> |
853 | + <regexpForFailed>^UPGRADED TO VERSION: (.*)</regexpForFailed> |
854 | + <setForMatrix>false</setForMatrix> |
855 | + </hudson.plugins.descriptionsetter.DescriptionSetterPublisher> |
856 | +{% endblock %} |
857 | |
858 | === added file 'jenkins/templates/touch-webbrowser-app-autopilot.xml.jinja2' |
859 | --- jenkins/templates/touch-webbrowser-app-autopilot.xml.jinja2 1970-01-01 00:00:00 +0000 |
860 | +++ jenkins/templates/touch-webbrowser-app-autopilot.xml.jinja2 2013-09-05 19:05:51 +0000 |
861 | @@ -0,0 +1,6 @@ |
862 | +{% extends "touch-autopilot-base.xml.jinja2" %} |
863 | +<?xml version='1.0' encoding='UTF-8'?> |
864 | + |
865 | +{% block apptest %} |
866 | +export APP="webbrowser-app-autopilot" |
867 | +{% endblock %} |
868 | |
869 | === added directory 'scripts' |
870 | === added file 'scripts/get-adb-id' |
871 | --- scripts/get-adb-id 1970-01-01 00:00:00 +0000 |
872 | +++ scripts/get-adb-id 2013-09-05 19:05:51 +0000 |
873 | @@ -0,0 +1,32 @@ |
874 | +#!/usr/bin/python |
875 | + |
876 | +import sys |
877 | + |
878 | +DEVICES = { |
879 | +"maguro-01":"0149BD7E0A019003", |
880 | +"maguro-02":"0149BD7E0200E00F", |
881 | +"maguro-04":"0149BDCC0500701B", |
882 | +"maguro-05":"0149BD3418014013", |
883 | +"mako-01":"01aa3d7a5dcba4a2", |
884 | +"mako-02":"01ade38b552014d4", |
885 | +"mako-05":"01b22f82dc5cec63", |
886 | +"mako-06":"04ed70928fdc13ba", |
887 | +"mako-07":"01e2f64788556934", |
888 | +"grouper-02":"015d1884951c020e", |
889 | +"grouper-03":"015d18ad5c27f80d", |
890 | +"grouper-04":"015d188445242611", |
891 | +"grouper-05":"015d21d9151c0019", |
892 | +"manta-01":"R32D102RPZL", |
893 | +"manta-02":"R32D102RPPK", |
894 | +"manta-04":"R32D203DDZR", |
895 | +"manta-05":"R32D203DMBY", |
896 | +} |
897 | + |
898 | +name = sys.argv[1] |
899 | + |
900 | +try: |
901 | + print DEVICES[name] |
902 | +except KeyError: |
903 | + print "Unknown device name: '%s'" % name |
904 | + sys.exit(-1) |
905 | + |
906 | |
907 | === added file 'scripts/jenkins.sh' |
908 | --- scripts/jenkins.sh 1970-01-01 00:00:00 +0000 |
909 | +++ scripts/jenkins.sh 2013-09-05 19:05:51 +0000 |
910 | @@ -0,0 +1,111 @@ |
911 | +#!/bin/bash |
912 | + |
913 | +## This is the script jenkins should run to execute various touch applications |
914 | +## Intersting environment variables that must be set: |
915 | +## ANDROID_SERIAL - specify another android device |
916 | +## APP - the name of the app to test, ie share_app_autopilot |
917 | +## QUICK - if set, skips the reboot and wait-for-network logic |
918 | +## FROM_HOST - if set, runs the test from the host instead of the target |
919 | + |
920 | +set -e |
921 | + |
922 | +BASEDIR=$(dirname $(readlink -f $0))/.. |
923 | + |
924 | +RESDIR=`pwd`/clientlogs |
925 | +UTAHFILE=${RESDIR}/utah.yaml |
926 | +UTAH_PHABLET_CMD="${UTAH_PHABLET_CMD-/usr/share/utah/examples/run_utah_phablet.py}" |
927 | + |
928 | +ANDROID_SERIAL="${ANDROID_SERIAL-015d1884b20c1c0f}" #doanac's nexus7 at home |
929 | + |
930 | +TESTSUITE_HOST=$(readlink -f ${BASEDIR}/tests/${APP}) |
931 | +TESTSUITE_TARGET_BASE=/tmp/tests |
932 | +TESTSUITE_TARGET=${TESTSUITE_TARGET_BASE}/$(basename ${TESTSUITE_HOST}) |
933 | + |
934 | +cleanup() { |
935 | + set +e |
936 | +} |
937 | + |
938 | +test_from_target() { |
939 | + # push the runlist over to the test |
940 | + adb push ${BASEDIR}/tests ${TESTSUITE_TARGET_BASE} &> /dev/null |
941 | + ${UTAH_PHABLET_CMD} \ |
942 | + -s ${ANDROID_SERIAL} \ |
943 | + --results-dir ${RESDIR} \ |
944 | + --skip-install --skip-network --skip-utah \ |
945 | + --pull /var/crash \ |
946 | + --pull /home/phablet/.cache/upstart \ |
947 | + -l ${TESTSUITE_TARGET}/master.run |
948 | +} |
949 | + |
950 | +test_from_host() { |
951 | + export ANDROID_SERIAL # need for utils/hosts scripts |
952 | + |
953 | + export PATH=${BASEDIR}/utils/host:${PATH} |
954 | + |
955 | + # allow for certain commands to run from host/target |
956 | + # see unity8-autopilot/ts_control for example |
957 | + export TARGET_PREFIX=adb-shell |
958 | + |
959 | + sudo TARGET_PREFIX=$TARGET_PREFIX PATH="${PATH}" ${UTAH_PHABLET_CMD} \ |
960 | + -s ${ANDROID_SERIAL} \ |
961 | + --from-host \ |
962 | + --results-dir ${RESDIR} \ |
963 | + --skip-install --skip-network --skip-utah \ |
964 | + --pull /var/crash \ |
965 | + --pull /home/phablet/.cache/upstart \ |
966 | + -l ${TESTSUITE_HOST}/master.run |
967 | +} |
968 | + |
969 | +main() { |
970 | + rm -rf clientlogs |
971 | + mkdir clientlogs |
972 | + |
973 | + # print the build date so the jenkins job can use it as the |
974 | + # build description |
975 | + adb -s ${ANDROID_SERIAL} pull /var/log/installer/media-info ${RESDIR} |
976 | + BUILDID=$(adb -s ${ANDROID_SERIAL} shell cat /home/phablet/.ci-version) |
977 | + echo "= TOUCH IMAGE VERSION:$BUILDID" |
978 | + |
979 | + adb shell "top -n1 -b" > ${RESDIR}/top.log |
980 | + |
981 | + set -x |
982 | + adb shell 'rm -f /var/crash/*' |
983 | + if [ -z $QUICK ] ; then |
984 | + # get the phone in sane place |
985 | + adb -s ${ANDROID_SERIAL} reboot |
986 | + # sometimes reboot doesn't happen fast enough, so add a little |
987 | + # delay to help ensure its actually rebooted and we didn't just |
988 | + # connect back to the device before it rebooted |
989 | + adb -s ${ANDROID_SERIAL} wait-for-device |
990 | + sleep 5 |
991 | + adb -s ${ANDROID_SERIAL} wait-for-device |
992 | + phablet-network -s ${ANDROID_SERIAL} --skip-setup |
993 | + else |
994 | + echo "SKIPPING phone reboot..." |
995 | + fi |
996 | + |
997 | + if [ -z $FROM_HOST ] ; then |
998 | + echo "launching test on the target...." |
999 | + test_from_target |
1000 | + else |
1001 | + echo "launching test from the host...." |
1002 | + test_from_host |
1003 | + fi |
1004 | + adb shell 'rm -f /var/crash/*' |
1005 | + |
1006 | + if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then |
1007 | + echo "errors found" |
1008 | + EXITCODE=1 |
1009 | + fi |
1010 | + if ! `grep "^failures: [!0]" < $UTAHFILE >/dev/null` ; then |
1011 | + echo "failures found" |
1012 | + EXITCODE=2 |
1013 | + fi |
1014 | + echo "Results Summary" |
1015 | + echo "---------------" |
1016 | + egrep '^(errors|failures|passes|fetch_errors):' $UTAHFILE |
1017 | + exit $EXITCODE |
1018 | +} |
1019 | + |
1020 | +trap cleanup TERM INT EXIT |
1021 | +main |
1022 | |
1023 | === added file 'scripts/provision.sh' |
1024 | --- scripts/provision.sh 1970-01-01 00:00:00 +0000 |
1025 | +++ scripts/provision.sh 2013-09-05 19:05:51 +0000 |
1026 | @@ -0,0 +1,41 @@ |
1027 | +#!/bin/bash |
1028 | + |
1029 | +## This is the script jenkins should run to provision a device in the lab |
1030 | +## Intersting environment variables that must be set: |
1031 | +## ANDROID_SERIAL - specify another android device |
1032 | +## NETWORK_FILE - an alternative network file if you aren't in the lab |
1033 | +## TOUCH_IMAGE=--ubuntu-bootstrap (provision with read-only system image) |
1034 | + |
1035 | +set -e |
1036 | +set -x |
1037 | + |
1038 | +BASEDIR=$(dirname $(readlink -f $0)) |
1039 | + |
1040 | +RESDIR=`pwd`/clientlogs |
1041 | +UTAH_PHABLET_CMD="${UTAH_PHABLET_CMD-/usr/share/utah/examples/run_utah_phablet.py}" |
1042 | + |
1043 | +ANDROID_SERIAL="${ANDROID_SERIAL-015d1884b20c1c0f}" #doanac's nexus7 at home |
1044 | +NETWORK_FILE="${NETWORK_FILE-/home/ubuntu/magners-wifi}" |
1045 | + |
1046 | +rm -rf clientlogs |
1047 | +mkdir clientlogs |
1048 | + |
1049 | +${UTAH_PHABLET_CMD} -s ${ANDROID_SERIAL} --results-dir ${RESDIR} --network-file=${NETWORK_FILE} ${TOUCH_IMAGE} |
1050 | + |
1051 | +# mark the version we installed in /home/phablet/.ci-version |
1052 | +if [ -n "$TOUCH_IMAGE" ]; then |
1053 | + DEVICE_TYPE=$(adb -s ${ANDROID_SERIAL} shell "getprop ro.cm.device" |tr -d '\r') |
1054 | + bzr export utils lp:~ubuntu-system-image/ubuntu-system-image/server/utils |
1055 | + IMAGEVER=$(utils/check-latest ${DEVICE_TYPE} |sed -n 's/Current full image: \([0-9]*\).*ubuntu=\([0-9\.]*\),.*=\([0-9\.]*\))/\1:\2:\3/p') |
1056 | + rm -rf utils |
1057 | +else |
1058 | + IMAGEVER=$(adb -s ${ANDROID_SERIAL} shell "cat /var/log/installer/media-info |sed 's/.*(\([0-9\.]*\))/\1/'") |
1059 | +fi |
1060 | +adb -s ${ANDROID_SERIAL} shell "echo '${IMAGEVER}' > /home/phablet/.ci-version" |
1061 | + |
1062 | +# get our target-based utilities into our PATH |
1063 | +adb -s ${ANDROID_SERIAL} push ${BASEDIR}/../utils/target /usr/local/bin/ |
1064 | + |
1065 | +# ensure the "edges intro" is disabled so that it doesn't cause noise |
1066 | +# in the system |
1067 | +adb -s ${ANDROID_SERIAL} shell dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User32011 org.freedesktop.DBus.Properties.Set string:com.canonical.unity.AccountsService string:demo-edges variant:boolean:false |
1068 | |
1069 | === added file 'scripts/run-touch-upgrade.sh' |
1070 | --- scripts/run-touch-upgrade.sh 1970-01-01 00:00:00 +0000 |
1071 | +++ scripts/run-touch-upgrade.sh 2013-09-05 19:05:51 +0000 |
1072 | @@ -0,0 +1,46 @@ |
1073 | +#!/bin/bash |
1074 | + |
1075 | +## This is the script jenkins should run to test upgrading a system image |
1076 | +## in the lab. |
1077 | +## Intersting environment variables that must be set: |
1078 | +## ANDROID_SERIAL - specify another android device |
1079 | +## RUNLIST - the path the runlist |
1080 | +## NETWORK_FILE - specify an alternative network file (passed to runlist) |
1081 | +## UPGRADE_FROM - the revision to upgrade from, eg -1 (passed to runlist) |
1082 | + |
1083 | +set -eux |
1084 | + |
1085 | +BASEDIR=$(dirname $(readlink -f $0)) |
1086 | + |
1087 | +RESDIR=`pwd`/clientlogs |
1088 | + |
1089 | +UTAH_PHABLET_CMD="${UTAH_PHABLET_CMD-/usr/share/utah/examples/run_utah_phablet.py}" |
1090 | +RUNLIST=${RUNLIST-"`pwd`/smoke-touch-apps/upgrade/master.run"} |
1091 | +ANDROID_SERIAL="${ANDROID_SERIAL-015d1884b20c1c0f}" #doanac's nexus7 at home |
1092 | +NETWORK_FILE="${NETWORK_FILE-/home/ubuntu/magners-wifi}" |
1093 | + |
1094 | +rm -rf clientlogs |
1095 | +mkdir clientlogs |
1096 | + |
1097 | +export ANDROID_SERIAL=$ANDROID_SERIAL |
1098 | + |
1099 | +set +e |
1100 | +sudo NETWORK_FILE=$NETWORK_FILE \ |
1101 | + $UTAH_PHABLET_CMD -s $ANDROID_SERIAL \ |
1102 | + --from-host --skip-install --skip-utah --skip-network -l $RUNLIST \ |
1103 | + --results-dir=$RESDIR |
1104 | +EXITCODE=$? |
1105 | + |
1106 | +UTAHFILE=$RESDIR/utah.yaml |
1107 | +if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then |
1108 | + echo "errors found" |
1109 | + EXITCODE=1 |
1110 | +fi |
1111 | +if ! `grep "^failures: [!0]" < $UTAHFILE >/dev/null` ; then |
1112 | + echo "failures found" |
1113 | + EXITCODE=2 |
1114 | +fi |
1115 | +echo "Results Summary" |
1116 | +echo "---------------" |
1117 | +egrep '^(errors|failures|passes|fetch_errors):' $UTAHFILE |
1118 | +exit $EXITCODE |
1119 | |
1120 | === added file 'scripts/run-touch-utah-runlist.sh' |
1121 | --- scripts/run-touch-utah-runlist.sh 1970-01-01 00:00:00 +0000 |
1122 | +++ scripts/run-touch-utah-runlist.sh 2013-09-05 19:05:51 +0000 |
1123 | @@ -0,0 +1,66 @@ |
1124 | +#!/bin/bash |
1125 | +# Run tests on ubuntu-touch devices and gather the results |
1126 | +# Set $RUNLIST to the runlist you wish to run |
1127 | +set -x |
1128 | + |
1129 | +BRANCH=lp:~cjohnston/ubuntu-test-cases/convergence |
1130 | +WORKSPACE=/home/phablet/workspace |
1131 | +RESDIR=`pwd`/clientlogs |
1132 | +UTAHFILE=${RESDIR}/utah.yaml |
1133 | +UTAH_PHABLET_CMD="${UTAH_PHABLET_CMD-/usr/share/utah/examples/run_utah_phablet.py}" |
1134 | + |
1135 | +function show_usage() { |
1136 | + echo "USAGE: $0 -s ANDROID_SERIAL -r RUNLIST" |
1137 | + echo " -p - List of additional files/dirs to pull from target" |
1138 | + exit 0 |
1139 | +} |
1140 | + |
1141 | +while getopts "h?p:r:s:" opt; do |
1142 | + case "$opt" in |
1143 | + h|\?) |
1144 | + show_usage |
1145 | + ;; |
1146 | + p) PULL_LIST=$OPTARG |
1147 | + ;; |
1148 | + r) RUNLIST=$OPTARG |
1149 | + ;; |
1150 | + s) ANDROID_SERIAL=$OPTARG |
1151 | + ;; |
1152 | + esac |
1153 | +done |
1154 | +if [ -z $ANDROID_SERIAL ]; then show_usage; fi |
1155 | + |
1156 | +if [ -n "$PULL_LIST" ]; then |
1157 | + PULL="--pull $PULL_LIST" |
1158 | +fi |
1159 | + |
1160 | +if [ -z $QUICK ]; then |
1161 | + adb -s $ANDROID_SERIAL reboot |
1162 | + adb -s $ANDROID_SERIAL wait-for-device |
1163 | + sleep 5 |
1164 | + adb -s $ANDROID_SERIAL wait-for-device |
1165 | + phablet-network -s ${ANDROID_SERIAL} --skip-setup |
1166 | +else |
1167 | + echo "SKIPPING phone reboot..." |
1168 | +fi |
1169 | +rm -rf ${RESDIR} |
1170 | +mkdir -p ${RESDIR} |
1171 | +adb -s ${ANDROID_SERIAL} pull /var/log/installer/media-info ${RESDIR} |
1172 | +BUILDID=$(adb -s ${ANDROID_SERIAL} shell cat /home/phablet/.ci-version) |
1173 | +echo "= TOUCH IMAGE VERSION:$BUILDID" |
1174 | + |
1175 | +${UTAH_PHABLET_CMD} \ |
1176 | + -s ${ANDROID_SERIAL} \ |
1177 | + --results-dir ${RESDIR} \ |
1178 | + --skip-install --skip-network --skip-utah \ |
1179 | + ${PULL} \ |
1180 | + -l ${RUNLIST} |
1181 | + |
1182 | +if ! `grep "^errors: [!0]" < $UTAHFILE >/dev/null` ; then |
1183 | + echo "errors found" |
1184 | + exit 1 |
1185 | +fi |
1186 | +if ! `grep "^failures: [!0]" < $UTAHFILE >/dev/null` ; then |
1187 | + echo "failures found" |
1188 | + exit 2 |
1189 | +fi |
1190 | |
1191 | === added directory 'tests' |
1192 | === added directory 'tests/address-book-app-autopilot' |
1193 | === added file 'tests/address-book-app-autopilot/master.run' |
1194 | --- tests/address-book-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1195 | +++ tests/address-book-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1196 | @@ -0,0 +1,15 @@ |
1197 | +--- |
1198 | +testsuites: |
1199 | + - name: settle-before |
1200 | + fetch_method: dev |
1201 | + fetch_location: ../systemsettle |
1202 | + include_tests: |
1203 | + - systemsettle-before |
1204 | + - name: address-book-app-autopilot |
1205 | + fetch_method: dev |
1206 | + fetch_location: ./ |
1207 | + - name: settle-after |
1208 | + fetch_method: dev |
1209 | + fetch_location: ../systemsettle |
1210 | + include_tests: |
1211 | + - systemsettle-after |
1212 | |
1213 | === added file 'tests/address-book-app-autopilot/ts_control' |
1214 | --- tests/address-book-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1215 | +++ tests/address-book-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1216 | @@ -0,0 +1,1 @@ |
1217 | +ts_setup: PKGS=address-book-app-autopilot prepare-autopilot-test.sh |
1218 | |
1219 | === added file 'tests/address-book-app-autopilot/tslist.auto' |
1220 | --- tests/address-book-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1221 | +++ tests/address-book-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1222 | @@ -0,0 +1,4 @@ |
1223 | +- |
1224 | + discovery_cmd: autopilot-list address_book_app |
1225 | + test_cmd: autopilot-run address_book_app.tests.{} |
1226 | + |
1227 | |
1228 | === added directory 'tests/calendar-app-autopilot' |
1229 | === added file 'tests/calendar-app-autopilot/master.run' |
1230 | --- tests/calendar-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1231 | +++ tests/calendar-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1232 | @@ -0,0 +1,15 @@ |
1233 | +--- |
1234 | +testsuites: |
1235 | + - name: settle-before |
1236 | + fetch_method: dev |
1237 | + fetch_location: ../systemsettle |
1238 | + include_tests: |
1239 | + - systemsettle-before |
1240 | + - name: calendar-app-autopilot |
1241 | + fetch_method: dev |
1242 | + fetch_location: ./ |
1243 | + - name: settle-after |
1244 | + fetch_method: dev |
1245 | + fetch_location: ../systemsettle |
1246 | + include_tests: |
1247 | + - systemsettle-after |
1248 | |
1249 | === added file 'tests/calendar-app-autopilot/ts_control' |
1250 | --- tests/calendar-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1251 | +++ tests/calendar-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1252 | @@ -0,0 +1,1 @@ |
1253 | +ts_setup: PKGS=calendar-app-autopilot prepare-autopilot-test.sh |
1254 | |
1255 | === added file 'tests/calendar-app-autopilot/tslist.auto' |
1256 | --- tests/calendar-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1257 | +++ tests/calendar-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1258 | @@ -0,0 +1,4 @@ |
1259 | +- |
1260 | + discovery_cmd: autopilot-list calendar_app |
1261 | + test_cmd: autopilot-run calendar_app.tests.{} |
1262 | + |
1263 | |
1264 | === added directory 'tests/camera-app-autopilot' |
1265 | === added file 'tests/camera-app-autopilot/master.run' |
1266 | --- tests/camera-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1267 | +++ tests/camera-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1268 | @@ -0,0 +1,15 @@ |
1269 | +--- |
1270 | +testsuites: |
1271 | + - name: settle-before |
1272 | + fetch_method: dev |
1273 | + fetch_location: ../systemsettle |
1274 | + include_tests: |
1275 | + - systemsettle-before |
1276 | + - name: camera-app-autopilot |
1277 | + fetch_method: dev |
1278 | + fetch_location: ./ |
1279 | + - name: settle-after |
1280 | + fetch_method: dev |
1281 | + fetch_location: ../systemsettle |
1282 | + include_tests: |
1283 | + - systemsettle-after |
1284 | |
1285 | === added file 'tests/camera-app-autopilot/ts_control' |
1286 | --- tests/camera-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1287 | +++ tests/camera-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1288 | @@ -0,0 +1,1 @@ |
1289 | +ts_setup: PKGS=camera-app-autopilot prepare-autopilot-test.sh |
1290 | |
1291 | === added file 'tests/camera-app-autopilot/tslist.auto' |
1292 | --- tests/camera-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1293 | +++ tests/camera-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1294 | @@ -0,0 +1,4 @@ |
1295 | +- |
1296 | + discovery_cmd: autopilot-list camera_app |
1297 | + test_cmd: autopilot-run camera_app.tests.{} |
1298 | + |
1299 | |
1300 | === added directory 'tests/default' |
1301 | === renamed directory 'ifconfig' => 'tests/default/ifconfig' |
1302 | === renamed directory 'install' => 'tests/default/install' |
1303 | === renamed file 'master.run' => 'tests/default/master.run' |
1304 | --- master.run 2013-06-14 10:01:48 +0000 |
1305 | +++ tests/default/master.run 2013-09-05 19:05:51 +0000 |
1306 | @@ -1,5 +1,5 @@ |
1307 | --- |
1308 | testsuites: |
1309 | - name: smoke_touch |
1310 | - fetch_method: bzr # one of 'bzr', 'bzr-export', 'dev', 'git' |
1311 | - fetch_location: lp:ubuntu-test-cases/touch |
1312 | + fetch_method: dev |
1313 | + fetch_location: ./ |
1314 | |
1315 | === renamed directory 'netstat' => 'tests/default/netstat' |
1316 | === renamed directory 'ping' => 'tests/default/ping' |
1317 | === renamed directory 'pwd' => 'tests/default/pwd' |
1318 | === renamed directory 'route' => 'tests/default/route' |
1319 | === renamed directory 'systemsettle' => 'tests/default/systemsettle' |
1320 | === renamed file 'ts_control' => 'tests/default/ts_control' |
1321 | === renamed file 'tslist.run' => 'tests/default/tslist.run' |
1322 | === renamed directory 'uname' => 'tests/default/uname' |
1323 | === renamed directory 'unity8' => 'tests/default/unity8' |
1324 | === renamed directory 'update' => 'tests/default/update' |
1325 | === renamed directory 'vmstat' => 'tests/default/vmstat' |
1326 | === added directory 'tests/dialer-app-autopilot' |
1327 | === added file 'tests/dialer-app-autopilot/master.run' |
1328 | --- tests/dialer-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1329 | +++ tests/dialer-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1330 | @@ -0,0 +1,15 @@ |
1331 | +--- |
1332 | +testsuites: |
1333 | + - name: settle-before |
1334 | + fetch_method: dev |
1335 | + fetch_location: ../systemsettle |
1336 | + include_tests: |
1337 | + - systemsettle-before |
1338 | + - name: dialer-app-autopilot |
1339 | + fetch_method: dev |
1340 | + fetch_location: ./ |
1341 | + - name: settle-after |
1342 | + fetch_method: dev |
1343 | + fetch_location: ../systemsettle |
1344 | + include_tests: |
1345 | + - systemsettle-after |
1346 | |
1347 | === added file 'tests/dialer-app-autopilot/ts_control' |
1348 | --- tests/dialer-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1349 | +++ tests/dialer-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1350 | @@ -0,0 +1,1 @@ |
1351 | +ts_setup: PKGS="dialer-app-autopilot ubuntu-ui-toolkit-autopilot" prepare-autopilot-test.sh |
1352 | |
1353 | === added file 'tests/dialer-app-autopilot/tslist.auto' |
1354 | --- tests/dialer-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1355 | +++ tests/dialer-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1356 | @@ -0,0 +1,4 @@ |
1357 | +- |
1358 | + discovery_cmd: autopilot-list dialer_app |
1359 | + test_cmd: autopilot-run dialer_app.tests.{} |
1360 | + |
1361 | |
1362 | === added directory 'tests/friends-app-autopilot' |
1363 | === added file 'tests/friends-app-autopilot/master.run' |
1364 | --- tests/friends-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1365 | +++ tests/friends-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1366 | @@ -0,0 +1,15 @@ |
1367 | +--- |
1368 | +testsuites: |
1369 | + - name: settle-before |
1370 | + fetch_method: dev |
1371 | + fetch_location: ../systemsettle |
1372 | + include_tests: |
1373 | + - systemsettle-before |
1374 | + - name: friends-app-autopilot |
1375 | + fetch_method: dev |
1376 | + fetch_location: ./ |
1377 | + - name: settle-after |
1378 | + fetch_method: dev |
1379 | + fetch_location: ../systemsettle |
1380 | + include_tests: |
1381 | + - systemsettle-after |
1382 | |
1383 | === added file 'tests/friends-app-autopilot/ts_control' |
1384 | --- tests/friends-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1385 | +++ tests/friends-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1386 | @@ -0,0 +1,1 @@ |
1387 | +ts_setup: PKGS=friends-app-autopilot prepare-autopilot-test.sh |
1388 | |
1389 | === added file 'tests/friends-app-autopilot/tslist.auto' |
1390 | --- tests/friends-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1391 | +++ tests/friends-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1392 | @@ -0,0 +1,4 @@ |
1393 | +- |
1394 | + discovery_cmd: autopilot-list friends_app |
1395 | + test_cmd: autopilot-run friends_app.tests.{} |
1396 | + |
1397 | |
1398 | === added directory 'tests/gallery-app-autopilot' |
1399 | === added file 'tests/gallery-app-autopilot/master.run' |
1400 | --- tests/gallery-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1401 | +++ tests/gallery-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1402 | @@ -0,0 +1,15 @@ |
1403 | +--- |
1404 | +testsuites: |
1405 | + - name: settle-before |
1406 | + fetch_method: dev |
1407 | + fetch_location: ../systemsettle |
1408 | + include_tests: |
1409 | + - systemsettle-before |
1410 | + - name: gallery-app-autopilot |
1411 | + fetch_method: dev |
1412 | + fetch_location: ./ |
1413 | + - name: settle-after |
1414 | + fetch_method: dev |
1415 | + fetch_location: ../systemsettle |
1416 | + include_tests: |
1417 | + - systemsettle-after |
1418 | |
1419 | === added file 'tests/gallery-app-autopilot/ts_control' |
1420 | --- tests/gallery-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1421 | +++ tests/gallery-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1422 | @@ -0,0 +1,1 @@ |
1423 | +ts_setup: PKGS=gallery-app-autopilot prepare-autopilot-test.sh |
1424 | |
1425 | === added file 'tests/gallery-app-autopilot/tslist.auto' |
1426 | --- tests/gallery-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1427 | +++ tests/gallery-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1428 | @@ -0,0 +1,4 @@ |
1429 | +- |
1430 | + discovery_cmd: autopilot-list gallery_app |
1431 | + test_cmd: autopilot-run gallery_app.tests.{} |
1432 | + |
1433 | |
1434 | === added directory 'tests/mediaplayer-app-autopilot' |
1435 | === added file 'tests/mediaplayer-app-autopilot/master.run' |
1436 | --- tests/mediaplayer-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
1437 | +++ tests/mediaplayer-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
1438 | @@ -0,0 +1,15 @@ |
1439 | +--- |
1440 | +testsuites: |
1441 | + - name: settle-before |
1442 | + fetch_method: dev |
1443 | + fetch_location: ../systemsettle |
1444 | + include_tests: |
1445 | + - systemsettle-before |
1446 | + - name: mediaplayer-app-autopilot |
1447 | + fetch_method: dev |
1448 | + fetch_location: ./ |
1449 | + - name: settle-after |
1450 | + fetch_method: dev |
1451 | + fetch_location: ../systemsettle |
1452 | + include_tests: |
1453 | + - systemsettle-after |
1454 | |
1455 | === added file 'tests/mediaplayer-app-autopilot/ts_control' |
1456 | --- tests/mediaplayer-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
1457 | +++ tests/mediaplayer-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
1458 | @@ -0,0 +1,1 @@ |
1459 | +ts_setup: PKGS=mediaplayer-app-autopilot prepare-autopilot-test.sh |
1460 | |
1461 | === added file 'tests/mediaplayer-app-autopilot/tslist.auto' |
1462 | --- tests/mediaplayer-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
1463 | +++ tests/mediaplayer-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
1464 | @@ -0,0 +1,4 @@ |
1465 | +- |
1466 | + discovery_cmd: autopilot-list mediaplayer_app |
1467 | + test_cmd: autopilot-run mediaplayer_app.tests.{} |
1468 | + |
1469 | |
1470 | === added directory 'tests/memevent' |
1471 | === added file 'tests/memevent/master.run' |
1472 | --- tests/memevent/master.run 1970-01-01 00:00:00 +0000 |
1473 | +++ tests/memevent/master.run 2013-09-05 19:05:51 +0000 |
1474 | @@ -0,0 +1,5 @@ |
1475 | +--- |
1476 | +testsuites: |
1477 | + - name: memevent |
1478 | + fetch_method: dev |
1479 | + fetch_location: ./ |
1480 | |
1481 | === added file 'tests/memevent/setup.sh' |
1482 | --- tests/memevent/setup.sh 1970-01-01 00:00:00 +0000 |
1483 | +++ tests/memevent/setup.sh 2013-09-05 19:05:51 +0000 |
1484 | @@ -0,0 +1,8 @@ |
1485 | +#!/bin/sh |
1486 | + |
1487 | +set -e |
1488 | + |
1489 | +# copy the autopilot scripts over if needed |
1490 | +[ -z $ANDROID_SERIAL ] || adb push ./ubuntu_test_cases /home/phablet/autopilot/ubuntu_test_cases |
1491 | + |
1492 | +PKGS="camera-app-autopilot gallery-app-autopilot mediaplayer-app-autopilot webbrowser-app-autopilot" prepare-autopilot-test.sh |
1493 | |
1494 | === added file 'tests/memevent/ts_control' |
1495 | --- tests/memevent/ts_control 1970-01-01 00:00:00 +0000 |
1496 | +++ tests/memevent/ts_control 2013-09-05 19:05:51 +0000 |
1497 | @@ -0,0 +1,1 @@ |
1498 | +ts_setup: ./setup.sh |
1499 | |
1500 | === added file 'tests/memevent/tslist.auto' |
1501 | --- tests/memevent/tslist.auto 1970-01-01 00:00:00 +0000 |
1502 | +++ tests/memevent/tslist.auto 2013-09-05 19:05:51 +0000 |
1503 | @@ -0,0 +1,7 @@ |
1504 | +--- |
1505 | +# The discovery command is run from a directory containing the whole suite |
1506 | +# The test command is run from a sub directory in that |
1507 | +# We need to run each command in the directory that contains ubuntu_test_cases |
1508 | +# so that autopilot can find our python modules |
1509 | +- discovery_cmd: cd memevent; autopilot-list ubuntu_test_cases.memory_usage_measurement |
1510 | + test_cmd: cd ..; autopilot-run ubuntu_test_cases.memory_usage_measurement.tests.{} |
1511 | |
1512 | === added directory 'tests/memevent/ubuntu_test_cases' |
1513 | === added file 'tests/memevent/ubuntu_test_cases/__init__.py' |
1514 | --- tests/memevent/ubuntu_test_cases/__init__.py 1970-01-01 00:00:00 +0000 |
1515 | +++ tests/memevent/ubuntu_test_cases/__init__.py 2013-09-05 19:05:51 +0000 |
1516 | @@ -0,0 +1,6 @@ |
1517 | +"""ubuntu_test_cases package |
1518 | + |
1519 | +Warning: This python package is installed by a different debian package in a |
1520 | +different branch. It's been been created here only because it's convenient to |
1521 | +run autopilot directly from the branch. |
1522 | +""" |
1523 | |
1524 | === added directory 'tests/memevent/ubuntu_test_cases/memory_usage_measurement' |
1525 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/__init__.py' |
1526 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/__init__.py 1970-01-01 00:00:00 +0000 |
1527 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/__init__.py 2013-09-05 19:05:51 +0000 |
1528 | @@ -0,0 +1,1 @@ |
1529 | +"""Event based memory usage measurements test cases.""" |
1530 | |
1531 | === added directory 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps' |
1532 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/__init__.py' |
1533 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/__init__.py 1970-01-01 00:00:00 +0000 |
1534 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/__init__.py 2013-09-05 19:05:51 +0000 |
1535 | @@ -0,0 +1,21 @@ |
1536 | +"""Application classes used to drive them easily with autopilot.""" |
1537 | + |
1538 | +from autopilot.input import Keyboard, Mouse, Pointer, Touch |
1539 | +from autopilot.platform import model |
1540 | + |
1541 | + |
1542 | +class App(object): |
1543 | + |
1544 | + """Application class with common code.""" |
1545 | + |
1546 | + def __init__(self, tc): |
1547 | + self.tc = tc |
1548 | + self.app = None |
1549 | + self.window = None |
1550 | + |
1551 | + self.keyboard = Keyboard.create() |
1552 | + if model() == 'Desktop': |
1553 | + input_device = Mouse.create() |
1554 | + else: |
1555 | + input_device = Touch.create() |
1556 | + self.pointer = Pointer(input_device) |
1557 | |
1558 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/browser.py' |
1559 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/browser.py 1970-01-01 00:00:00 +0000 |
1560 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/browser.py 2013-09-05 19:05:51 +0000 |
1561 | @@ -0,0 +1,103 @@ |
1562 | +"""Browser application to write autopilot test cases easily.""" |
1563 | + |
1564 | +from testtools.matchers import Contains, Equals |
1565 | + |
1566 | +from ubuntuuitoolkit.emulators import UbuntuUIToolkitEmulatorBase |
1567 | +from webbrowser_app.emulators.browser import Browser |
1568 | + |
1569 | +from ubuntu_test_cases.memory_usage_measurement.apps import App |
1570 | +from ubuntu_test_cases.memory_usage_measurement.matchers import ( |
1571 | + DoesNotChange, |
1572 | + Eventually, |
1573 | +) |
1574 | + |
1575 | + |
1576 | +class BrowserApp(App): |
1577 | + |
1578 | + """Browser application.""" |
1579 | + |
1580 | + TYPING_DELAY = 0.01 |
1581 | + |
1582 | + def assert_chrome_eventually_hidden(self): |
1583 | + """Make sure chrome is eventually hidden.""" |
1584 | + |
1585 | + toolbar = self.window.get_toolbar() |
1586 | + self.tc.assertThat(toolbar.opened, Eventually(Equals(False))) |
1587 | + self.tc.assertThat(toolbar.animating, Eventually(Equals(False))) |
1588 | + |
1589 | + def assert_page_eventually_loaded(self, url): |
1590 | + """Make sure page is eventually loaded.""" |
1591 | + webview = self.window.get_current_webview() |
1592 | + self.tc.assertThat(webview.url, Eventually(Equals(url))) |
1593 | + # loadProgress == 100 ensures that a page has actually loaded |
1594 | + self.tc.assertThat(webview.loadProgress, Eventually(Equals(100))) |
1595 | + self.tc.assertThat(webview.loading, Eventually(Equals(False))) |
1596 | + |
1597 | + def clear_address_bar(self): |
1598 | + """Clear address bar.""" |
1599 | + self.focus_address_bar() |
1600 | + clear_button = self.window.get_address_bar_clear_button() |
1601 | + self.tc.assertThat(lambda: (clear_button.x, |
1602 | + clear_button.y, |
1603 | + clear_button.y), |
1604 | + Eventually(DoesNotChange())) |
1605 | + self.pointer.move_to_object(clear_button) |
1606 | + self.pointer.click() |
1607 | + text_field = self.window.get_address_bar_text_field() |
1608 | + self.tc.assertThat(text_field.text, Eventually(Equals(""))) |
1609 | + |
1610 | + def ensure_chrome_is_hidden(self): |
1611 | + """Make sure chrome is hidden.""" |
1612 | + webview = self.window.get_current_webview() |
1613 | + self.pointer.move_to_object(webview) |
1614 | + self.pointer.click() |
1615 | + self.assert_chrome_eventually_hidden() |
1616 | + |
1617 | + def focus_address_bar(self): |
1618 | + """Make sure address bar is focused.""" |
1619 | + address_bar = self.window.get_address_bar() |
1620 | + self.pointer.move_to_object(address_bar) |
1621 | + self.pointer.click() |
1622 | + self.tc.assertThat(address_bar.activeFocus, Eventually(Equals(True))) |
1623 | + |
1624 | + def go_to_url(self, url): |
1625 | + """Go to given url. |
1626 | + |
1627 | + :param url: URL that should be loaded in the browser |
1628 | + :type url: str |
1629 | + |
1630 | + """ |
1631 | + self.ensure_chrome_is_hidden() |
1632 | + self.window.open_toolbar() |
1633 | + self.clear_address_bar() |
1634 | + self.type_in_address_bar(url) |
1635 | + self.keyboard.press_and_release("Enter") |
1636 | + |
1637 | + def launch(self): |
1638 | + """Launch application.""" |
1639 | + args = [ |
1640 | + 'webbrowser-app', |
1641 | + '--fullscreen', |
1642 | + ('--desktop_file_hint=' |
1643 | + '/usr/share/applications/webbrowser-app.desktop'), |
1644 | + ] |
1645 | + self.app = self.tc.launch_test_application( |
1646 | + *args, |
1647 | + app_type='qt', |
1648 | + emulator_base=UbuntuUIToolkitEmulatorBase |
1649 | + ) |
1650 | + self.window = self.app.select_single(Browser) |
1651 | + self.window.visible.wait_for(True) |
1652 | + |
1653 | + def type_in_address_bar(self, text): |
1654 | + """Type text in address bar. |
1655 | + |
1656 | + :param text: Text to be typed in the address bar. |
1657 | + :type text: str |
1658 | + |
1659 | + """ |
1660 | + address_bar = self.window.get_address_bar() |
1661 | + self.tc.assertThat(address_bar.activeFocus, Eventually(Equals(True))) |
1662 | + self.keyboard.type(text, delay=self.TYPING_DELAY) |
1663 | + text_field = self.window.get_address_bar_text_field() |
1664 | + self.tc.assertThat(text_field.text, Eventually(Contains(text))) |
1665 | |
1666 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/camera.py' |
1667 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/camera.py 1970-01-01 00:00:00 +0000 |
1668 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/camera.py 2013-09-05 19:05:51 +0000 |
1669 | @@ -0,0 +1,58 @@ |
1670 | +"""Camera application to write autopilot test cases easily.""" |
1671 | + |
1672 | +import logging |
1673 | +import os |
1674 | + |
1675 | +from glob import glob |
1676 | + |
1677 | +from camera_app.emulators.main_window import MainWindow as CameraWindow |
1678 | +from testtools.matchers import Equals, HasLength |
1679 | + |
1680 | +from ubuntu_test_cases.memory_usage_measurement.apps import App |
1681 | +from ubuntu_test_cases.memory_usage_measurement.matchers import Eventually |
1682 | + |
1683 | +LOGGER = logging.getLogger(__file__) |
1684 | + |
1685 | + |
1686 | +class CameraApp(App): |
1687 | + |
1688 | + """Camera application.""" |
1689 | + |
1690 | + IMAGE_FILENAME_PATTERN = os.path.expanduser('~/Pictures/image*') |
1691 | + |
1692 | + def _remove_image_files(self): |
1693 | + """Remove all image files. |
1694 | + |
1695 | + This is useful not only to cleanup, but also to check that just one |
1696 | + image file has been written to disk. |
1697 | + |
1698 | + """ |
1699 | + for filename in glob(self.IMAGE_FILENAME_PATTERN): |
1700 | + LOGGER.debug('Removing image file: {}'.format(filename)) |
1701 | + os.remove(filename) |
1702 | + |
1703 | + def launch(self): |
1704 | + """Launch application.""" |
1705 | + args = [ |
1706 | + 'camera-app', |
1707 | + '--fullscreen', |
1708 | + ('--desktop_file_hint=' |
1709 | + '/usr/share/applications/camera-app.desktop'), |
1710 | + ] |
1711 | + self.app = self.tc.launch_test_application(*args, app_type='qt') |
1712 | + self.window = CameraWindow(self.app) |
1713 | + |
1714 | + def take_picture(self): |
1715 | + """Click on the exposure button to take picture.""" |
1716 | + self._remove_image_files() |
1717 | + |
1718 | + exposure_button = self.window.get_exposure_button() |
1719 | + self.tc.assertThat(exposure_button.enabled, Eventually(Equals(True))) |
1720 | + |
1721 | + LOGGER.debug('Taking picture...') |
1722 | + self.pointer.move_to_object(exposure_button) |
1723 | + self.pointer.click() |
1724 | + |
1725 | + # Wait for image file to be produced before memory usage measurement |
1726 | + self.tc.assertThat(lambda: glob(self.IMAGE_FILENAME_PATTERN), |
1727 | + Eventually(HasLength(1))) |
1728 | |
1729 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/gallery.py' |
1730 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/gallery.py 1970-01-01 00:00:00 +0000 |
1731 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/gallery.py 2013-09-05 19:05:51 +0000 |
1732 | @@ -0,0 +1,41 @@ |
1733 | +"""Gallery application to write autopilot test cases easily.""" |
1734 | + |
1735 | +import os |
1736 | +import shutil |
1737 | +import tempfile |
1738 | + |
1739 | +from ubuntu_test_cases.memory_usage_measurement.apps import App |
1740 | + |
1741 | + |
1742 | +class GalleryApp(App): |
1743 | + |
1744 | + """Gallery application.""" |
1745 | + |
1746 | + SAMPLE_DIR = '/usr/lib/python2.7/dist-packages/gallery_app/data/default' |
1747 | + |
1748 | + def __init__(self, tc): |
1749 | + super(GalleryApp, self).__init__(tc) |
1750 | + self.temp_sample_dir = None |
1751 | + self._copy_sample_dir() |
1752 | + |
1753 | + def _copy_sample_dir(self): |
1754 | + """Copy sample directory to a temporary location. |
1755 | + |
1756 | + This is useful to provide some default content. |
1757 | + |
1758 | + """ |
1759 | + self.temp_sample_dir = tempfile.mkdtemp(prefix='gallery-app-test-') |
1760 | + self.tc.addCleanup(shutil.rmtree, self.temp_sample_dir) |
1761 | + self.temp_sample_dir = os.path.join(self.temp_sample_dir, 'data') |
1762 | + shutil.copytree(self.SAMPLE_DIR, self.temp_sample_dir) |
1763 | + |
1764 | + def launch(self): |
1765 | + """Launch the application.""" |
1766 | + args = [ |
1767 | + 'gallery-app', |
1768 | + ('--desktop_file_hint=' |
1769 | + '/usr/share/applications/gallery-app.desktop'), |
1770 | + self.temp_sample_dir, |
1771 | + ] |
1772 | + self.app = self.tc.launch_test_application(*args, |
1773 | + app_type='qt') |
1774 | |
1775 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/media_player.py' |
1776 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/media_player.py 1970-01-01 00:00:00 +0000 |
1777 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/media_player.py 2013-09-05 19:05:51 +0000 |
1778 | @@ -0,0 +1,53 @@ |
1779 | +"""Media player application to write autopilot test cases easily.""" |
1780 | + |
1781 | +import os |
1782 | + |
1783 | +from testtools.matchers import Equals, GreaterThan |
1784 | + |
1785 | +from mediaplayer_app.emulators.main_window import ( |
1786 | + MainWindow as MediaPlayerWindow) |
1787 | + |
1788 | +from ubuntu_test_cases.memory_usage_measurement.apps import App |
1789 | +from ubuntu_test_cases.memory_usage_measurement.matchers import Eventually |
1790 | + |
1791 | + |
1792 | +class MediaPlayerApp(App): |
1793 | + |
1794 | + """Media player application.""" |
1795 | + |
1796 | + # Default content |
1797 | + VIDEOS_DIR = 'file:///usr/share/mediaplayer-app/videos/' |
1798 | + |
1799 | + def assert_playback_finished(self): |
1800 | + """Media player memory usage after playing a file.""" |
1801 | + time_line = self.window.get_object("Slider", "TimeLine.Slider") |
1802 | + |
1803 | + # Time line value isn't set to maximum value after playback is finished |
1804 | + # (LP: #1190555) |
1805 | + maximum_value = time_line.maximumValue - 2.0 |
1806 | + self.tc.assertThat(time_line.value, |
1807 | + Eventually(GreaterThan(maximum_value))) |
1808 | + |
1809 | + def launch(self, movie_file=None): |
1810 | + """Launch application. |
1811 | + |
1812 | + :param movie_file: |
1813 | + Relative path to movie file (uses default content directory as |
1814 | + root). |
1815 | + :type movie_file: str |
1816 | + |
1817 | + """ |
1818 | + binary = 'mediaplayer-app' |
1819 | + args = [ |
1820 | + binary, |
1821 | + '--fullscreen', |
1822 | + ('--desktop_file_hint=' |
1823 | + '/usr/share/applications/mediaplayer-app.desktop'), |
1824 | + ] |
1825 | + if movie_file: |
1826 | + args.insert(1, os.path.join(self.VIDEOS_DIR, movie_file)) |
1827 | + |
1828 | + self.app = self.tc.launch_test_application(*args, app_type='qt') |
1829 | + self.window = MediaPlayerWindow(self.app) |
1830 | + self.tc.assertThat(self.window.get_qml_view().visible, |
1831 | + Eventually(Equals(True))) |
1832 | |
1833 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/matchers.py' |
1834 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/matchers.py 1970-01-01 00:00:00 +0000 |
1835 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/matchers.py 2013-09-05 19:05:51 +0000 |
1836 | @@ -0,0 +1,37 @@ |
1837 | +"""Custom matchers used by the tests.""" |
1838 | + |
1839 | +from autopilot.matchers import Eventually as EventuallyMatcher |
1840 | +from testtools.matchers import Mismatch |
1841 | + |
1842 | + |
1843 | +def Eventually(matcher): |
1844 | + """Wrapper around autopilot.matchers.Eventually. |
1845 | + |
1846 | + The aim of the wrapper is just use a different timeout default |
1847 | + |
1848 | + :param matcher: A testools-like matcher that tests the desired condition |
1849 | + :type matcher: object |
1850 | + :returns: A value depending on the matcher protocol |
1851 | + :rtype: None | a mismatch object with information about the mismatch |
1852 | + |
1853 | + """ |
1854 | + return EventuallyMatcher(matcher, timeout=40) |
1855 | + |
1856 | + |
1857 | +class DoesNotChange(object): |
1858 | + """Match if two consecutive values are equal.""" |
1859 | + def __init__(self): |
1860 | + self.old_value = None |
1861 | + self.value = None |
1862 | + |
1863 | + def __str__(self): |
1864 | + return 'DoesNotChange()' |
1865 | + |
1866 | + def match(self, value): |
1867 | + self.old_value = self.value |
1868 | + self.value = value |
1869 | + if self.value != self.old_value: |
1870 | + return Mismatch('Current value ({}) does not match old value ({})' |
1871 | + .format(self.value, self.old_value)) |
1872 | + |
1873 | + return None |
1874 | |
1875 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/probes.py' |
1876 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/probes.py 1970-01-01 00:00:00 +0000 |
1877 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/probes.py 2013-09-05 19:05:51 +0000 |
1878 | @@ -0,0 +1,170 @@ |
1879 | +"""Probes used to take measurements4 while the tests are executed.""" |
1880 | + |
1881 | +import itertools |
1882 | +import logging |
1883 | +import os |
1884 | +import re |
1885 | +import subprocess |
1886 | + |
1887 | +from contextlib import contextmanager |
1888 | +from time import time |
1889 | + |
1890 | +LOGGER = logging.getLogger(__file__) |
1891 | + |
1892 | + |
1893 | +class SmemProbe(object): |
1894 | + |
1895 | + """Memory usage probe.""" |
1896 | + |
1897 | + BINARY = os.path.join(os.path.dirname(__file__), 'smem-tabs') |
1898 | + THRESHOLDS = { |
1899 | + 'foreground': 262144, # 256MB |
1900 | + 'background': 131072, # 128MB |
1901 | + } |
1902 | + |
1903 | + def __init__(self): |
1904 | + self.pids = [] # List of pids that should be monitored |
1905 | + self.readings = [] # List of readings |
1906 | + self.current_reading = None |
1907 | + self.threshold_exceeded_summary = [] |
1908 | + |
1909 | + @contextmanager |
1910 | + def probe(self, event): |
1911 | + """Run start and stop methods in a contex manager.""" |
1912 | + self.start(event) |
1913 | + yield |
1914 | + self.stop(event) |
1915 | + |
1916 | + def start(self, event): |
1917 | + """Start measurement. |
1918 | + |
1919 | + This method is not actually used, but defined to be consistent with the |
1920 | + probes API. |
1921 | + |
1922 | + :param event: Event name |
1923 | + :type event: str |
1924 | + :returns: None |
1925 | + |
1926 | + """ |
1927 | + LOGGER.debug('smem start: {}'.format(event)) |
1928 | + self.current_reading = { |
1929 | + 'event': event, |
1930 | + 'start_time': time(), |
1931 | + } |
1932 | + |
1933 | + def stop(self, event): |
1934 | + """Stop measurement. |
1935 | + |
1936 | + Run smem and get memory usage for a given set PIDs. |
1937 | + |
1938 | + :param event: Event name |
1939 | + :type event: str |
1940 | + :returns: None |
1941 | + |
1942 | + """ |
1943 | + LOGGER.debug('smem stop: {}'.format(event)) |
1944 | + LOGGER.debug('Running {!r}...'.format(self.BINARY)) |
1945 | + output = subprocess.check_output(self.BINARY) |
1946 | + parser = SmemParser() |
1947 | + pids_info = parser.parse(output) |
1948 | + threshold_exceeded_pids = self._calculate_threshold_exceeded(pids_info) |
1949 | + print '{:-^72}'.format(event) |
1950 | + for pid in self.pids: |
1951 | + print('PID: {pid}, command: {command}, PSS: {pss}, USS: {uss}' |
1952 | + .format(**pids_info[pid])) |
1953 | + |
1954 | + self.current_reading['stop_time'] = time() |
1955 | + self.current_reading['data'] = pids_info |
1956 | + self.readings.append(self.current_reading) |
1957 | + if threshold_exceeded_pids: |
1958 | + self.threshold_exceeded_summary.append( |
1959 | + (event, threshold_exceeded_pids)) |
1960 | + self.current_reading = None |
1961 | + |
1962 | + def _calculate_threshold_exceeded(self, pids_info): |
1963 | + """Calculate thresholds for the given set of pids. |
1964 | + |
1965 | + :param pids_info: |
1966 | + Memory usage data for a give set of pids. |
1967 | + |
1968 | + ..note:: |
1969 | + This parameter is modified in place to add a delta of the PSS |
1970 | + and the threshold. |
1971 | + :type pids_info: list(dict) |
1972 | + |
1973 | + """ |
1974 | + # It's assumed that the pid for the foreground application is the one |
1975 | + # that was last added to the probe |
1976 | + foreground_pid = self.pids[-1] |
1977 | + foreground_threshold = self.THRESHOLDS['foreground'] |
1978 | + background_pids = self.pids[:-1] |
1979 | + background_threshold = self.THRESHOLDS['background'] |
1980 | + |
1981 | + pids_and_thresholds = itertools.chain( |
1982 | + [(foreground_pid, foreground_threshold)], |
1983 | + itertools.product(background_pids, [background_threshold])) |
1984 | + |
1985 | + threshold_exceeded_pids = [] |
1986 | + for pid, threshold in pids_and_thresholds: |
1987 | + if pid in pids_info: |
1988 | + pid_info = pids_info[pid] |
1989 | + delta = pid_info['pss'] - threshold |
1990 | + pid_info['threshold_exceeded'] = delta |
1991 | + if delta > 0: |
1992 | + threshold_exceeded_pids.append(pid) |
1993 | + return threshold_exceeded_pids |
1994 | + |
1995 | + @property |
1996 | + def report(self): |
1997 | + """Return report with all the readings that have been made.""" |
1998 | + return {'pids': self.pids, |
1999 | + 'thresholds': self.THRESHOLDS, |
2000 | + 'readings': self.readings} |
2001 | + |
2002 | + |
2003 | +class SmemParser(object): |
2004 | + |
2005 | + """Parser object to map smem output to data structure.""" |
2006 | + |
2007 | + SMEM_LINE = re.compile( |
2008 | + r'\s*(?P<pid>\d+)' |
2009 | + r'\s+(?P<user>\w+)' |
2010 | + r'\s+(?P<command>.+?)' |
2011 | + r'\s+(?P<swap>\d+)' |
2012 | + r'\s+(?P<uss>\d+)' |
2013 | + r'\s+(?P<pss>\d+)' |
2014 | + r'\s+(?P<rss>\d+)') |
2015 | + |
2016 | + def parse(self, output): |
2017 | + """Parse smem output. |
2018 | + |
2019 | + :param output: The report printed to stdout by smem |
2020 | + :type output: str |
2021 | + :returns: Data structure that can be serialized |
2022 | + :rtype: dict(dict) |
2023 | + |
2024 | + """ |
2025 | + pids_info = filter(None, |
2026 | + [self._parse_line(line) |
2027 | + for line in output.splitlines()[1:]]) |
2028 | + return {pid_info['pid']: pid_info for pid_info in pids_info} |
2029 | + |
2030 | + def _parse_line(self, line): |
2031 | + """Parse a single smem output line. |
2032 | + |
2033 | + :param line: |
2034 | + A single line containing all the fields to parse for a process. |
2035 | + :type line: str |
2036 | + :returns: Data structure with the parsed fields |
2037 | + :rtype: dict |
2038 | + |
2039 | + """ |
2040 | + match = self.SMEM_LINE.match(line) |
2041 | + if not match: |
2042 | + LOGGER.warning('Unable to parse smem output: {}'.format(line)) |
2043 | + return None |
2044 | + |
2045 | + pid_info = match.groupdict() |
2046 | + for key in ('pid', 'swap', 'uss', 'pss', 'rss'): |
2047 | + pid_info[key] = int(pid_info[key]) |
2048 | + return pid_info |
2049 | |
2050 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/smem-tabs' |
2051 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/smem-tabs 1970-01-01 00:00:00 +0000 |
2052 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/smem-tabs 2013-09-05 19:05:51 +0000 |
2053 | @@ -0,0 +1,687 @@ |
2054 | +#!/usr/bin/env python |
2055 | +# |
2056 | +# smem - a tool for meaningful memory reporting |
2057 | +# |
2058 | +# Copyright 2008-2009 Matt Mackall <mpm@selenic.com> |
2059 | +# |
2060 | +# This software may be used and distributed according to the terms of |
2061 | +# the GNU General Public License version 2 or later, incorporated |
2062 | +# herein by reference. |
2063 | + |
2064 | +import re, os, sys, pwd, optparse, errno, tarfile |
2065 | + |
2066 | +warned = False |
2067 | + |
2068 | +class procdata(object): |
2069 | + def __init__(self, source): |
2070 | + self._ucache = {} |
2071 | + self._gcache = {} |
2072 | + self.source = source and source or "" |
2073 | + self._memdata = None |
2074 | + def _list(self): |
2075 | + return os.listdir(self.source + "/proc") |
2076 | + def _read(self, f): |
2077 | + return file(self.source + '/proc/' + f).read() |
2078 | + def _readlines(self, f): |
2079 | + return self._read(f).splitlines(True) |
2080 | + def _stat(self, f): |
2081 | + return os.stat(self.source + "/proc/" + f) |
2082 | + |
2083 | + def pids(self): |
2084 | + '''get a list of processes''' |
2085 | + return [int(e) for e in self._list() |
2086 | + if e.isdigit() and not iskernel(e)] |
2087 | + def mapdata(self, pid): |
2088 | + return self._readlines('%s/smaps' % pid) |
2089 | + def memdata(self): |
2090 | + if self._memdata is None: |
2091 | + self._memdata = self._readlines('meminfo') |
2092 | + return self._memdata |
2093 | + def version(self): |
2094 | + return self._readlines('version')[0] |
2095 | + def pidname(self, pid): |
2096 | + try: |
2097 | + l = self.pidcmd(pid).split(' ')[0] |
2098 | + return os.path.basename(l) |
2099 | + except: |
2100 | + return '?' |
2101 | + def pidcmd(self, pid): |
2102 | + try: |
2103 | + c = self._read('%s/cmdline' % pid)[:-1] |
2104 | + return c.replace('\0', ' ') |
2105 | + except: |
2106 | + return '?' |
2107 | + def piduser(self, pid): |
2108 | + try: |
2109 | + return self._stat('%d' % pid).st_uid |
2110 | + except: |
2111 | + return -1 |
2112 | + def pidgroup(self, pid): |
2113 | + try: |
2114 | + return self._stat('%d' % pid).st_gid |
2115 | + except: |
2116 | + return -1 |
2117 | + def username(self, uid): |
2118 | + if uid == -1: |
2119 | + return '?' |
2120 | + if uid not in self._ucache: |
2121 | + try: |
2122 | + self._ucache[uid] = pwd.getpwuid(uid)[0] |
2123 | + except KeyError: |
2124 | + self._ucache[uid] = str(uid) |
2125 | + return self._ucache[uid] |
2126 | + def groupname(self, gid): |
2127 | + if gid == -1: |
2128 | + return '?' |
2129 | + if gid not in self._gcache: |
2130 | + try: |
2131 | + self._gcache[gid] = pwd.getgrgid(gid)[0] |
2132 | + except KeyError: |
2133 | + self._gcache[gid] = str(gid) |
2134 | + return self._gcache[gid] |
2135 | + |
2136 | +class tardata(procdata): |
2137 | + def __init__(self, source): |
2138 | + procdata.__init__(self, source) |
2139 | + self.tar = tarfile.open(source) |
2140 | + def _list(self): |
2141 | + for ti in self.tar: |
2142 | + if ti.name.endswith('/smaps'): |
2143 | + d,f = ti.name.split('/') |
2144 | + yield d |
2145 | + def _read(self, f): |
2146 | + return self.tar.extractfile(f).read() |
2147 | + def _readlines(self, f): |
2148 | + return self.tar.extractfile(f).readlines() |
2149 | + def piduser(self, p): |
2150 | + t = self.tar.getmember("%d" % p) |
2151 | + if t.uname: |
2152 | + self._ucache[t.uid] = t.uname |
2153 | + return t.uid |
2154 | + def pidgroup(self, p): |
2155 | + t = self.tar.getmember("%d" % p) |
2156 | + if t.gname: |
2157 | + self._gcache[t.gid] = t.gname |
2158 | + return t.gid |
2159 | + def username(self, u): |
2160 | + return self._ucache.get(u, str(u)) |
2161 | + def groupname(self, g): |
2162 | + return self._gcache.get(g, str(g)) |
2163 | + |
2164 | +_totalmem = 0 |
2165 | +def totalmem(): |
2166 | + global _totalmem |
2167 | + if not _totalmem: |
2168 | + if options.realmem: |
2169 | + _totalmem = fromunits(options.realmem) / 1024 |
2170 | + else: |
2171 | + _totalmem = memory()['memtotal'] |
2172 | + return _totalmem |
2173 | + |
2174 | +_kernelsize = 0 |
2175 | +def kernelsize(): |
2176 | + global _kernelsize |
2177 | + if not _kernelsize and options.kernel: |
2178 | + try: |
2179 | + d = os.popen("size %s" % options.kernel).readlines()[1] |
2180 | + _kernelsize = int(d.split()[3]) / 1024 |
2181 | + except: |
2182 | + try: |
2183 | + # try some heuristic to find gzipped part in kernel image |
2184 | + packedkernel = open(options.kernel).read() |
2185 | + pos = packedkernel.find('\x1F\x8B') |
2186 | + if pos >= 0 and pos < 25000: |
2187 | + sys.stderr.write("Maybe uncompressed kernel can be extracted by the command:\n" |
2188 | + " dd if=%s bs=1 skip=%d | gzip -d >%s.unpacked\n\n" % (options.kernel, pos, options.kernel)) |
2189 | + except: |
2190 | + pass |
2191 | + sys.stderr.write("Parameter '%s' should be an original uncompressed compiled kernel file.\n\n" % options.kernel) |
2192 | + return _kernelsize |
2193 | + |
2194 | +def pidmaps(pid): |
2195 | + global warned |
2196 | + maps = {} |
2197 | + start = None |
2198 | + seen = False |
2199 | + for l in src.mapdata(pid): |
2200 | + f = l.split() |
2201 | + if f[-1] == 'kB': |
2202 | + if f[0].startswith('Pss'): |
2203 | + seen = True |
2204 | + maps[start][f[0][:-1].lower()] = int(f[1]) |
2205 | + elif f[0] == 'VmFlags:': |
2206 | + continue |
2207 | + else: |
2208 | + start, end = f[0].split('-') |
2209 | + start = int(start, 16) |
2210 | + name = "<anonymous>" |
2211 | + if len(f) > 5: |
2212 | + name = f[5] |
2213 | + maps[start] = dict(end=int(end, 16), mode=f[1], |
2214 | + offset=int(f[2], 16), |
2215 | + device=f[3], inode=f[4], name=name) |
2216 | + |
2217 | + if not seen and not warned: |
2218 | + sys.stderr.write('warning: kernel does not appear to support PSS measurement\n') |
2219 | + warned = True |
2220 | + if not options.sort: |
2221 | + options.sort = 'rss' |
2222 | + |
2223 | + if options.mapfilter: |
2224 | + f = {} |
2225 | + for m in maps: |
2226 | + if not filter(options.mapfilter, m, lambda x: maps[x]['name']): |
2227 | + f[m] = maps[m] |
2228 | + return f |
2229 | + |
2230 | + return maps |
2231 | + |
2232 | +def sortmaps(totals, key): |
2233 | + l = [] |
2234 | + for pid in totals: |
2235 | + l.append((totals[pid][key], pid)) |
2236 | + l.sort() |
2237 | + return [pid for pid,key in l] |
2238 | + |
2239 | +def iskernel(pid): |
2240 | + return src.pidcmd(pid) == "" |
2241 | + |
2242 | +def memory(): |
2243 | + t = {} |
2244 | + f = re.compile('(\\S+):\\s+(\\d+) kB') |
2245 | + for l in src.memdata(): |
2246 | + m = f.match(l) |
2247 | + if m: |
2248 | + t[m.group(1).lower()] = int(m.group(2)) |
2249 | + return t |
2250 | + |
2251 | +def units(x): |
2252 | + s = '' |
2253 | + if x == 0: |
2254 | + return '0' |
2255 | + for s in ('', 'K', 'M', 'G', 'T'): |
2256 | + if x < 1024: |
2257 | + break |
2258 | + x /= 1024.0 |
2259 | + return "%.1f%s" % (x, s) |
2260 | + |
2261 | +def fromunits(x): |
2262 | + s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, |
2263 | + M=2**20, MB=2**20, G=2**30, GB=2**30, |
2264 | + T=2**40, TB=2**40) |
2265 | + for k,v in s.items(): |
2266 | + if x.endswith(k): |
2267 | + return int(float(x[:-len(k)])*v) |
2268 | + sys.stderr.write("Memory size should be written with units, for example 1024M\n") |
2269 | + sys.exit(-1) |
2270 | + |
2271 | +def pidusername(pid): |
2272 | + return src.username(src.piduser(pid)) |
2273 | + |
2274 | +def showamount(a, total): |
2275 | + if options.abbreviate: |
2276 | + return units(a * 1024) |
2277 | + elif options.percent: |
2278 | + return "%.2f%%" % (100.0 * a / total) |
2279 | + return a |
2280 | + |
2281 | +def filter(opt, arg, *sources): |
2282 | + if not opt: |
2283 | + return False |
2284 | + |
2285 | + for f in sources: |
2286 | + if re.search(opt, f(arg)): |
2287 | + return False |
2288 | + return True |
2289 | + |
2290 | +def pidtotals(pid): |
2291 | + maps = pidmaps(pid) |
2292 | + t = dict(size=0, rss=0, pss=0, shared_clean=0, shared_dirty=0, |
2293 | + private_clean=0, private_dirty=0, referenced=0, swap=0) |
2294 | + for m in maps.iterkeys(): |
2295 | + for k in t: |
2296 | + t[k] += maps[m].get(k, 0) |
2297 | + |
2298 | + t['uss'] = t['private_clean'] + t['private_dirty'] |
2299 | + t['maps'] = len(maps) |
2300 | + |
2301 | + return t |
2302 | + |
2303 | +def processtotals(pids): |
2304 | + totals = {} |
2305 | + for pid in pids: |
2306 | + if (filter(options.processfilter, pid, src.pidname, src.pidcmd) or |
2307 | + filter(options.userfilter, pid, pidusername)): |
2308 | + continue |
2309 | + try: |
2310 | + p = pidtotals(pid) |
2311 | + if p['maps'] != 0: |
2312 | + totals[pid] = p |
2313 | + except: |
2314 | + continue |
2315 | + return totals |
2316 | + |
2317 | +def showpids(): |
2318 | + p = src.pids() |
2319 | + pt = processtotals(p) |
2320 | + |
2321 | + def showuser(p): |
2322 | + if options.numeric: |
2323 | + return src.piduser(p) |
2324 | + return pidusername(p) |
2325 | + |
2326 | + fields = dict( |
2327 | + pid=('PID', lambda n: n, '% 5s', lambda x: len(pt), |
2328 | + 'process ID'), |
2329 | + user=('User', showuser, '%-8s', lambda x: len(dict.fromkeys(x)), |
2330 | + 'owner of process'), |
2331 | + name=('Name', src.pidname, '%s', None, |
2332 | + 'name of process'), |
2333 | + command=('Command', src.pidcmd, '%s', None, |
2334 | + 'process command line'), |
2335 | + maps=('Maps',lambda n: pt[n]['maps'], '% 5s', sum, |
2336 | + 'total number of mappings'), |
2337 | + swap=('Swap',lambda n: pt[n]['swap'], '% 8a', sum, |
2338 | + 'amount of swap space consumed (ignoring sharing)'), |
2339 | + uss=('USS', lambda n: pt[n]['uss'], '%a', sum, |
2340 | + 'unique set size'), |
2341 | + rss=('RSS', lambda n: pt[n]['rss'], '%a', sum, |
2342 | + 'resident set size (ignoring sharing)'), |
2343 | + pss=('PSS', lambda n: pt[n]['pss'], '%a', sum, |
2344 | + 'proportional set size (including sharing)'), |
2345 | + vss=('VSS', lambda n: pt[n]['size'], '%a', sum, |
2346 | + 'virtual set size (total virtual memory mapped)'), |
2347 | + ) |
2348 | + columns = options.columns or 'pid user command swap uss pss rss' |
2349 | + |
2350 | + showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') |
2351 | + |
2352 | +def maptotals(pids): |
2353 | + totals = {} |
2354 | + for pid in pids: |
2355 | + if (filter(options.processfilter, pid, src.pidname, src.pidcmd) or |
2356 | + filter(options.userfilter, pid, pidusername)): |
2357 | + continue |
2358 | + try: |
2359 | + maps = pidmaps(pid) |
2360 | + seen = {} |
2361 | + for m in maps.iterkeys(): |
2362 | + name = maps[m]['name'] |
2363 | + if name not in totals: |
2364 | + t = dict(size=0, rss=0, pss=0, shared_clean=0, |
2365 | + shared_dirty=0, private_clean=0, count=0, |
2366 | + private_dirty=0, referenced=0, swap=0, pids=0) |
2367 | + else: |
2368 | + t = totals[name] |
2369 | + |
2370 | + for k in t: |
2371 | + t[k] += maps[m].get(k, 0) |
2372 | + t['count'] += 1 |
2373 | + if name not in seen: |
2374 | + t['pids'] += 1 |
2375 | + seen[name] = 1 |
2376 | + totals[name] = t |
2377 | + except EnvironmentError: |
2378 | + continue |
2379 | + return totals |
2380 | + |
2381 | +def showmaps(): |
2382 | + p = src.pids() |
2383 | + pt = maptotals(p) |
2384 | + |
2385 | + fields = dict( |
2386 | + map=('Map', lambda n: n, '%-40.40s', len, |
2387 | + 'mapping name'), |
2388 | + count=('Count', lambda n: pt[n]['count'], '% 5s', sum, |
2389 | + 'number of mappings found'), |
2390 | + pids=('PIDs', lambda n: pt[n]['pids'], '% 5s', sum, |
2391 | + 'number of PIDs using mapping'), |
2392 | + swap=('Swap',lambda n: pt[n]['swap'], '% 8a', sum, |
2393 | + 'amount of swap space consumed (ignoring sharing)'), |
2394 | + uss=('USS', lambda n: pt[n]['private_clean'] |
2395 | + + pt[n]['private_dirty'], '% 8a', sum, |
2396 | + 'unique set size'), |
2397 | + rss=('RSS', lambda n: pt[n]['rss'], '% 8a', sum, |
2398 | + 'resident set size (ignoring sharing)'), |
2399 | + pss=('PSS', lambda n: pt[n]['pss'], '% 8a', sum, |
2400 | + 'proportional set size (including sharing)'), |
2401 | + vss=('VSS', lambda n: pt[n]['size'], '% 8a', sum, |
2402 | + 'virtual set size (total virtual address space mapped)'), |
2403 | + avgpss=('AVGPSS', lambda n: int(1.0 * pt[n]['pss']/pt[n]['pids']), |
2404 | + '% 8a', sum, |
2405 | + 'average PSS per PID'), |
2406 | + avguss=('AVGUSS', lambda n: int(1.0 * pt[n]['uss']/pt[n]['pids']), |
2407 | + '% 8a', sum, |
2408 | + 'average USS per PID'), |
2409 | + avgrss=('AVGRSS', lambda n: int(1.0 * pt[n]['rss']/pt[n]['pids']), |
2410 | + '% 8a', sum, |
2411 | + 'average RSS per PID'), |
2412 | + ) |
2413 | + columns = options.columns or 'map pids avgpss pss' |
2414 | + |
2415 | + showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') |
2416 | + |
2417 | +def usertotals(pids): |
2418 | + totals = {} |
2419 | + for pid in pids: |
2420 | + if (filter(options.processfilter, pid, src.pidname, src.pidcmd) or |
2421 | + filter(options.userfilter, pid, pidusername)): |
2422 | + continue |
2423 | + try: |
2424 | + maps = pidmaps(pid) |
2425 | + if len(maps) == 0: |
2426 | + continue |
2427 | + except EnvironmentError: |
2428 | + continue |
2429 | + user = src.piduser(pid) |
2430 | + if user not in totals: |
2431 | + t = dict(size=0, rss=0, pss=0, shared_clean=0, |
2432 | + shared_dirty=0, private_clean=0, count=0, |
2433 | + private_dirty=0, referenced=0, swap=0) |
2434 | + else: |
2435 | + t = totals[user] |
2436 | + |
2437 | + for m in maps.iterkeys(): |
2438 | + for k in t: |
2439 | + t[k] += maps[m].get(k, 0) |
2440 | + |
2441 | + t['count'] += 1 |
2442 | + totals[user] = t |
2443 | + return totals |
2444 | + |
2445 | +def showusers(): |
2446 | + p = src.pids() |
2447 | + pt = usertotals(p) |
2448 | + |
2449 | + def showuser(u): |
2450 | + if options.numeric: |
2451 | + return u |
2452 | + return src.username(u) |
2453 | + |
2454 | + fields = dict( |
2455 | + user=('User', showuser, '%-8s', None, |
2456 | + 'user name or ID'), |
2457 | + count=('Count', lambda n: pt[n]['count'], '% 5s', sum, |
2458 | + 'number of processes'), |
2459 | + swap=('Swap',lambda n: pt[n]['swap'], '% 8a', sum, |
2460 | + 'amount of swapspace consumed (ignoring sharing)'), |
2461 | + uss=('USS', lambda n: pt[n]['private_clean'] |
2462 | + + pt[n]['private_dirty'], '% 8a', sum, |
2463 | + 'unique set size'), |
2464 | + rss=('RSS', lambda n: pt[n]['rss'], '% 8a', sum, |
2465 | + 'resident set size (ignoring sharing)'), |
2466 | + pss=('PSS', lambda n: pt[n]['pss'], '% 8a', sum, |
2467 | + 'proportional set size (including sharing)'), |
2468 | + vss=('VSS', lambda n: pt[n]['pss'], '% 8a', sum, |
2469 | + 'virtual set size (total virtual memory mapped)'), |
2470 | + ) |
2471 | + columns = options.columns or 'user count swap uss pss rss' |
2472 | + |
2473 | + showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') |
2474 | + |
2475 | +def showsystem(): |
2476 | + t = totalmem() |
2477 | + ki = kernelsize() |
2478 | + m = memory() |
2479 | + |
2480 | + mt = m['memtotal'] |
2481 | + f = m['memfree'] |
2482 | + |
2483 | + # total amount used by hardware |
2484 | + fh = max(t - mt - ki, 0) |
2485 | + |
2486 | + # total amount mapped into userspace (ie mapped an unmapped pages) |
2487 | + u = m['anonpages'] + m['mapped'] |
2488 | + |
2489 | + # total amount allocated by kernel not for userspace |
2490 | + kd = mt - f - u |
2491 | + |
2492 | + # total amount in kernel caches |
2493 | + kdc = m['buffers'] + m['sreclaimable'] + (m['cached'] - m['mapped']) |
2494 | + |
2495 | + l = [("firmware/hardware", fh, 0), |
2496 | + ("kernel image", ki, 0), |
2497 | + ("kernel dynamic memory", kd, kdc), |
2498 | + ("userspace memory", u, m['mapped']), |
2499 | + ("free memory", f, f)] |
2500 | + |
2501 | + fields = dict( |
2502 | + order=('Order', lambda n: n, '% 1s', lambda x: '', |
2503 | + 'hierarchical order'), |
2504 | + area=('Area', lambda n: l[n][0], '%-24s', lambda x: '', |
2505 | + 'memory area'), |
2506 | + used=('Used', lambda n: l[n][1], '%10a', sum, |
2507 | + 'area in use'), |
2508 | + cache=('Cache', lambda n: l[n][2], '%10a', sum, |
2509 | + 'area used as reclaimable cache'), |
2510 | + noncache=('Noncache', lambda n: l[n][1] - l[n][2], '%10a', sum, |
2511 | + 'area not reclaimable')) |
2512 | + |
2513 | + columns = options.columns or 'area used cache noncache' |
2514 | + showtable(range(len(l)), fields, columns.split(), options.sort or 'order') |
2515 | + |
2516 | +def showfields(fields, f): |
2517 | + if f != list: |
2518 | + print "unknown field", f |
2519 | + print "known fields:" |
2520 | + for l in sorted(fields.keys()): |
2521 | + print "%-8s %s" % (l, fields[l][-1]) |
2522 | + |
2523 | +def showtable(rows, fields, columns, sort): |
2524 | + header = "" |
2525 | + format = "" |
2526 | + formatter = [] |
2527 | + |
2528 | + if sort not in fields: |
2529 | + showfields(fields, sort) |
2530 | + sys.exit(-1) |
2531 | + |
2532 | + if options.pie: |
2533 | + columns.append(options.pie) |
2534 | + if options.bar: |
2535 | + columns.append(options.bar) |
2536 | + |
2537 | + mt = totalmem() |
2538 | + st = memory()['swaptotal'] |
2539 | + |
2540 | + for n in columns: |
2541 | + if n not in fields: |
2542 | + showfields(fields, n) |
2543 | + sys.exit(-1) |
2544 | + |
2545 | + f = fields[n][2] |
2546 | + if 'a' in f: |
2547 | + if n == 'swap': |
2548 | + formatter.append(lambda x: showamount(x, st)) |
2549 | + else: |
2550 | + formatter.append(lambda x: showamount(x, mt)) |
2551 | + f = f.replace('a', 's') |
2552 | + else: |
2553 | + formatter.append(lambda x: x) |
2554 | + format += f + "\t" |
2555 | + header += f % fields[n][0] + "\t" |
2556 | + |
2557 | + l = [] |
2558 | + for n in rows: |
2559 | + r = [fields[c][1](n) for c in columns] |
2560 | + l.append((fields[sort][1](n), r)) |
2561 | + |
2562 | + l.sort(reverse=bool(options.reverse)) |
2563 | + |
2564 | + if options.pie: |
2565 | + showpie(l, sort) |
2566 | + return |
2567 | + elif options.bar: |
2568 | + showbar(l, columns, sort) |
2569 | + return |
2570 | + |
2571 | + if not options.no_header: |
2572 | + print header |
2573 | + |
2574 | + for k,r in l: |
2575 | + print format % tuple([f(v) for f,v in zip(formatter, r)]) |
2576 | + |
2577 | + if options.totals: |
2578 | + # totals |
2579 | + t = [] |
2580 | + for c in columns: |
2581 | + f = fields[c][3] |
2582 | + if f: |
2583 | + t.append(f([fields[c][1](n) for n in rows])) |
2584 | + else: |
2585 | + t.append("") |
2586 | + |
2587 | + print "-" * len(header) |
2588 | + print format % tuple([f(v) for f,v in zip(formatter, t)]) |
2589 | + |
2590 | +def showpie(l, sort): |
2591 | + try: |
2592 | + import pylab |
2593 | + except ImportError: |
2594 | + sys.stderr.write("pie chart requires matplotlib\n") |
2595 | + sys.exit(-1) |
2596 | + |
2597 | + if (l[0][0] < l[-1][0]): |
2598 | + l.reverse() |
2599 | + |
2600 | + labels = [r[1][-1] for r in l] |
2601 | + values = [r[0] for r in l] # sort field |
2602 | + |
2603 | + tm = totalmem() |
2604 | + s = sum(values) |
2605 | + unused = tm - s |
2606 | + t = 0 |
2607 | + while values and (t + values[-1] < (tm * .02) or |
2608 | + values[-1] < (tm * .005)): |
2609 | + t += values.pop() |
2610 | + labels.pop() |
2611 | + |
2612 | + if t: |
2613 | + values.append(t) |
2614 | + labels.append('other') |
2615 | + |
2616 | + explode = [0] * len(values) |
2617 | + if unused > 0: |
2618 | + values.insert(0, unused) |
2619 | + labels.insert(0, 'unused') |
2620 | + explode.insert(0, .05) |
2621 | + |
2622 | + pylab.figure(1, figsize=(6,6)) |
2623 | + ax = pylab.axes([0.1, 0.1, 0.8, 0.8]) |
2624 | + pylab.pie(values, explode = explode, labels=labels, |
2625 | + autopct="%.2f%%", shadow=True) |
2626 | + pylab.title('%s by %s' % (options.pie, sort)) |
2627 | + pylab.show() |
2628 | + |
2629 | +def showbar(l, columns, sort): |
2630 | + try: |
2631 | + import pylab, numpy |
2632 | + except ImportError: |
2633 | + sys.stderr.write("bar chart requires matplotlib\n") |
2634 | + sys.exit(-1) |
2635 | + |
2636 | + if (l[0][0] < l[-1][0]): |
2637 | + l.reverse() |
2638 | + |
2639 | + rc = [] |
2640 | + key = [] |
2641 | + for n in range(len(columns) - 1): |
2642 | + try: |
2643 | + if columns[n] in 'pid user group'.split(): |
2644 | + continue |
2645 | + float(l[0][1][n]) |
2646 | + rc.append(n) |
2647 | + key.append(columns[n]) |
2648 | + except: |
2649 | + pass |
2650 | + |
2651 | + width = 1.0 / (len(rc) + 1) |
2652 | + offset = width / 2 |
2653 | + |
2654 | + def gc(n): |
2655 | + return 'bgrcmyw'[n % 7] |
2656 | + |
2657 | + pl = [] |
2658 | + ind = numpy.arange(len(l)) |
2659 | + for n in xrange(len(rc)): |
2660 | + pl.append(pylab.bar(ind + offset + width * n, |
2661 | + [x[1][rc[n]] for x in l], width, color=gc(n))) |
2662 | + |
2663 | + #plt.xticks(ind + .5, ) |
2664 | + pylab.gca().set_xticks(ind + .5) |
2665 | + pylab.gca().set_xticklabels([x[1][-1] for x in l], rotation=45) |
2666 | + pylab.legend([p[0] for p in pl], key) |
2667 | + pylab.show() |
2668 | + |
2669 | + |
2670 | +parser = optparse.OptionParser("%prog [options]") |
2671 | +parser.add_option("-H", "--no-header", action="store_true", |
2672 | + help="disable header line") |
2673 | +parser.add_option("-c", "--columns", type="str", |
2674 | + help="columns to show") |
2675 | +parser.add_option("-t", "--totals", action="store_true", |
2676 | + help="show totals") |
2677 | + |
2678 | +parser.add_option("-R", "--realmem", type="str", |
2679 | + help="amount of physical RAM") |
2680 | +parser.add_option("-K", "--kernel", type="str", |
2681 | + help="path to kernel image") |
2682 | + |
2683 | +parser.add_option("-m", "--mappings", action="store_true", |
2684 | + help="show mappings") |
2685 | +parser.add_option("-u", "--users", action="store_true", |
2686 | + help="show users") |
2687 | +parser.add_option("-w", "--system", action="store_true", |
2688 | + help="show whole system") |
2689 | + |
2690 | +parser.add_option("-P", "--processfilter", type="str", |
2691 | + help="process filter regex") |
2692 | +parser.add_option("-M", "--mapfilter", type="str", |
2693 | + help="map filter regex") |
2694 | +parser.add_option("-U", "--userfilter", type="str", |
2695 | + help="user filter regex") |
2696 | + |
2697 | +parser.add_option("-n", "--numeric", action="store_true", |
2698 | + help="numeric output") |
2699 | +parser.add_option("-s", "--sort", type="str", |
2700 | + help="field to sort on") |
2701 | +parser.add_option("-r", "--reverse", action="store_true", |
2702 | + help="reverse sort") |
2703 | + |
2704 | +parser.add_option("-p", "--percent", action="store_true", |
2705 | + help="show percentage") |
2706 | +parser.add_option("-k", "--abbreviate", action="store_true", |
2707 | + help="show unit suffixes") |
2708 | + |
2709 | +parser.add_option("", "--pie", type='str', |
2710 | + help="show pie graph") |
2711 | +parser.add_option("", "--bar", type='str', |
2712 | + help="show bar graph") |
2713 | + |
2714 | +parser.add_option("-S", "--source", type="str", |
2715 | + help="/proc data source") |
2716 | + |
2717 | + |
2718 | +defaults = {} |
2719 | +parser.set_defaults(**defaults) |
2720 | +(options, args) = parser.parse_args() |
2721 | + |
2722 | +try: |
2723 | + src = tardata(options.source) |
2724 | +except: |
2725 | + src = procdata(options.source) |
2726 | + |
2727 | +try: |
2728 | + if options.mappings: |
2729 | + showmaps() |
2730 | + elif options.users: |
2731 | + showusers() |
2732 | + elif options.system: |
2733 | + showsystem() |
2734 | + else: |
2735 | + showpids() |
2736 | +except IOError, e: |
2737 | + if e.errno == errno.EPIPE: |
2738 | + pass |
2739 | +except KeyboardInterrupt: |
2740 | + pass |
2741 | |
2742 | === added directory 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests' |
2743 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/__init__.py' |
2744 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/__init__.py 1970-01-01 00:00:00 +0000 |
2745 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/__init__.py 2013-09-05 19:05:51 +0000 |
2746 | @@ -0,0 +1,1 @@ |
2747 | +"""Event based memory usage measurements test cases.""" |
2748 | |
2749 | === added file 'tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/test_memory_usage.py' |
2750 | --- tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/test_memory_usage.py 1970-01-01 00:00:00 +0000 |
2751 | +++ tests/memevent/ubuntu_test_cases/memory_usage_measurement/tests/test_memory_usage.py 2013-09-05 19:05:51 +0000 |
2752 | @@ -0,0 +1,79 @@ |
2753 | +"""Measure touch applications memory usage.""" |
2754 | + |
2755 | +import json |
2756 | +import logging |
2757 | + |
2758 | +from autopilot.testcase import AutopilotTestCase |
2759 | + |
2760 | +from ubuntu_test_cases.memory_usage_measurement.apps.browser import BrowserApp |
2761 | +from ubuntu_test_cases.memory_usage_measurement.apps.camera import CameraApp |
2762 | +from ubuntu_test_cases.memory_usage_measurement.apps.gallery import GalleryApp |
2763 | +from ubuntu_test_cases.memory_usage_measurement.apps.media_player import ( |
2764 | + MediaPlayerApp, |
2765 | +) |
2766 | +from ubuntu_test_cases.memory_usage_measurement.probes import SmemProbe |
2767 | + |
2768 | +LOGGER = logging.getLogger(__file__) |
2769 | + |
2770 | + |
2771 | +class MemoryUsageTests(AutopilotTestCase): |
2772 | + |
2773 | + """Event based memory usage measurement scenario.""" |
2774 | + |
2775 | + def test_scenario(self): |
2776 | + """Scenario that takes measurements on some events.""" |
2777 | + self.smem = SmemProbe() |
2778 | + |
2779 | + # Make sure report is written with the data collected |
2780 | + # even if the test failed to complete |
2781 | + self.addCleanup(self._write_report) |
2782 | + |
2783 | + browser = BrowserApp(self) |
2784 | + with self.smem.probe('Browser started'): |
2785 | + browser.launch() |
2786 | + self.smem.pids.append(browser.app.pid) |
2787 | + |
2788 | + with self.smem.probe('Browser finished loading'): |
2789 | + url = 'http://www.cnn.com/' |
2790 | + browser.go_to_url(url) |
2791 | + browser.assert_page_eventually_loaded(url) |
2792 | + |
2793 | + camera = CameraApp(self) |
2794 | + with self.smem.probe('Camera app started'): |
2795 | + camera.launch() |
2796 | + self.smem.pids.append(camera.app.pid) |
2797 | + |
2798 | + with self.smem.probe('Camera app picture taken'): |
2799 | + camera.take_picture() |
2800 | + |
2801 | + with self.smem.probe('Gallery app started'): |
2802 | + gallery = GalleryApp(self) |
2803 | + gallery.launch() |
2804 | + self.smem.pids.append(gallery.app.pid) |
2805 | + |
2806 | + with self.smem.probe('Media player app started'): |
2807 | + media_player = MediaPlayerApp(self) |
2808 | + media_player.launch() |
2809 | + self.smem.pids.append(media_player.app.pid) |
2810 | + |
2811 | + with self.smem.probe('Media player app finished playback'): |
2812 | + media_player = MediaPlayerApp(self) |
2813 | + media_player.launch('small.mp4') |
2814 | + self.smem.pids.append(media_player.app.pid) |
2815 | + media_player.assert_playback_finished() |
2816 | + |
2817 | + summary_msg = '\n'.join( |
2818 | + ['- {}: {}'.format(event, pids) |
2819 | + for event, pids in self.smem.threshold_exceeded_summary]) |
2820 | + self.assertListEqual( |
2821 | + self.smem.threshold_exceeded_summary, |
2822 | + [], |
2823 | + 'Threshold(s) exceded:\n{}'.format(summary_msg)) |
2824 | + |
2825 | + def _write_report(self): |
2826 | + """Write report to to results directory.""" |
2827 | + report_filename = '/var/cache/utah-probes/memory_usage.json' |
2828 | + with open(report_filename, 'w') as report_file: |
2829 | + json.dump(self.smem.report, report_file, |
2830 | + indent=4, sort_keys=True) |
2831 | + LOGGER.debug('Report written to {}'.format(report_file.name)) |
2832 | |
2833 | === added directory 'tests/messaging-app-autopilot' |
2834 | === added file 'tests/messaging-app-autopilot/master.run' |
2835 | --- tests/messaging-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
2836 | +++ tests/messaging-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
2837 | @@ -0,0 +1,15 @@ |
2838 | +--- |
2839 | +testsuites: |
2840 | + - name: settle-before |
2841 | + fetch_method: dev |
2842 | + fetch_location: ../systemsettle |
2843 | + include_tests: |
2844 | + - systemsettle-before |
2845 | + - name: messaging-app-autopilot |
2846 | + fetch_method: dev |
2847 | + fetch_location: ./ |
2848 | + - name: settle-after |
2849 | + fetch_method: dev |
2850 | + fetch_location: ../systemsettle |
2851 | + include_tests: |
2852 | + - systemsettle-after |
2853 | |
2854 | === added file 'tests/messaging-app-autopilot/ts_control' |
2855 | --- tests/messaging-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
2856 | +++ tests/messaging-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
2857 | @@ -0,0 +1,1 @@ |
2858 | +ts_setup: PKGS="messaging-app-autopilot ubuntu-ui-toolkit-autopilot" prepare-autopilot-test.sh |
2859 | |
2860 | === added file 'tests/messaging-app-autopilot/tslist.auto' |
2861 | --- tests/messaging-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
2862 | +++ tests/messaging-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
2863 | @@ -0,0 +1,4 @@ |
2864 | +- |
2865 | + discovery_cmd: autopilot-list messaging_app |
2866 | + test_cmd: autopilot-run messaging_app.tests.{} |
2867 | + |
2868 | |
2869 | === added directory 'tests/music-app-autopilot' |
2870 | === added file 'tests/music-app-autopilot/master.run' |
2871 | --- tests/music-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
2872 | +++ tests/music-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
2873 | @@ -0,0 +1,15 @@ |
2874 | +--- |
2875 | +testsuites: |
2876 | + - name: settle-before |
2877 | + fetch_method: dev |
2878 | + fetch_location: ../systemsettle |
2879 | + include_tests: |
2880 | + - systemsettle-before |
2881 | + - name: music-app-autopilot |
2882 | + fetch_method: dev |
2883 | + fetch_location: ./ |
2884 | + - name: settle-after |
2885 | + fetch_method: dev |
2886 | + fetch_location: ../systemsettle |
2887 | + include_tests: |
2888 | + - systemsettle-after |
2889 | |
2890 | === added file 'tests/music-app-autopilot/ts_control' |
2891 | --- tests/music-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
2892 | +++ tests/music-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
2893 | @@ -0,0 +1,1 @@ |
2894 | +ts_setup: PKGS=music-app-autopilot prepare-autopilot-test.sh |
2895 | |
2896 | === added file 'tests/music-app-autopilot/tslist.auto' |
2897 | --- tests/music-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
2898 | +++ tests/music-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
2899 | @@ -0,0 +1,4 @@ |
2900 | +- |
2901 | + discovery_cmd: autopilot-list music_app |
2902 | + test_cmd: autopilot-run music_app.tests.{} |
2903 | + |
2904 | |
2905 | === added directory 'tests/notes-app-autopilot' |
2906 | === added file 'tests/notes-app-autopilot/master.run' |
2907 | --- tests/notes-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
2908 | +++ tests/notes-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
2909 | @@ -0,0 +1,15 @@ |
2910 | +--- |
2911 | +testsuites: |
2912 | + - name: settle-before |
2913 | + fetch_method: dev |
2914 | + fetch_location: ../systemsettle |
2915 | + include_tests: |
2916 | + - systemsettle-before |
2917 | + - name: notes-app-autopilot |
2918 | + fetch_method: dev |
2919 | + fetch_location: ./ |
2920 | + - name: settle-after |
2921 | + fetch_method: dev |
2922 | + fetch_location: ../systemsettle |
2923 | + include_tests: |
2924 | + - systemsettle-after |
2925 | |
2926 | === added file 'tests/notes-app-autopilot/ts_control' |
2927 | --- tests/notes-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
2928 | +++ tests/notes-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
2929 | @@ -0,0 +1,1 @@ |
2930 | +ts_setup: PKGS=notes-app-autopilot prepare-autopilot-test.sh |
2931 | |
2932 | === added file 'tests/notes-app-autopilot/tslist.auto' |
2933 | --- tests/notes-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
2934 | +++ tests/notes-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
2935 | @@ -0,0 +1,4 @@ |
2936 | +- |
2937 | + discovery_cmd: autopilot-list notes_app |
2938 | + test_cmd: autopilot-run notes_app.tests.{} |
2939 | + |
2940 | |
2941 | === added directory 'tests/phone-app-connected-autopilot' |
2942 | === added file 'tests/phone-app-connected-autopilot/master.run' |
2943 | --- tests/phone-app-connected-autopilot/master.run 1970-01-01 00:00:00 +0000 |
2944 | +++ tests/phone-app-connected-autopilot/master.run 2013-09-05 19:05:51 +0000 |
2945 | @@ -0,0 +1,5 @@ |
2946 | +--- |
2947 | +testsuites: |
2948 | + - name: phone-app-connected-autopilot |
2949 | + fetch_method: dev |
2950 | + fetch_location: ./ |
2951 | |
2952 | === added file 'tests/phone-app-connected-autopilot/setup.sh' |
2953 | --- tests/phone-app-connected-autopilot/setup.sh 1970-01-01 00:00:00 +0000 |
2954 | +++ tests/phone-app-connected-autopilot/setup.sh 2013-09-05 19:05:51 +0000 |
2955 | @@ -0,0 +1,36 @@ |
2956 | +#!/bin/sh |
2957 | + |
2958 | +set -ex |
2959 | + |
2960 | +# we have issues with running the test too soon, this is a hack: |
2961 | +echo "SLEEPING 60 TO HELP MAKE SURE PHONE IS READY" |
2962 | +sleep 60 |
2963 | + |
2964 | + |
2965 | +if [ -z $ANDROID_SERIAL ] ; then |
2966 | + # set up the config file for the test |
2967 | + NUMBER=$(./sms_self.py --list) |
2968 | + cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > /home/phablet/.testnumbers.cfg |
2969 | + |
2970 | + # remove old logs so the receive test will work |
2971 | + rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf |
2972 | + |
2973 | + # now send an sms to ourself |
2974 | + ./sms_self.py |
2975 | +else |
2976 | + echo "test running from host" |
2977 | + adb push ./sms_self.py /home/phablet/autopilot/ |
2978 | + |
2979 | + # set up the config file for the test |
2980 | + NUMBER=$(adb-shell /home/phablet/autopilot/sms_self.py --list | head -n1) |
2981 | + cat ./testnumbers.cfg | sed -e "s/TODO/+$NUMBER/" > .testnumbers.cfg |
2982 | + adb push .testnumbers.cfg /home/phablet/.testnumbers.cfg |
2983 | + rm .testnumbers.cfg |
2984 | + |
2985 | + # remove old logs so the receive test will work |
2986 | + adb-shell rm /home/phablet/.local/share/TpLogger/logs/ofono_ofono_account0/* -rf |
2987 | + adb-shell /home/phablet/autopilot/sms_self.py |
2988 | +fi |
2989 | + |
2990 | +sleep 10s # try and let the message come through |
2991 | +PKGS="phone-app-connected-autopilot" prepare-autopilot-test.sh |
2992 | |
2993 | === added file 'tests/phone-app-connected-autopilot/sms_self.py' |
2994 | --- tests/phone-app-connected-autopilot/sms_self.py 1970-01-01 00:00:00 +0000 |
2995 | +++ tests/phone-app-connected-autopilot/sms_self.py 2013-09-05 19:05:51 +0000 |
2996 | @@ -0,0 +1,34 @@ |
2997 | +#!/usr/bin/env python |
2998 | + |
2999 | +import argparse |
3000 | +import dbus |
3001 | + |
3002 | + |
3003 | +def _get_parser(): |
3004 | + parser = argparse.ArgumentParser( |
3005 | + description='Send an SMS message to yourself via the ofono API') |
3006 | + parser.add_argument('-m', '--modem', default='/ril_0', |
3007 | + help='The modem to use. Default: %(default)s') |
3008 | + parser.add_argument('message', nargs='?', default='hello world', |
3009 | + help='Message to send. Default "%(default)s"') |
3010 | + parser.add_argument('--list', action='store_true', |
3011 | + help='Just print the number of this cell phone.') |
3012 | + return parser |
3013 | + |
3014 | + |
3015 | +def _main(args): |
3016 | + bus = dbus.SystemBus() |
3017 | + obj = bus.get_object('org.ofono', args.modem) |
3018 | + |
3019 | + mgr = dbus.Interface(obj, 'org.ofono.SimManager') |
3020 | + local_sms = str(mgr.GetProperties()['SubscriberNumbers'][0]) |
3021 | + |
3022 | + if args.list: |
3023 | + print local_sms |
3024 | + else: |
3025 | + mgr = dbus.Interface(obj, 'org.ofono.MessageManager') |
3026 | + mgr.SendMessage(local_sms, args.message) |
3027 | + |
3028 | + |
3029 | +if __name__ == '__main__': |
3030 | + _main(_get_parser().parse_args()) |
3031 | |
3032 | === added file 'tests/phone-app-connected-autopilot/testnumbers.cfg' |
3033 | --- tests/phone-app-connected-autopilot/testnumbers.cfg 1970-01-01 00:00:00 +0000 |
3034 | +++ tests/phone-app-connected-autopilot/testnumbers.cfg 2013-09-05 19:05:51 +0000 |
3035 | @@ -0,0 +1,23 @@ |
3036 | +[connected_variables] |
3037 | + |
3038 | +#number to dial |
3039 | +dial_number = 77777 |
3040 | + |
3041 | +#number to send sms to (doanac's google voice) |
3042 | +sms_send_number = 4322350086 |
3043 | + |
3044 | +#expected to receive sms from |
3045 | +sms_receive_num = TODO |
3046 | + |
3047 | +#time (in seconds) allowed for the outgoing call |
3048 | +outgoing_call_duration = 20 |
3049 | + |
3050 | +#time (in seconds) to wait till the call is not received |
3051 | +call_wait_time = 2 |
3052 | + |
3053 | +#text to send in the sms |
3054 | +sms_send_text = Hey there |
3055 | + |
3056 | +#expected text to be received in sms |
3057 | +sms_expect_text = Ubuntu Rocks |
3058 | + |
3059 | |
3060 | === added file 'tests/phone-app-connected-autopilot/ts_control' |
3061 | --- tests/phone-app-connected-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3062 | +++ tests/phone-app-connected-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3063 | @@ -0,0 +1,1 @@ |
3064 | +ts_setup: sh ./setup.sh |
3065 | |
3066 | === added file 'tests/phone-app-connected-autopilot/tslist.auto' |
3067 | --- tests/phone-app-connected-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3068 | +++ tests/phone-app-connected-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3069 | @@ -0,0 +1,4 @@ |
3070 | +- |
3071 | + discovery_cmd: autopilot-list connected_tests test_communication_panel |
3072 | + test_cmd: autopilot-run connected_tests.tests.{} |
3073 | + |
3074 | |
3075 | === added directory 'tests/share-app-autopilot' |
3076 | === added file 'tests/share-app-autopilot/master.run' |
3077 | --- tests/share-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3078 | +++ tests/share-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3079 | @@ -0,0 +1,15 @@ |
3080 | +--- |
3081 | +testsuites: |
3082 | + - name: settle-before |
3083 | + fetch_method: dev |
3084 | + fetch_location: ../systemsettle |
3085 | + include_tests: |
3086 | + - systemsettle-before |
3087 | + - name: share-app-autopilot |
3088 | + fetch_method: dev |
3089 | + fetch_location: ./ |
3090 | + - name: settle-after |
3091 | + fetch_method: dev |
3092 | + fetch_location: ../systemsettle |
3093 | + include_tests: |
3094 | + - systemsettle-after |
3095 | |
3096 | === added file 'tests/share-app-autopilot/ts_control' |
3097 | --- tests/share-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3098 | +++ tests/share-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3099 | @@ -0,0 +1,1 @@ |
3100 | +ts_setup: PKGS=share-app-autopilot prepare-autopilot-test.sh |
3101 | |
3102 | === added file 'tests/share-app-autopilot/tslist.auto' |
3103 | --- tests/share-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3104 | +++ tests/share-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3105 | @@ -0,0 +1,4 @@ |
3106 | +- |
3107 | + discovery_cmd: autopilot-list share_app |
3108 | + test_cmd: autopilot-run share_app.tests.{} |
3109 | + |
3110 | |
3111 | === added directory 'tests/systemsettle' |
3112 | === added directory 'tests/systemsettle/systemsettle-after' |
3113 | === added file 'tests/systemsettle/systemsettle-after/tc_control' |
3114 | --- tests/systemsettle/systemsettle-after/tc_control 1970-01-01 00:00:00 +0000 |
3115 | +++ tests/systemsettle/systemsettle-after/tc_control 2013-09-05 19:05:51 +0000 |
3116 | @@ -0,0 +1,9 @@ |
3117 | +description: check if system settles to idle average > 99.25% |
3118 | +dependencies: none |
3119 | +action: | |
3120 | + 1. Take CPU load samples for 10s, do this up to 10 times until idle is over 99% |
3121 | +expected_results: | |
3122 | + 1. When doing nothing, system calms down to at least 99% idle level |
3123 | +type: userland |
3124 | +timeout: 120 |
3125 | +command: ../systemsettle.sh -c5 -d2 -p 97.5 -l _after |
3126 | |
3127 | === added directory 'tests/systemsettle/systemsettle-before' |
3128 | === added file 'tests/systemsettle/systemsettle-before/tc_control' |
3129 | --- tests/systemsettle/systemsettle-before/tc_control 1970-01-01 00:00:00 +0000 |
3130 | +++ tests/systemsettle/systemsettle-before/tc_control 2013-09-05 19:05:51 +0000 |
3131 | @@ -0,0 +1,9 @@ |
3132 | +description: check if system settles to idle average > 99.25% |
3133 | +dependencies: none |
3134 | +action: | |
3135 | + 1. Take CPU load samples for 10s, do this up to 10 times until idle is over 99% |
3136 | +expected_results: | |
3137 | + 1. When doing nothing, system calms down to at least 99% idle level |
3138 | +type: userland |
3139 | +timeout: 120 |
3140 | +command: ../systemsettle.sh -c5 -d2 -p 97.5 -l _before |
3141 | |
3142 | === added file 'tests/systemsettle/systemsettle.sh' |
3143 | --- tests/systemsettle/systemsettle.sh 1970-01-01 00:00:00 +0000 |
3144 | +++ tests/systemsettle/systemsettle.sh 2013-09-05 19:05:51 +0000 |
3145 | @@ -0,0 +1,119 @@ |
3146 | +#!/bin/bash |
3147 | + |
3148 | +# Configuration variables: |
3149 | +# TARGET_PREFIX - Allows this to be run from the host, by providings something |
3150 | +# like TARGET_PREFIX="adb shell" |
3151 | +# UTAH_PROBE_DIR - optionally where to save log files so utah will grab them |
3152 | + |
3153 | +set -e |
3154 | + |
3155 | +[ -z $UTAH_PROBE_DIR ] && UTAH_PROBE_DIR="/tmp" |
3156 | + |
3157 | +# default exit code storage |
3158 | +dump_error=1 |
3159 | + |
3160 | +calc () { awk "BEGIN{ print $* }" ;} |
3161 | + |
3162 | +function show_usage() { |
3163 | + echo "Usage:" |
3164 | + echo " $0 [options]" |
3165 | + echo "Options:" |
3166 | + echo " -r run forever without exiting" |
3167 | + echo " -p minimum idle percent to wait for (Default: 99)" |
3168 | + echo " -c number of times to run top at each iteration (Default: 10)" |
3169 | + echo " -d seconds to delay between each top iteration (Default: 6)" |
3170 | + echo " -i top measurements to ignore from each loop (Default: 1)" |
3171 | + echo " -m maximum loops of top before giving up if minimum idle" |
3172 | + echo " percent is not reached (Default: 10)" |
3173 | + echo " -l label to include for the top_log file" |
3174 | + exit 129 |
3175 | +} |
3176 | + |
3177 | +while getopts "h?rp:c:d:i:m:l:" opt; do |
3178 | + case "$opt" in |
3179 | + h|\?) show_usage |
3180 | + ;; |
3181 | + r) settle_prefix='-' |
3182 | + ;; |
3183 | + p) idle_avg_min=$OPTARG |
3184 | + ;; |
3185 | + c) top_repeat=$OPTARG |
3186 | + ;; |
3187 | + d) top_wait=$OPTARG |
3188 | + ;; |
3189 | + i) top_ignore=$OPTARG |
3190 | + ;; |
3191 | + m) settle_max=$OPTARG |
3192 | + ;; |
3193 | + l) top_log_label=$OPTARG |
3194 | + ;; |
3195 | + esac |
3196 | +done |
3197 | + |
3198 | +# minimum average idle level required to succeed |
3199 | +idle_avg_min=${idle_avg_min:-99} |
3200 | +# measurement details: top $top_wait $top_repeat |
3201 | +top_repeat=${top_repeat:-10} |
3202 | +top_wait=${top_wait:-6} |
3203 | +# how many samples to ignore |
3204 | +top_ignore=${top_ignore:-1} |
3205 | +# how many total attempts to settle the system |
3206 | +settle_max=${settle_max:-10} |
3207 | + |
3208 | +top_log="$UTAH_PROBE_DIR/top$top_log_label.log" |
3209 | + |
3210 | +# set and calc more runtime values |
3211 | +top_tail=`calc $top_repeat - $top_ignore` |
3212 | +settle_count=0 |
3213 | +idle_avg=0 |
3214 | + |
3215 | +echo "System Settle run - quiesce the system" |
3216 | +echo "--------------------------------------" |
3217 | +echo |
3218 | +echo " idle_avg_min = '$idle_avg_min'" |
3219 | +echo " top_repeat = '$top_repeat'" |
3220 | +echo " top_wait = '$top_wait'" |
3221 | +echo " top_ignore = '$top_ignore'" |
3222 | +echo " settle_max = '$settle_max'" |
3223 | +echo " run_forever = '$settle_prefix' (- = yes)" |
3224 | +echo " log files = $top_log $top_log.reduced" |
3225 | +echo |
3226 | + |
3227 | +while test `calc $idle_avg '<' $idle_avg_min` = 1 -a "$settle_prefix$settle_count" -lt "$settle_max"; do |
3228 | + echo -n "Starting system idle measurement (run: $settle_count) ... " |
3229 | + |
3230 | + # get top |
3231 | + echo "TOP DUMP (after settle run: $settle_count)" >> $top_log |
3232 | + echo "========================" >> $top_log |
3233 | + ${TARGET_PREFIX} top -b -d $top_wait -n $top_repeat >> $top_log |
3234 | + cat $top_log | grep '.Cpu.*' | tail -n $top_tail > $top_log.reduced |
3235 | + echo >> $top_log |
3236 | + |
3237 | + # calc average of idle field for this measurement |
3238 | + sum=0 |
3239 | + count=0 |
3240 | + while read line; do |
3241 | + idle=`echo $line | sed -e 's/.* \([0-9\.]*\) id.*/\1/'` |
3242 | + sum=`calc $sum + $idle` |
3243 | + count=`calc $count + 1` |
3244 | + done < $top_log.reduced |
3245 | + |
3246 | + idle_avg=`calc $sum / $count` |
3247 | + settle_count=`calc $settle_count + 1` |
3248 | + |
3249 | + echo " DONE." |
3250 | + echo |
3251 | + echo "Measurement:" |
3252 | + echo " + idle level: $idle_avg" |
3253 | + echo " + idle sum: $sum / count: $count" |
3254 | + echo |
3255 | +done |
3256 | + |
3257 | +if test `calc $idle_avg '<' $idle_avg_min` = 1; then |
3258 | + echo "system not settled. FAIL" |
3259 | + exit 1 |
3260 | +else |
3261 | + echo "system settled. SUCCESS" |
3262 | + exit 0 |
3263 | +fi |
3264 | + |
3265 | |
3266 | === added file 'tests/systemsettle/tslist.run' |
3267 | --- tests/systemsettle/tslist.run 1970-01-01 00:00:00 +0000 |
3268 | +++ tests/systemsettle/tslist.run 2013-09-05 19:05:51 +0000 |
3269 | @@ -0,0 +1,2 @@ |
3270 | +- test: systemsettle-before |
3271 | +- test: systemsettle-after |
3272 | |
3273 | === added file 'tests/touch-smoke-boot.run' |
3274 | --- tests/touch-smoke-boot.run 1970-01-01 00:00:00 +0000 |
3275 | +++ tests/touch-smoke-boot.run 2013-09-05 19:05:51 +0000 |
3276 | @@ -0,0 +1,6 @@ |
3277 | +testsuites: |
3278 | + - name: usit |
3279 | + fetch_method: bzr-export |
3280 | + fetch_location: lp:ubuntu-test-cases/desktop/testsuites/usit |
3281 | + include_tests: |
3282 | + - read_write |
3283 | |
3284 | === added file 'tests/touch-smoke-sdk.run' |
3285 | --- tests/touch-smoke-sdk.run 1970-01-01 00:00:00 +0000 |
3286 | +++ tests/touch-smoke-sdk.run 2013-09-05 19:05:51 +0000 |
3287 | @@ -0,0 +1,4 @@ |
3288 | +testsuites: |
3289 | + - name: sdk |
3290 | + fetch_method: bzr-export |
3291 | + fetch_location: lp:~ubuntu-test-case-dev/ubuntu-test-cases/package-checks/sdk |
3292 | |
3293 | === added file 'tests/touch-smoke-security.run' |
3294 | --- tests/touch-smoke-security.run 1970-01-01 00:00:00 +0000 |
3295 | +++ tests/touch-smoke-security.run 2013-09-05 19:05:51 +0000 |
3296 | @@ -0,0 +1,4 @@ |
3297 | +testsuites: |
3298 | + - name: image |
3299 | + fetch_method: bzr-export |
3300 | + fetch_location: lp:~ubuntu-test-case-dev/ubuntu-test-cases/package-checks/image |
3301 | |
3302 | === added directory 'tests/ubuntu-calculator-app-autopilot' |
3303 | === added file 'tests/ubuntu-calculator-app-autopilot/master.run' |
3304 | --- tests/ubuntu-calculator-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3305 | +++ tests/ubuntu-calculator-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3306 | @@ -0,0 +1,15 @@ |
3307 | +--- |
3308 | +testsuites: |
3309 | + - name: settle-before |
3310 | + fetch_method: dev |
3311 | + fetch_location: ../systemsettle |
3312 | + include_tests: |
3313 | + - systemsettle-before |
3314 | + - name: ubuntu-calculator-app-autopilot |
3315 | + fetch_method: dev |
3316 | + fetch_location: ./ |
3317 | + - name: settle-after |
3318 | + fetch_method: dev |
3319 | + fetch_location: ../systemsettle |
3320 | + include_tests: |
3321 | + - systemsettle-after |
3322 | |
3323 | === added file 'tests/ubuntu-calculator-app-autopilot/ts_control' |
3324 | --- tests/ubuntu-calculator-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3325 | +++ tests/ubuntu-calculator-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3326 | @@ -0,0 +1,1 @@ |
3327 | +ts_setup: PKGS=ubuntu-calculator-app-autopilot prepare-autopilot-test.sh |
3328 | |
3329 | === added file 'tests/ubuntu-calculator-app-autopilot/tslist.auto' |
3330 | --- tests/ubuntu-calculator-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3331 | +++ tests/ubuntu-calculator-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3332 | @@ -0,0 +1,4 @@ |
3333 | +- |
3334 | + discovery_cmd: autopilot-list ubuntu_calculator_app |
3335 | + test_cmd: autopilot-run ubuntu_calculator_app.tests.{} |
3336 | + |
3337 | |
3338 | === added directory 'tests/ubuntu-clock-app-autopilot' |
3339 | === added file 'tests/ubuntu-clock-app-autopilot/master.run' |
3340 | --- tests/ubuntu-clock-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3341 | +++ tests/ubuntu-clock-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3342 | @@ -0,0 +1,15 @@ |
3343 | +--- |
3344 | +testsuites: |
3345 | + - name: settle-before |
3346 | + fetch_method: dev |
3347 | + fetch_location: ../systemsettle |
3348 | + include_tests: |
3349 | + - systemsettle-before |
3350 | + - name: ubuntu-clock-app-autopilot |
3351 | + fetch_method: dev |
3352 | + fetch_location: ./ |
3353 | + - name: settle-after |
3354 | + fetch_method: dev |
3355 | + fetch_location: ../systemsettle |
3356 | + include_tests: |
3357 | + - systemsettle-after |
3358 | |
3359 | === added file 'tests/ubuntu-clock-app-autopilot/ts_control' |
3360 | --- tests/ubuntu-clock-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3361 | +++ tests/ubuntu-clock-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3362 | @@ -0,0 +1,1 @@ |
3363 | +ts_setup: PKGS=ubuntu-clock-app-autopilot prepare-autopilot-test.sh |
3364 | |
3365 | === added file 'tests/ubuntu-clock-app-autopilot/tslist.auto' |
3366 | --- tests/ubuntu-clock-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3367 | +++ tests/ubuntu-clock-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3368 | @@ -0,0 +1,4 @@ |
3369 | +- |
3370 | + discovery_cmd: autopilot-list ubuntu_clock_app |
3371 | + test_cmd: autopilot-run ubuntu_clock_app.tests.{} |
3372 | + |
3373 | |
3374 | === added directory 'tests/ubuntu-docviewer-app-autopilot' |
3375 | === added file 'tests/ubuntu-docviewer-app-autopilot/master.run' |
3376 | --- tests/ubuntu-docviewer-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3377 | +++ tests/ubuntu-docviewer-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3378 | @@ -0,0 +1,15 @@ |
3379 | +--- |
3380 | +testsuites: |
3381 | + - name: settle-before |
3382 | + fetch_method: dev |
3383 | + fetch_location: ../systemsettle |
3384 | + include_tests: |
3385 | + - systemsettle-before |
3386 | + - name: ubuntu-docviewer-app-autopilot |
3387 | + fetch_method: dev |
3388 | + fetch_location: ./ |
3389 | + - name: settle-after |
3390 | + fetch_method: dev |
3391 | + fetch_location: ../systemsettle |
3392 | + include_tests: |
3393 | + - systemsettle-after |
3394 | |
3395 | === added file 'tests/ubuntu-docviewer-app-autopilot/ts_control' |
3396 | --- tests/ubuntu-docviewer-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3397 | +++ tests/ubuntu-docviewer-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3398 | @@ -0,0 +1,1 @@ |
3399 | +ts_setup: PKGS=ubuntu-docviewer-app-autopilot prepare-autopilot-test.sh |
3400 | |
3401 | === added file 'tests/ubuntu-docviewer-app-autopilot/tslist.auto' |
3402 | --- tests/ubuntu-docviewer-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3403 | +++ tests/ubuntu-docviewer-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3404 | @@ -0,0 +1,4 @@ |
3405 | +- |
3406 | + discovery_cmd: autopilot-list ubuntu_docviewer_app |
3407 | + test_cmd: autopilot-run ubuntu_docviewer_app.tests.{} |
3408 | + |
3409 | |
3410 | === added directory 'tests/ubuntu-filemanager-app-autopilot' |
3411 | === added file 'tests/ubuntu-filemanager-app-autopilot/master.run' |
3412 | --- tests/ubuntu-filemanager-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3413 | +++ tests/ubuntu-filemanager-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3414 | @@ -0,0 +1,15 @@ |
3415 | +--- |
3416 | +testsuites: |
3417 | + - name: settle-before |
3418 | + fetch_method: dev |
3419 | + fetch_location: ../systemsettle |
3420 | + include_tests: |
3421 | + - systemsettle-before |
3422 | + - name: ubuntu-filemanager-app-autopilot |
3423 | + fetch_method: dev |
3424 | + fetch_location: ./ |
3425 | + - name: settle-after |
3426 | + fetch_method: dev |
3427 | + fetch_location: ../systemsettle |
3428 | + include_tests: |
3429 | + - systemsettle-after |
3430 | |
3431 | === added file 'tests/ubuntu-filemanager-app-autopilot/ts_control' |
3432 | --- tests/ubuntu-filemanager-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3433 | +++ tests/ubuntu-filemanager-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3434 | @@ -0,0 +1,1 @@ |
3435 | +ts_setup: PKGS=ubuntu-filemanager-app-autopilot prepare-autopilot-test.sh |
3436 | |
3437 | === added file 'tests/ubuntu-filemanager-app-autopilot/tslist.auto' |
3438 | --- tests/ubuntu-filemanager-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3439 | +++ tests/ubuntu-filemanager-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3440 | @@ -0,0 +1,4 @@ |
3441 | +- |
3442 | + discovery_cmd: autopilot-list ubuntu_filemanager_app |
3443 | + test_cmd: autopilot-run ubuntu_filemanager_app.tests.{} |
3444 | + |
3445 | |
3446 | === added directory 'tests/ubuntu-rssreader-app-autopilot' |
3447 | === added file 'tests/ubuntu-rssreader-app-autopilot/master.run' |
3448 | --- tests/ubuntu-rssreader-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3449 | +++ tests/ubuntu-rssreader-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3450 | @@ -0,0 +1,15 @@ |
3451 | +--- |
3452 | +testsuites: |
3453 | + - name: settle-before |
3454 | + fetch_method: dev |
3455 | + fetch_location: ../systemsettle |
3456 | + include_tests: |
3457 | + - systemsettle-before |
3458 | + - name: ubuntu-rssreader-app-autopilot |
3459 | + fetch_method: dev |
3460 | + fetch_location: ./ |
3461 | + - name: settle-after |
3462 | + fetch_method: dev |
3463 | + fetch_location: ../systemsettle |
3464 | + include_tests: |
3465 | + - systemsettle-after |
3466 | |
3467 | === added file 'tests/ubuntu-rssreader-app-autopilot/ts_control' |
3468 | --- tests/ubuntu-rssreader-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3469 | +++ tests/ubuntu-rssreader-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3470 | @@ -0,0 +1,1 @@ |
3471 | +ts_setup: PKGS=ubuntu-rssreader-app-autopilot prepare-autopilot-test.sh |
3472 | |
3473 | === added file 'tests/ubuntu-rssreader-app-autopilot/tslist.auto' |
3474 | --- tests/ubuntu-rssreader-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3475 | +++ tests/ubuntu-rssreader-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3476 | @@ -0,0 +1,4 @@ |
3477 | +- |
3478 | + discovery_cmd: autopilot-list ubuntu_rssreader_app |
3479 | + test_cmd: autopilot-run ubuntu_rssreader_app.tests.{} |
3480 | + |
3481 | |
3482 | === added directory 'tests/ubuntu-terminal-app-autopilot' |
3483 | === added file 'tests/ubuntu-terminal-app-autopilot/master.run' |
3484 | --- tests/ubuntu-terminal-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3485 | +++ tests/ubuntu-terminal-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3486 | @@ -0,0 +1,15 @@ |
3487 | +--- |
3488 | +testsuites: |
3489 | + - name: settle-before |
3490 | + fetch_method: dev |
3491 | + fetch_location: ../systemsettle |
3492 | + include_tests: |
3493 | + - systemsettle-before |
3494 | + - name: ubuntu-terminal-app-autopilot |
3495 | + fetch_method: dev |
3496 | + fetch_location: ./ |
3497 | + - name: settle-after |
3498 | + fetch_method: dev |
3499 | + fetch_location: ../systemsettle |
3500 | + include_tests: |
3501 | + - systemsettle-after |
3502 | |
3503 | === added file 'tests/ubuntu-terminal-app-autopilot/ts_control' |
3504 | --- tests/ubuntu-terminal-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3505 | +++ tests/ubuntu-terminal-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3506 | @@ -0,0 +1,1 @@ |
3507 | +ts_setup: PKGS=ubuntu-terminal-app-autopilot prepare-autopilot-test.sh |
3508 | |
3509 | === added file 'tests/ubuntu-terminal-app-autopilot/tslist.auto' |
3510 | --- tests/ubuntu-terminal-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3511 | +++ tests/ubuntu-terminal-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3512 | @@ -0,0 +1,4 @@ |
3513 | +- |
3514 | + discovery_cmd: autopilot-list ubuntu_terminal_app |
3515 | + test_cmd: autopilot-run ubuntu_terminal_app.tests.{} |
3516 | + |
3517 | |
3518 | === added directory 'tests/ubuntu-weather-app-autopilot' |
3519 | === added file 'tests/ubuntu-weather-app-autopilot/master.run' |
3520 | --- tests/ubuntu-weather-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3521 | +++ tests/ubuntu-weather-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3522 | @@ -0,0 +1,15 @@ |
3523 | +--- |
3524 | +testsuites: |
3525 | + - name: settle-before |
3526 | + fetch_method: dev |
3527 | + fetch_location: ../systemsettle |
3528 | + include_tests: |
3529 | + - systemsettle-before |
3530 | + - name: ubuntu-weather-app-autopilot |
3531 | + fetch_method: dev |
3532 | + fetch_location: ./ |
3533 | + - name: settle-after |
3534 | + fetch_method: dev |
3535 | + fetch_location: ../systemsettle |
3536 | + include_tests: |
3537 | + - systemsettle-after |
3538 | |
3539 | === added file 'tests/ubuntu-weather-app-autopilot/ts_control' |
3540 | --- tests/ubuntu-weather-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3541 | +++ tests/ubuntu-weather-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3542 | @@ -0,0 +1,1 @@ |
3543 | +ts_setup: PKGS=ubuntu-weather-app-autopilot prepare-autopilot-test.sh |
3544 | |
3545 | === added file 'tests/ubuntu-weather-app-autopilot/tslist.auto' |
3546 | --- tests/ubuntu-weather-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3547 | +++ tests/ubuntu-weather-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3548 | @@ -0,0 +1,4 @@ |
3549 | +- |
3550 | + discovery_cmd: autopilot-list ubuntu_weather_app |
3551 | + test_cmd: autopilot-run ubuntu_weather_app.tests.{} |
3552 | + |
3553 | |
3554 | === added directory 'tests/unity8-autopilot' |
3555 | === added file 'tests/unity8-autopilot/master.run' |
3556 | --- tests/unity8-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3557 | +++ tests/unity8-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3558 | @@ -0,0 +1,15 @@ |
3559 | +--- |
3560 | +testsuites: |
3561 | + - name: settle-before |
3562 | + fetch_method: dev |
3563 | + fetch_location: ../systemsettle |
3564 | + include_tests: |
3565 | + - systemsettle-before |
3566 | + - name: unity8-autopilot |
3567 | + fetch_method: dev |
3568 | + fetch_location: ./ |
3569 | + - name: settle-after |
3570 | + fetch_method: dev |
3571 | + fetch_location: ../systemsettle |
3572 | + include_tests: |
3573 | + - systemsettle-after |
3574 | |
3575 | === added file 'tests/unity8-autopilot/setup.sh' |
3576 | --- tests/unity8-autopilot/setup.sh 1970-01-01 00:00:00 +0000 |
3577 | +++ tests/unity8-autopilot/setup.sh 2013-09-05 19:05:51 +0000 |
3578 | @@ -0,0 +1,6 @@ |
3579 | +#!/bin/sh |
3580 | + |
3581 | +set -e |
3582 | + |
3583 | +NO_UNLOCK=1 PKGS="unity8-autopilot" prepare-autopilot-test.sh |
3584 | +$TARGET_PREFIX sudo -i -u phablet stop unity8 |
3585 | |
3586 | === added file 'tests/unity8-autopilot/ts_control' |
3587 | --- tests/unity8-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3588 | +++ tests/unity8-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3589 | @@ -0,0 +1,2 @@ |
3590 | +ts_setup: TARGET_PREFIX=$TARGET_PREFIX ./setup.sh |
3591 | +ts_cleanup: $TARGET_PREFIX sudo -i -u phablet start unity8 |
3592 | |
3593 | === added file 'tests/unity8-autopilot/tslist.auto' |
3594 | --- tests/unity8-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3595 | +++ tests/unity8-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3596 | @@ -0,0 +1,4 @@ |
3597 | +- |
3598 | + discovery_cmd: autopilot-list unity8 unity8 unity8. |
3599 | + test_cmd: autopilot-run unity8.{} |
3600 | + |
3601 | |
3602 | === added directory 'tests/upgrade' |
3603 | === added file 'tests/upgrade/README' |
3604 | --- tests/upgrade/README 1970-01-01 00:00:00 +0000 |
3605 | +++ tests/upgrade/README 2013-09-05 19:05:51 +0000 |
3606 | @@ -0,0 +1,3 @@ |
3607 | +NOTE: This test is intended to be run by UTAH using the "--from-host" |
3608 | +method. This is different from other tests in this repository and should |
3609 | +not be run with jenkins.sh |
3610 | |
3611 | === added directory 'tests/upgrade/install_old' |
3612 | === added file 'tests/upgrade/install_old/run.sh' |
3613 | --- tests/upgrade/install_old/run.sh 1970-01-01 00:00:00 +0000 |
3614 | +++ tests/upgrade/install_old/run.sh 2013-09-05 19:05:51 +0000 |
3615 | @@ -0,0 +1,27 @@ |
3616 | +#!/bin/bash |
3617 | + |
3618 | +## Puts an older build on the device |
3619 | +## Intersting environment variables that must be set: |
3620 | +## ANDROID_SERIAL - specify another android device |
3621 | +## NETWORK_FILE - specify an alternative network file |
3622 | +## UPGRADE_FROM - the revision to upgrade from, eg -1 |
3623 | + |
3624 | +set -eux |
3625 | + |
3626 | +BASEDIR=$(dirname $(readlink -f $0)) |
3627 | + |
3628 | +RESDIR=`pwd`/clientlogs |
3629 | + |
3630 | +UTAH_PHABLET_CMD="${UTAH_PHABLET_CMD-/usr/share/utah/examples/run_utah_phablet.py}" |
3631 | +ANDROID_SERIAL="${ANDROID_SERIAL-015d1884b20c1c0f}" #doanac's nexus7 at home |
3632 | +NETWORK_FILE="${NETWORK_FILE-/home/ubuntu/magners-wifi}" |
3633 | +UPGRADE_FROM="${UPGRADE_FROM--1}" |
3634 | +CLIENT_LOGS="${CLIENT_LOGS-/tmp}" |
3635 | + |
3636 | +echo "INSTALLING OLD BUILD..." |
3637 | +$UTAH_PHABLET_CMD -s $ANDROID_SERIAL \ |
3638 | + --ubuntu-bootstrap -r $UPGRADE_FROM \ |
3639 | + --network-file $NETWORK_FILE \ |
3640 | + --skip-utah \ |
3641 | + --pull /var/crash \ |
3642 | + --results-dir=${CLIENT_LOGS} |
3643 | |
3644 | === added file 'tests/upgrade/install_old/tc_control' |
3645 | --- tests/upgrade/install_old/tc_control 1970-01-01 00:00:00 +0000 |
3646 | +++ tests/upgrade/install_old/tc_control 2013-09-05 19:05:51 +0000 |
3647 | @@ -0,0 +1,9 @@ |
3648 | +description: sets up a previous days build on the target |
3649 | +dependencies: n/a |
3650 | +action: | |
3651 | + 1. install an older system image |
3652 | +expected_results: | |
3653 | + 1. an older system image will be installed |
3654 | +type: userland |
3655 | +timeout: 1800 |
3656 | +command: ./run.sh |
3657 | |
3658 | === added file 'tests/upgrade/master.run' |
3659 | --- tests/upgrade/master.run 1970-01-01 00:00:00 +0000 |
3660 | +++ tests/upgrade/master.run 2013-09-05 19:05:51 +0000 |
3661 | @@ -0,0 +1,5 @@ |
3662 | +--- |
3663 | +testsuites: |
3664 | + - name: upgrade |
3665 | + fetch_method: dev |
3666 | + fetch_location: ./ |
3667 | |
3668 | === added file 'tests/upgrade/tslist.run' |
3669 | --- tests/upgrade/tslist.run 1970-01-01 00:00:00 +0000 |
3670 | +++ tests/upgrade/tslist.run 2013-09-05 19:05:51 +0000 |
3671 | @@ -0,0 +1,2 @@ |
3672 | +- test: install_old |
3673 | +- test: upgrade |
3674 | |
3675 | === added directory 'tests/upgrade/upgrade' |
3676 | === added file 'tests/upgrade/upgrade/tc_control' |
3677 | --- tests/upgrade/upgrade/tc_control 1970-01-01 00:00:00 +0000 |
3678 | +++ tests/upgrade/upgrade/tc_control 2013-09-05 19:05:51 +0000 |
3679 | @@ -0,0 +1,9 @@ |
3680 | +description: performs an upgrade using system-image-cli |
3681 | +dependencies: a touch read-only image |
3682 | +action: | |
3683 | + 1. execute upgrade |
3684 | +expected_results: | |
3685 | + 1. it will reboot into recovery, upgrade, and boot up |
3686 | +type: userland |
3687 | +timeout: 1800 |
3688 | +command: ./upgrade.sh |
3689 | |
3690 | === added file 'tests/upgrade/upgrade/upgrade.sh' |
3691 | --- tests/upgrade/upgrade/upgrade.sh 1970-01-01 00:00:00 +0000 |
3692 | +++ tests/upgrade/upgrade/upgrade.sh 2013-09-05 19:05:51 +0000 |
3693 | @@ -0,0 +1,79 @@ |
3694 | +#!/bin/sh |
3695 | + |
3696 | +## upgrades the given target |
3697 | +## Intersting environment variables that must be set: |
3698 | +## ANDROID_SERIAL - specify another android device |
3699 | +ANDROID_SERIAL="${ANDROID_SERIAL-015d1884b20c1c0f}" #doanac's nexus7 at home |
3700 | + |
3701 | +set -eux |
3702 | + |
3703 | +export ANDROID_SERIAL=$ANDROID_SERIAL |
3704 | + |
3705 | +phablet_reboot_wait() { |
3706 | + # TODO get this into phablet-tools |
3707 | + adb reboot |
3708 | + adb shell stop android-tools-adbd 2>/dev/null || true |
3709 | + adb wait-for-device |
3710 | + # sometimes wait-for-device comes back too quick, so wait once more |
3711 | + sleep 4s |
3712 | + adb wait-for-device |
3713 | +} |
3714 | + |
3715 | +# try and get the system up with an actual wlan0 |
3716 | +phablet_get_interface() { |
3717 | + if ! adb shell ifconfig -a | grep wlan0 >/dev/null ; then |
3718 | + return 1 |
3719 | + fi |
3720 | +} |
3721 | + |
3722 | +# try and try and try to get an IP |
3723 | +# network is flaky, this seems to help: |
3724 | +phablet_get_ip() { |
3725 | + adb shell nmcli c list |
3726 | + uuid=$(adb shell nmcli c list | grep 802-11-wireless | tail -n1 | grep -o -E "[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}") |
3727 | + tmp=$(mktemp) |
3728 | + adb shell sh -c "nmcli c up uuid $uuid ; echo ANDROID_RC=$?" | tee $tmp |
3729 | + rc=1 |
3730 | + if grep "ANDROID_RC=0" $tmp >/dev/null; then |
3731 | + rc=0 |
3732 | + fi |
3733 | + rm $tmp |
3734 | + return $rc |
3735 | +} |
3736 | + |
3737 | +retry() { |
3738 | + cmd=$1 |
3739 | + retries=$2 |
3740 | + |
3741 | + for i in $(seq $retries) ; do |
3742 | + if $cmd ; then |
3743 | + return 0 |
3744 | + fi |
3745 | + times=$(($retries - $i)) |
3746 | + if [ $times -ne 0 ] ; then |
3747 | + echo "$cmd: failed, retrying $(($retries - $i)) more times" |
3748 | + [ -z $reboot ] || phablet_reboot_wait |
3749 | + sleep 60 |
3750 | + else |
3751 | + echo "$cmd: failed after $retries attempts" |
3752 | + fi |
3753 | + done |
3754 | + return 1 |
3755 | +} |
3756 | + |
3757 | +orig_version=$(adb shell system-image-cli -b) |
3758 | +echo $orig_version | sed -e 's/build number/UPGRADING FROM VERSION/' |
3759 | + |
3760 | +reboot=1 retry phablet_get_interface 4 |
3761 | +sleep 60 |
3762 | +retry phablet_get_ip 4 |
3763 | + |
3764 | +adb shell system-image-cli -v |
3765 | +adb wait-for-device |
3766 | +new_version=$(adb shell system-image-cli -b) |
3767 | +echo $new_version | sed -e 's/build number/UPGRADED TO VERSION/' |
3768 | + |
3769 | +if [ "$new_version" = "$orig_version" ] ; then |
3770 | + echo "UPGRADE FAILED" |
3771 | + exit 1 |
3772 | +fi |
3773 | |
3774 | === added directory 'tests/webbrowser-app-autopilot' |
3775 | === added file 'tests/webbrowser-app-autopilot/master.run' |
3776 | --- tests/webbrowser-app-autopilot/master.run 1970-01-01 00:00:00 +0000 |
3777 | +++ tests/webbrowser-app-autopilot/master.run 2013-09-05 19:05:51 +0000 |
3778 | @@ -0,0 +1,15 @@ |
3779 | +--- |
3780 | +testsuites: |
3781 | + - name: settle-before |
3782 | + fetch_method: dev |
3783 | + fetch_location: ../systemsettle |
3784 | + include_tests: |
3785 | + - systemsettle-before |
3786 | + - name: webbrowser-app-autopilot |
3787 | + fetch_method: dev |
3788 | + fetch_location: ./ |
3789 | + - name: settle-after |
3790 | + fetch_method: dev |
3791 | + fetch_location: ../systemsettle |
3792 | + include_tests: |
3793 | + - systemsettle-after |
3794 | |
3795 | === added file 'tests/webbrowser-app-autopilot/ts_control' |
3796 | --- tests/webbrowser-app-autopilot/ts_control 1970-01-01 00:00:00 +0000 |
3797 | +++ tests/webbrowser-app-autopilot/ts_control 2013-09-05 19:05:51 +0000 |
3798 | @@ -0,0 +1,1 @@ |
3799 | +ts_setup: PKGS=webbrowser-app-autopilot prepare-autopilot-test.sh |
3800 | |
3801 | === added file 'tests/webbrowser-app-autopilot/tslist.auto' |
3802 | --- tests/webbrowser-app-autopilot/tslist.auto 1970-01-01 00:00:00 +0000 |
3803 | +++ tests/webbrowser-app-autopilot/tslist.auto 2013-09-05 19:05:51 +0000 |
3804 | @@ -0,0 +1,4 @@ |
3805 | +- |
3806 | + discovery_cmd: autopilot-list webbrowser_app |
3807 | + test_cmd: autopilot-run webbrowser_app.tests.{} |
3808 | + |
3809 | |
3810 | === added directory 'utils' |
3811 | === added directory 'utils/host' |
3812 | === added file 'utils/host/adb-shell' |
3813 | --- utils/host/adb-shell 1970-01-01 00:00:00 +0000 |
3814 | +++ utils/host/adb-shell 2013-09-05 19:05:51 +0000 |
3815 | @@ -0,0 +1,20 @@ |
3816 | +#!/bin/bash |
3817 | + |
3818 | +# The "adb shell" command doesn't return an error if the command you execute |
3819 | +# resulted in an error. This is a wrapper to return the command's true return code. |
3820 | + |
3821 | +# NOTE: This script uses some specific bash'isms to keep things short and simple |
3822 | + |
3823 | +set -eu |
3824 | + |
3825 | +pat='ADB_RC=([[:digit:]]+)' |
3826 | + |
3827 | +{ |
3828 | + adb -s $ANDROID_SERIAL shell "$* ; echo ADB_RC=\$?" |
3829 | +} | while read line; do |
3830 | + echo $line |
3831 | + if [[ $line =~ $pat ]] ; then |
3832 | + rc=${BASH_REMATCH[1]} |
3833 | + exit $rc |
3834 | + fi |
3835 | +done |
3836 | |
3837 | === added file 'utils/host/autopilot-list' |
3838 | --- utils/host/autopilot-list 1970-01-01 00:00:00 +0000 |
3839 | +++ utils/host/autopilot-list 2013-09-05 19:05:51 +0000 |
3840 | @@ -0,0 +1,18 @@ |
3841 | +#!/bin/sh |
3842 | + |
3843 | +set -e |
3844 | + |
3845 | +app=$1 |
3846 | +pat=$app |
3847 | +rep=$app.tests. |
3848 | + |
3849 | +if [ -z "$app" ] ; then |
3850 | + echo "USAGE: $0 <app> [pattern] [replace]" |
3851 | + exit 1 |
3852 | +fi |
3853 | +[ -z "$2" ] || pat=$2 |
3854 | +[ -z "$3" ] || rep=$3 |
3855 | + |
3856 | +#NOTE we just use adb shell here, because we don't have to catch errors. the greps |
3857 | +# will work around that |
3858 | +adb shell sudo -i -u phablet bash -ic \"PYTHONPATH=/home/phablet/autopilot autopilot list $app\" | grep $pat | sed -e "s/^.*${rep}//" |
3859 | |
3860 | === added file 'utils/host/autopilot-run' |
3861 | --- utils/host/autopilot-run 1970-01-01 00:00:00 +0000 |
3862 | +++ utils/host/autopilot-run 2013-09-05 19:05:51 +0000 |
3863 | @@ -0,0 +1,3 @@ |
3864 | +#!/bin/sh |
3865 | + |
3866 | +adb-shell sudo -i -u phablet bash -ic \"PYTHONPATH=/home/phablet/autopilot autopilot run -v $*\" |
3867 | |
3868 | === added file 'utils/host/prepare-autopilot-test.sh' |
3869 | --- utils/host/prepare-autopilot-test.sh 1970-01-01 00:00:00 +0000 |
3870 | +++ utils/host/prepare-autopilot-test.sh 2013-09-05 19:05:51 +0000 |
3871 | @@ -0,0 +1,5 @@ |
3872 | +#!/bin/sh |
3873 | + |
3874 | +set -e |
3875 | + |
3876 | +adb-shell PKGS=\"$PKGS\" prepare-autopilot-test.sh |
3877 | |
3878 | === added directory 'utils/target' |
3879 | === added file 'utils/target/autopilot-list' |
3880 | --- utils/target/autopilot-list 1970-01-01 00:00:00 +0000 |
3881 | +++ utils/target/autopilot-list 2013-09-05 19:05:51 +0000 |
3882 | @@ -0,0 +1,13 @@ |
3883 | +#!/bin/sh |
3884 | + |
3885 | +app=$1 |
3886 | +pat=${2:-$app} |
3887 | +rep=${3:-$app.tests.} |
3888 | + |
3889 | +if [ -z "$app" ] ; then |
3890 | + echo "USAGE: $0 <app> [pattern] [replace]" |
3891 | + exit 1 |
3892 | +fi |
3893 | + |
3894 | +curdir=$(pwd) |
3895 | +sudo -i -u phablet bash -ic "PYTHONPATH=$curdir autopilot list $app" | grep $pat | sed -e "s/^.*${rep}//" |
3896 | |
3897 | === added file 'utils/target/autopilot-run' |
3898 | --- utils/target/autopilot-run 1970-01-01 00:00:00 +0000 |
3899 | +++ utils/target/autopilot-run 2013-09-05 19:05:51 +0000 |
3900 | @@ -0,0 +1,4 @@ |
3901 | +#!/bin/sh |
3902 | + |
3903 | +curdir=$(pwd) |
3904 | +sudo -i -u phablet bash -ic "PYTHONPATH=$curdir autopilot run -v $*" |
3905 | |
3906 | === added file 'utils/target/prepare-autopilot-test.sh' |
3907 | --- utils/target/prepare-autopilot-test.sh 1970-01-01 00:00:00 +0000 |
3908 | +++ utils/target/prepare-autopilot-test.sh 2013-09-05 19:05:51 +0000 |
3909 | @@ -0,0 +1,17 @@ |
3910 | +#!/bin/sh |
3911 | + |
3912 | +set -e |
3913 | + |
3914 | +#installs dependencies and unlocks screen so an autopilot test case can run |
3915 | + |
3916 | +if [ -n "$PKGS" ] ; then |
3917 | + MISSING=0 |
3918 | + dpkg -s $PKGS 2>/dev/null >/dev/null || MISSING=1 |
3919 | + if [ $MISSING -eq 1 ] ; then |
3920 | + apt-get install -yq --force-yes $PKGS |
3921 | + else |
3922 | + echo "setup not needed" |
3923 | + fi |
3924 | +fi |
3925 | +[ -z $NO_UNLOCK ] && unlock_screen.sh |
3926 | +exit 0 |
3927 | |
3928 | === added file 'utils/target/unlock_screen.py' |
3929 | --- utils/target/unlock_screen.py 1970-01-01 00:00:00 +0000 |
3930 | +++ utils/target/unlock_screen.py 2013-09-05 19:05:51 +0000 |
3931 | @@ -0,0 +1,87 @@ |
3932 | +#!/usr/bin/env python |
3933 | + |
3934 | +from autopilot import introspection |
3935 | +from autopilot.display import Display |
3936 | +from autopilot.input import Pointer, Touch |
3937 | +import os |
3938 | +import sys |
3939 | + |
3940 | + |
3941 | +def help(): |
3942 | + print "Usage:" |
3943 | + print "Run the script without any argument to unlock with assertion" |
3944 | + print "" |
3945 | + print "option -q:" |
3946 | + print "Execute with parameter -q to unlock the screen quickly without introspection" |
3947 | + |
3948 | + |
3949 | +def start_unity_in_testability(): |
3950 | + override_file = "~/.config/upstart/unity8.override" |
3951 | + |
3952 | + os.system('echo "exec unity8 -testability" > ~/.config/upstart/unity8.override') |
3953 | + |
3954 | + print "----------------------------------------------------------------------" |
3955 | + print "Stopping Unity" |
3956 | + os.system('/sbin/stop unity8') |
3957 | + print "Unity stopped" |
3958 | + |
3959 | + print "----------------------------------------------------------------------" |
3960 | + print "Starting Unity with testability" |
3961 | + os.system('/sbin/start unity8') |
3962 | + print "Unity started" |
3963 | + |
3964 | + print "----------------------------------------------------------------------" |
3965 | + if os.path.exists(override_file): |
3966 | + os.remove(override_file) |
3967 | + print "Cleaned up upstart override" |
3968 | + print "----------------------------------------------------------------------" |
3969 | + |
3970 | + print "Turning on the screen" |
3971 | + print "" |
3972 | + |
3973 | + |
3974 | +def unlock_screen(): |
3975 | + input_device = Touch.create() |
3976 | + pointing_device = Pointer(input_device) |
3977 | + conn = "com.canonical.Shell.BottomBarVisibilityCommunicator" |
3978 | + unity8 = introspection.get_proxy_object_for_existing_process(connection_name=conn) |
3979 | + greeter = unity8.select_single("Greeter") |
3980 | + x, y, w, h = greeter.globalRect |
3981 | + tx = x + w |
3982 | + ty = y + (h / 2) |
3983 | + |
3984 | + pointing_device.drag(tx, ty, tx / 2, ty) |
3985 | + try: |
3986 | + greeter.shown.wait_for(False) |
3987 | + except AssertionError: |
3988 | + print "----------------------------------------------------------------------" |
3989 | + print "THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE" |
3990 | + unlock_screen_blind(greeter) |
3991 | + |
3992 | + |
3993 | +def unlock_screen_blind(greeter=None): |
3994 | + input_device = Touch.create() |
3995 | + pointing_device = Pointer(input_device) |
3996 | + x, y, w, h = Display.create(preferred_backend='UPA').get_screen_geometry(0) |
3997 | + tx = x + w |
3998 | + ty = y + (h / 2) |
3999 | + |
4000 | + pointing_device.drag(tx, ty, tx / 2, ty) |
4001 | + if greeter is not None: |
4002 | + try: |
4003 | + greeter.shown.wait_for(False) |
4004 | + if greeter.shown is False: |
4005 | + print "" |
4006 | + print "THE SCREEN IS NOW UNLOCKED" |
4007 | + except AssertionError: |
4008 | + print "----------------------------------------------------------------------" |
4009 | + "THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN" |
4010 | + |
4011 | + |
4012 | +if len(sys.argv) >= 2 and sys.argv[1] == '-q': |
4013 | + unlock_screen_blind() |
4014 | +elif len(sys.argv) >= 2 and sys.argv[1] == '-h': |
4015 | + help() |
4016 | +else: |
4017 | + start_unity_in_testability() |
4018 | + unlock_screen() |
4019 | |
4020 | === added file 'utils/target/unlock_screen.sh' |
4021 | --- utils/target/unlock_screen.sh 1970-01-01 00:00:00 +0000 |
4022 | +++ utils/target/unlock_screen.sh 2013-09-05 19:05:51 +0000 |
4023 | @@ -0,0 +1,7 @@ |
4024 | +#!/bin/sh |
4025 | + |
4026 | +basedir=$(dirname $(readlink -f $0)) |
4027 | + |
4028 | +#temporary workaround for bug #1207386 |
4029 | +chmod 666 /dev/uinput |
4030 | +sudo -i -u phablet bash -ic "PYTHONPATH=$(pwd) ${basedir}/unlock_screen.py" |
run-touch- upgrade. sh should probably get moved from /tests to scripts/