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