Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 2043803003: 👔 Reland #2: Move side-loaded test data /sdcard -> /sdcard/gtestdata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase atop https://codereview.chromium.org/2041723006 Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 re 8 import re
8 import time 9 import time
9 10
10 from devil.android import device_errors 11 from devil.android import device_errors
11 from devil.android import flag_changer 12 from devil.android import flag_changer
12 from devil.utils import reraiser_thread 13 from devil.utils import reraiser_thread
13 from pylib import valgrind_tools 14 from pylib import valgrind_tools
14 from pylib.base import base_test_result 15 from pylib.base import base_test_result
15 from pylib.local.device import local_device_test_run 16 from pylib.local.device import local_device_test_run
16 17
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 class LocalDeviceInstrumentationTestRun( 52 class LocalDeviceInstrumentationTestRun(
52 local_device_test_run.LocalDeviceTestRun): 53 local_device_test_run.LocalDeviceTestRun):
53 def __init__(self, env, test_instance): 54 def __init__(self, env, test_instance):
54 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) 55 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance)
55 self._flag_changers = {} 56 self._flag_changers = {}
56 57
57 def TestPackage(self): 58 def TestPackage(self):
58 return self._test_instance.suite 59 return self._test_instance.suite
59 60
60 def SetUp(self): 61 def SetUp(self):
61 def substitute_external_storage(d, external_storage): 62 def substitute_device_root(d, device_root):
62 if not d: 63 if not d:
63 return external_storage 64 return device_root
64 elif isinstance(d, list): 65 elif isinstance(d, list):
65 return '/'.join(p if p else external_storage for p in d) 66 return posixpath.join(p if p else device_root for p in d)
66 else: 67 else:
67 return d 68 return d
68 69
69 @local_device_test_run.handle_shard_failures_with( 70 @local_device_test_run.handle_shard_failures_with(
70 self._env.BlacklistDevice) 71 self._env.BlacklistDevice)
71 def individual_device_set_up(dev, host_device_tuples): 72 def individual_device_set_up(dev, host_device_tuples):
72 def install_apk(): 73 def install_apk():
73 if self._test_instance.apk_under_test: 74 if self._test_instance.apk_under_test:
74 if self._test_instance.apk_under_test_incremental_install_script: 75 if self._test_instance.apk_under_test_incremental_install_script:
75 local_device_test_run.IncrementalInstall( 76 local_device_test_run.IncrementalInstall(
(...skipping 23 matching lines...) Expand all
99 if not self._test_instance.package_info: 100 if not self._test_instance.package_info:
100 logging.error("Couldn't set debug app: no package info") 101 logging.error("Couldn't set debug app: no package info")
101 elif not self._test_instance.package_info.package: 102 elif not self._test_instance.package_info.package:
102 logging.error("Couldn't set debug app: no package defined") 103 logging.error("Couldn't set debug app: no package defined")
103 else: 104 else:
104 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', 105 dev.RunShellCommand(['am', 'set-debug-app', '--persistent',
105 self._test_instance.package_info.package], 106 self._test_instance.package_info.package],
106 check_return=True) 107 check_return=True)
107 108
108 def push_test_data(): 109 def push_test_data():
109 external_storage = dev.GetExternalStoragePath() 110 device_root = posixpath.join(dev.GetExternalStoragePath(),
111 'chromium_tests_root')
110 host_device_tuples_substituted = [ 112 host_device_tuples_substituted = [
111 (h, substitute_external_storage(d, external_storage)) 113 (h, substitute_device_root(d, device_root))
112 for h, d in host_device_tuples] 114 for h, d in host_device_tuples]
113 logging.info('instrumentation data deps:') 115 logging.info('instrumentation data deps:')
114 for h, d in host_device_tuples_substituted: 116 for h, d in host_device_tuples_substituted:
115 logging.info('%r -> %r', h, d) 117 logging.info('%r -> %r', h, d)
116 dev.PushChangedFiles(host_device_tuples_substituted) 118 dev.PushChangedFiles(host_device_tuples_substituted,
119 delete_device_stale=True)
120 if not host_device_tuples_substituted:
121 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True)
122 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True)
117 123
118 def create_flag_changer(): 124 def create_flag_changer():
119 if self._test_instance.flags: 125 if self._test_instance.flags:
120 if not self._test_instance.package_info: 126 if not self._test_instance.package_info:
121 logging.error("Couldn't set flags: no package info") 127 logging.error("Couldn't set flags: no package info")
122 elif not self._test_instance.package_info.cmdline_file: 128 elif not self._test_instance.package_info.cmdline_file:
123 logging.error("Couldn't set flags: no cmdline_file") 129 logging.error("Couldn't set flags: no cmdline_file")
124 else: 130 else:
125 self._CreateFlagChangerIfNeeded(dev) 131 self._CreateFlagChangerIfNeeded(dev)
126 logging.debug('Attempting to set flags: %r', 132 logging.debug('Attempting to set flags: %r',
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 timeout = v 349 timeout = v
344 break 350 break
345 else: 351 else:
346 logging.warning('Using default 1 minute timeout for %s', test_name) 352 logging.warning('Using default 1 minute timeout for %s', test_name)
347 timeout = 60 353 timeout = 60
348 354
349 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 355 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
350 356
351 return timeout 357 return timeout
352 358
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698