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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 local_device_test_run.LocalDeviceTestRun): | 58 local_device_test_run.LocalDeviceTestRun): |
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 def TestPackage(self): | 63 def TestPackage(self): |
64 return self._test_instance.suite | 64 return self._test_instance.suite |
65 | 65 |
66 #override | 66 #override |
67 def SetUp(self): | 67 def SetUp(self): |
68 def substitute_device_root(d, device_root): | |
69 if not d: | |
70 return device_root | |
71 elif isinstance(d, list): | |
72 return posixpath.join(*(p if p else device_root for p in d)) | |
73 else: | |
74 return d | |
75 | |
76 @local_device_environment.handle_shard_failures_with( | 68 @local_device_environment.handle_shard_failures_with( |
77 self._env.BlacklistDevice) | 69 self._env.BlacklistDevice) |
78 def individual_device_set_up(dev, host_device_tuples): | 70 def individual_device_set_up(dev, host_device_tuples): |
79 def install_apk(): | 71 def install_apk(): |
80 if self._test_instance.apk_under_test: | 72 if self._test_instance.apk_under_test: |
81 if self._test_instance.apk_under_test_incremental_install_script: | 73 if self._test_instance.apk_under_test_incremental_install_script: |
82 local_device_test_run.IncrementalInstall( | 74 local_device_test_run.IncrementalInstall( |
83 dev, | 75 dev, |
84 self._test_instance.apk_under_test, | 76 self._test_instance.apk_under_test, |
85 self._test_instance.apk_under_test_incremental_install_script) | 77 self._test_instance.apk_under_test_incremental_install_script) |
(...skipping 23 matching lines...) Expand all Loading... |
109 logging.error("Couldn't set debug app: no package defined") | 101 logging.error("Couldn't set debug app: no package defined") |
110 else: | 102 else: |
111 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', | 103 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', |
112 self._test_instance.package_info.package], | 104 self._test_instance.package_info.package], |
113 check_return=True) | 105 check_return=True) |
114 | 106 |
115 def push_test_data(): | 107 def push_test_data(): |
116 device_root = posixpath.join(dev.GetExternalStoragePath(), | 108 device_root = posixpath.join(dev.GetExternalStoragePath(), |
117 'chromium_tests_root') | 109 'chromium_tests_root') |
118 host_device_tuples_substituted = [ | 110 host_device_tuples_substituted = [ |
119 (h, substitute_device_root(d, device_root)) | 111 (h, local_device_test_run.SubstituteDeviceRoot(d, device_root)) |
120 for h, d in host_device_tuples] | 112 for h, d in host_device_tuples] |
121 logging.info('instrumentation data deps:') | 113 logging.info('instrumentation data deps:') |
122 for h, d in host_device_tuples_substituted: | 114 for h, d in host_device_tuples_substituted: |
123 logging.info('%r -> %r', h, d) | 115 logging.info('%r -> %r', h, d) |
124 dev.PushChangedFiles(host_device_tuples_substituted, | 116 dev.PushChangedFiles(host_device_tuples_substituted, |
125 delete_device_stale=True) | 117 delete_device_stale=True) |
126 if not host_device_tuples_substituted: | 118 if not host_device_tuples_substituted: |
127 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) | 119 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) |
128 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) | 120 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) |
129 | 121 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 timeout = v | 365 timeout = v |
374 break | 366 break |
375 else: | 367 else: |
376 logging.warning('Using default 1 minute timeout for %s', test_name) | 368 logging.warning('Using default 1 minute timeout for %s', test_name) |
377 timeout = 60 | 369 timeout = 60 |
378 | 370 |
379 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 371 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
380 | 372 |
381 return timeout | 373 return timeout |
382 | 374 |
OLD | NEW |