OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import posixpath | 7 import posixpath |
8 import re | 8 import re |
9 import time | 9 import time |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 def __init__(self, env, test_instance): | 59 def __init__(self, env, test_instance): |
60 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) | 60 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) |
61 self._flag_changers = {} | 61 self._flag_changers = {} |
62 | 62 |
63 #override | 63 #override |
64 def TestPackage(self): | 64 def TestPackage(self): |
65 return self._test_instance.suite | 65 return self._test_instance.suite |
66 | 66 |
67 #override | 67 #override |
68 def SetUp(self): | 68 def SetUp(self): |
69 def substitute_device_root(d, device_root): | |
70 if not d: | |
71 return device_root | |
72 elif isinstance(d, list): | |
73 return posixpath.join(*(p if p else device_root for p in d)) | |
74 else: | |
75 return d | |
76 | |
77 @local_device_environment.handle_shard_failures_with( | 69 @local_device_environment.handle_shard_failures_with( |
78 self._env.BlacklistDevice) | 70 self._env.BlacklistDevice) |
79 def individual_device_set_up(dev, host_device_tuples): | 71 def individual_device_set_up(dev, host_device_tuples): |
80 def install_apk(): | 72 def install_apk(): |
81 if self._test_instance.apk_under_test: | 73 if self._test_instance.apk_under_test: |
82 if self._test_instance.apk_under_test_incremental_install_script: | 74 if self._test_instance.apk_under_test_incremental_install_script: |
83 local_device_test_run.IncrementalInstall( | 75 local_device_test_run.IncrementalInstall( |
84 dev, | 76 dev, |
85 self._test_instance.apk_under_test, | 77 self._test_instance.apk_under_test, |
86 self._test_instance.apk_under_test_incremental_install_script) | 78 self._test_instance.apk_under_test_incremental_install_script) |
(...skipping 23 matching lines...) Expand all Loading... |
110 logging.error("Couldn't set debug app: no package defined") | 102 logging.error("Couldn't set debug app: no package defined") |
111 else: | 103 else: |
112 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', | 104 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', |
113 self._test_instance.package_info.package], | 105 self._test_instance.package_info.package], |
114 check_return=True) | 106 check_return=True) |
115 | 107 |
116 def push_test_data(): | 108 def push_test_data(): |
117 device_root = posixpath.join(dev.GetExternalStoragePath(), | 109 device_root = posixpath.join(dev.GetExternalStoragePath(), |
118 'chromium_tests_root') | 110 'chromium_tests_root') |
119 host_device_tuples_substituted = [ | 111 host_device_tuples_substituted = [ |
120 (h, substitute_device_root(d, device_root)) | 112 (h, local_device_test_run.SubstituteDeviceRoot(d, device_root)) |
121 for h, d in host_device_tuples] | 113 for h, d in host_device_tuples] |
122 logging.info('instrumentation data deps:') | 114 logging.info('instrumentation data deps:') |
123 for h, d in host_device_tuples_substituted: | 115 for h, d in host_device_tuples_substituted: |
124 logging.info('%r -> %r', h, d) | 116 logging.info('%r -> %r', h, d) |
125 dev.PushChangedFiles(host_device_tuples_substituted, | 117 dev.PushChangedFiles(host_device_tuples_substituted, |
126 delete_device_stale=True) | 118 delete_device_stale=True) |
127 if not host_device_tuples_substituted: | 119 if not host_device_tuples_substituted: |
128 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) | 120 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) |
129 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) | 121 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) |
130 | 122 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 timeout = v | 366 timeout = v |
375 break | 367 break |
376 else: | 368 else: |
377 logging.warning('Using default 1 minute timeout for %s', test_name) | 369 logging.warning('Using default 1 minute timeout for %s', test_name) |
378 timeout = 60 | 370 timeout = 60 |
379 | 371 |
380 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 372 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
381 | 373 |
382 return timeout | 374 return timeout |
383 | 375 |
OLD | NEW |