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

Side by Side Diff: build/android/test_package_executable.py

Issue 10566028: Fix build/android/run_tests.sh (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
« no previous file with comments | « build/android/flag_changer.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 5
6 import logging 6 import logging
7 import os 7 import os
8 import pexpect 8 import pexpect
9 import shutil 9 import shutil
10 import sys 10 import sys
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 # This value is calculated in buildbot.sh and 66 # This value is calculated in buildbot.sh and
67 # depends on where the tree is built. 67 # depends on where the tree is built.
68 # Ex: /usr/local/google/code/chrome will become 68 # Ex: /usr/local/google/code/chrome will become
69 # /code/chrome if GCOV_PREFIX_STRIP=3 69 # /code/chrome if GCOV_PREFIX_STRIP=3
70 try: 70 try:
71 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] 71 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP']
72 except KeyError: 72 except KeyError:
73 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: ' 73 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: '
74 'No native coverage.') 74 'No native coverage.')
75 return '' 75 return ''
76 export_string = 'export GCOV_PREFIX="/data/local/gcov"\n' 76 export_string = 'export GCOV_PREFIX="/data/local/tmp/gcov"\n'
77 export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth 77 export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth
78 return export_string 78 return export_string
79 79
80 def GetAllTests(self): 80 def GetAllTests(self):
81 """Returns a list of all tests available in the test suite.""" 81 """Returns a list of all tests available in the test suite."""
82 all_tests = self.adb.RunShellCommand( 82 all_tests = self.adb.RunShellCommand(
83 '/data/local/%s --gtest_list_tests' % self.test_suite_basename) 83 '/data/local/tmp/%s --gtest_list_tests' % self.test_suite_basename)
84 return self._ParseGTestListTests(all_tests) 84 return self._ParseGTestListTests(all_tests)
85 85
86 def CreateTestRunnerScript(self, gtest_filter, test_arguments): 86 def CreateTestRunnerScript(self, gtest_filter, test_arguments):
87 """Creates a test runner script and pushes to the device. 87 """Creates a test runner script and pushes to the device.
88 88
89 Args: 89 Args:
90 gtest_filter: A gtest_filter flag. 90 gtest_filter: A gtest_filter flag.
91 test_arguments: Additional arguments to pass to the test binary. 91 test_arguments: Additional arguments to pass to the test binary.
92 """ 92 """
93 tool_wrapper = self.tool.GetTestWrapper() 93 tool_wrapper = self.tool.GetTestWrapper()
94 sh_script_file = tempfile.NamedTemporaryFile() 94 sh_script_file = tempfile.NamedTemporaryFile()
95 # We need to capture the exit status from the script since adb shell won't 95 # We need to capture the exit status from the script since adb shell won't
96 # propagate to us. 96 # propagate to us.
97 sh_script_file.write('cd /data/local\n' 97 sh_script_file.write('cd /data/local/tmp\n'
98 '%s' 98 '%s'
99 '%s /data/local/%s --gtest_filter=%s %s\n' 99 '%s /data/local/tmp/%s --gtest_filter=%s %s\n'
100 'echo $? > %s' % 100 'echo $? > %s' %
101 (self._AddNativeCoverageExports(), 101 (self._AddNativeCoverageExports(),
102 tool_wrapper, self.test_suite_basename, 102 tool_wrapper, self.test_suite_basename,
103 gtest_filter, test_arguments, 103 gtest_filter, test_arguments,
104 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE)) 104 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE))
105 sh_script_file.flush() 105 sh_script_file.flush()
106 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) 106 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name])
107 self.adb.PushIfNeeded(sh_script_file.name, 107 self.adb.PushIfNeeded(sh_script_file.name,
108 '/data/local/chrome_test_runner.sh') 108 '/data/local/tmp/chrome_test_runner.sh')
109 logging.info('Conents of the test runner script: ') 109 logging.info('Conents of the test runner script: ')
110 for line in open(sh_script_file.name).readlines(): 110 for line in open(sh_script_file.name).readlines():
111 logging.info(' ' + line.rstrip()) 111 logging.info(' ' + line.rstrip())
112 112
113 def RunTestsAndListResults(self): 113 def RunTestsAndListResults(self):
114 """Runs all the tests and checks for failures. 114 """Runs all the tests and checks for failures.
115 115
116 Returns: 116 Returns:
117 A TestResults object. 117 A TestResults object.
118 """ 118 """
119 args = ['adb', '-s', self.device, 'shell', 'sh', 119 args = ['adb', '-s', self.device, 'shell', 'sh',
120 '/data/local/chrome_test_runner.sh'] 120 '/data/local/tmp/chrome_test_runner.sh']
121 logging.info(args) 121 logging.info(args)
122 p = pexpect.spawn(args[0], args[1:], logfile=sys.stdout) 122 p = pexpect.spawn(args[0], args[1:], logfile=sys.stdout)
123 return self._WatchTestOutput(p) 123 return self._WatchTestOutput(p)
124 124
125 def StripAndCopyExecutable(self): 125 def StripAndCopyExecutable(self):
126 """Strips and copies the executable to the device.""" 126 """Strips and copies the executable to the device."""
127 if self.tool.NeedsDebugInfo(): 127 if self.tool.NeedsDebugInfo():
128 target_name = self.test_suite 128 target_name = self.test_suite
129 else: 129 else:
130 target_name = self.test_suite + '_' + self.device + '_stripped' 130 target_name = self.test_suite + '_' + self.device + '_stripped'
(...skipping 11 matching lines...) Expand all
142 logging.info('Did not find up-to-date stripped binary. Generating a ' 142 logging.info('Did not find up-to-date stripped binary. Generating a '
143 'new one (%s).' % target_name) 143 'new one (%s).' % target_name)
144 # Whenever we generate a stripped binary, copy to the symbols dir. If we 144 # Whenever we generate a stripped binary, copy to the symbols dir. If we
145 # aren't stripping a new binary, assume it's there. 145 # aren't stripping a new binary, assume it's there.
146 if self.symbols_dir: 146 if self.symbols_dir:
147 if not os.path.exists(self.symbols_dir): 147 if not os.path.exists(self.symbols_dir):
148 os.makedirs(self.symbols_dir) 148 os.makedirs(self.symbols_dir)
149 shutil.copy(self.test_suite, self.symbols_dir) 149 shutil.copy(self.test_suite, self.symbols_dir)
150 strip = os.environ['STRIP'] 150 strip = os.environ['STRIP']
151 cmd_helper.RunCmd([strip, self.test_suite, '-o', target_name]) 151 cmd_helper.RunCmd([strip, self.test_suite, '-o', target_name])
152 test_binary = '/data/local/' + self.test_suite_basename 152 test_binary = '/data/local/tmp/' + self.test_suite_basename
153 self.adb.PushIfNeeded(target_name, test_binary) 153 self.adb.PushIfNeeded(target_name, test_binary)
154 154
155 if self.test_suite_basename == 'ui_unittests': 155 if self.test_suite_basename == 'ui_unittests':
156 self.adb.PushIfNeeded(self.test_suite_dirname + '/chrome.pak', 156 self.adb.PushIfNeeded(self.test_suite_dirname + '/chrome.pak',
157 '/data/local/tmp/paks/chrome.pak') 157 '/data/local/tmp/paks/chrome.pak')
158 self.adb.PushIfNeeded(self.test_suite_dirname + '/locales/en-US.pak', 158 self.adb.PushIfNeeded(self.test_suite_dirname + '/locales/en-US.pak',
159 '/data/local/tmp/paks/en-US.pak') 159 '/data/local/tmp/paks/en-US.pak')
160 160
161 def _GetTestSuiteBaseName(self): 161 def _GetTestSuiteBaseName(self):
162 """Returns the base name of the test suite.""" 162 """Returns the base name of the test suite."""
163 return os.path.basename(self.test_suite) 163 return os.path.basename(self.test_suite)
OLDNEW
« no previous file with comments | « build/android/flag_changer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698