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

Side by Side Diff: build/android/pylib/gtest/test_package_exe.py

Issue 1108173002: Roll //build, //native_client, and a few more targets of opportunity. Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Test fix Created 5 years, 8 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/pylib/gtest/test_package_apk.py ('k') | build/android/pylib/gtest/test_runner.py » ('j') | 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 """Defines TestPackageExecutable to help run stand-alone executables.""" 5 """Defines TestPackageExecutable to help run stand-alone executables."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import posixpath
9 import sys 10 import sys
10 import tempfile 11 import tempfile
11 12
12 from pylib import cmd_helper 13 from pylib import cmd_helper
13 from pylib import constants 14 from pylib import constants
14 from pylib import pexpect 15 from pylib import pexpect
15 from pylib.device import device_errors 16 from pylib.device import device_errors
16 from pylib.gtest import gtest_test_instance 17 from pylib.gtest import gtest_test_instance
17 from pylib.gtest.test_package import TestPackage 18 from pylib.gtest.test_package import TestPackage
18 19
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 except KeyError: 72 except KeyError:
72 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: ' 73 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: '
73 'No native coverage.') 74 'No native coverage.')
74 return '' 75 return ''
75 except device_errors.CommandFailedError: 76 except device_errors.CommandFailedError:
76 logging.info('No external storage found: No native coverage.') 77 logging.info('No external storage found: No native coverage.')
77 return '' 78 return ''
78 79
79 #override 80 #override
80 def ClearApplicationState(self, device): 81 def ClearApplicationState(self, device):
81 try: 82 device.KillAll(self.suite_name, blocking=True, timeout=30, quiet=True)
82 # We don't expect the executable to be running, so we don't attempt
83 # to retry on failure.
84 device.KillAll(self.suite_name, blocking=True, timeout=30, retries=0)
85 except device_errors.CommandFailedError:
86 # KillAll raises an exception if it can't find a process with the given
87 # name. We only care that there is no process with the given name, so
88 # we can safely eat the exception.
89 pass
90 83
91 #override 84 #override
92 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): 85 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments):
93 tool_wrapper = self.tool.GetTestWrapper() 86 tool_wrapper = self.tool.GetTestWrapper()
94 sh_script_file = tempfile.NamedTemporaryFile() 87 sh_script_file = tempfile.NamedTemporaryFile()
95 # We need to capture the exit status from the script since adb shell won't 88 # We need to capture the exit status from the script since adb shell won't
96 # propagate to us. 89 # propagate to us.
97 sh_script_file.write( 90 sh_script_file.write(
98 'cd %s\n' 91 'cd %s\n'
99 '%s' 92 '%s'
(...skipping 12 matching lines...) Expand all
112 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) 105 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name])
113 device.PushChangedFiles([( 106 device.PushChangedFiles([(
114 sh_script_file.name, 107 sh_script_file.name,
115 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')]) 108 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')])
116 logging.info('Conents of the test runner script: ') 109 logging.info('Conents of the test runner script: ')
117 for line in open(sh_script_file.name).readlines(): 110 for line in open(sh_script_file.name).readlines():
118 logging.info(' ' + line.rstrip()) 111 logging.info(' ' + line.rstrip())
119 112
120 #override 113 #override
121 def GetAllTests(self, device): 114 def GetAllTests(self, device):
122 cmd = '%s %s/%s --gtest_list_tests' % (self.tool.GetTestWrapper(), 115 lib_path = posixpath.join(
123 constants.TEST_EXECUTABLE_DIR, self.suite_name) 116 constants.TEST_EXECUTABLE_DIR, '%s_deps' % self.suite_name)
124 lib_path = '%s/%s_deps' % (constants.TEST_EXECUTABLE_DIR, self.suite_name) 117
125 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( 118 cmd = []
126 cmd, lib_path=lib_path) 119 for wrapper in (device.GetDevicePieWrapper(), self.tool.GetTestWrapper()):
127 if exit_code != 0: 120 if wrapper:
128 raise Exception( 121 cmd.append(wrapper)
129 'Failed to start binary:\n%s' % '\n'.join(output)) 122 cmd.extend([
123 posixpath.join(constants.TEST_EXECUTABLE_DIR, self.suite_name),
124 '--gtest_list_tests'])
125
126 output = device.RunShellCommand(
127 cmd, check_return=True, env={'LD_LIBRARY_PATH': lib_path})
130 return gtest_test_instance.ParseGTestListTests(output) 128 return gtest_test_instance.ParseGTestListTests(output)
131 129
132 #override 130 #override
133 def SpawnTestProcess(self, device): 131 def SpawnTestProcess(self, device):
134 args = ['adb', '-s', str(device), 'shell', 'sh', 132 args = ['adb', '-s', str(device), 'shell', 'sh',
135 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh'] 133 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh']
136 logging.info(args) 134 logging.info(args)
137 return pexpect.spawn(args[0], args[1:], logfile=sys.stdout) 135 return pexpect.spawn(args[0], args[1:], logfile=sys.stdout)
138 136
139 #override 137 #override
(...skipping 13 matching lines...) Expand all
153 'stripped binary (%s, timestamp %d) older than ' 151 'stripped binary (%s, timestamp %d) older than '
154 'source binary (%s, timestamp %d), build target %s' % 152 'source binary (%s, timestamp %d), build target %s' %
155 (target_name, target_mtime, self.suite_path, source_mtime, 153 (target_name, target_mtime, self.suite_path, source_mtime,
156 self.suite_name + '_stripped')) 154 self.suite_name + '_stripped'))
157 155
158 test_binary_path = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name 156 test_binary_path = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name
159 device.PushChangedFiles([(target_name, test_binary_path)]) 157 device.PushChangedFiles([(target_name, test_binary_path)])
160 deps_path = self.suite_path + '_deps' 158 deps_path = self.suite_path + '_deps'
161 if os.path.isdir(deps_path): 159 if os.path.isdir(deps_path):
162 device.PushChangedFiles([(deps_path, test_binary_path + '_deps')]) 160 device.PushChangedFiles([(deps_path, test_binary_path + '_deps')])
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package_apk.py ('k') | build/android/pylib/gtest/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698