OLD | NEW |
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 | |
10 import sys | 9 import sys |
11 import tempfile | 10 import tempfile |
12 | 11 |
13 from pylib import cmd_helper | 12 from pylib import cmd_helper |
14 from pylib import constants | 13 from pylib import constants |
15 from pylib import pexpect | 14 from pylib import pexpect |
16 from pylib.device import device_errors | 15 from pylib.device import device_errors |
17 from pylib.gtest import gtest_test_instance | 16 from pylib.gtest import gtest_test_instance |
18 from pylib.gtest.test_package import TestPackage | 17 from pylib.gtest.test_package import TestPackage |
19 | 18 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) | 112 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) |
114 device.PushChangedFiles([( | 113 device.PushChangedFiles([( |
115 sh_script_file.name, | 114 sh_script_file.name, |
116 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')]) | 115 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')]) |
117 logging.info('Conents of the test runner script: ') | 116 logging.info('Conents of the test runner script: ') |
118 for line in open(sh_script_file.name).readlines(): | 117 for line in open(sh_script_file.name).readlines(): |
119 logging.info(' ' + line.rstrip()) | 118 logging.info(' ' + line.rstrip()) |
120 | 119 |
121 #override | 120 #override |
122 def GetAllTests(self, device): | 121 def GetAllTests(self, device): |
123 lib_path = posixpath.join( | 122 cmd = '%s %s/%s --gtest_list_tests' % (self.tool.GetTestWrapper(), |
124 constants.TEST_EXECUTABLE_DIR, '%s_deps' % self.suite_name) | 123 constants.TEST_EXECUTABLE_DIR, self.suite_name) |
125 | 124 lib_path = '%s/%s_deps' % (constants.TEST_EXECUTABLE_DIR, self.suite_name) |
126 cmd = [] | 125 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( |
127 for wrapper in (device.GetDevicePieWrapper(), self.tool.GetTestWrapper()): | 126 cmd, lib_path=lib_path) |
128 if wrapper: | 127 if exit_code != 0: |
129 cmd.append(wrapper) | 128 raise Exception( |
130 cmd.extend([ | 129 'Failed to start binary:\n%s' % '\n'.join(output)) |
131 posixpath.join(constants.TEST_EXECUTABLE_DIR, self.suite_name), | |
132 '--gtest_list_tests']) | |
133 | |
134 output = device.RunShellCommand( | |
135 cmd, check_return=True, env={'LD_LIBRARY_PATH': lib_path}) | |
136 return gtest_test_instance.ParseGTestListTests(output) | 130 return gtest_test_instance.ParseGTestListTests(output) |
137 | 131 |
138 #override | 132 #override |
139 def SpawnTestProcess(self, device): | 133 def SpawnTestProcess(self, device): |
140 args = ['adb', '-s', str(device), 'shell', 'sh', | 134 args = ['adb', '-s', str(device), 'shell', 'sh', |
141 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh'] | 135 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh'] |
142 logging.info(args) | 136 logging.info(args) |
143 return pexpect.spawn(args[0], args[1:], logfile=sys.stdout) | 137 return pexpect.spawn(args[0], args[1:], logfile=sys.stdout) |
144 | 138 |
145 #override | 139 #override |
(...skipping 13 matching lines...) Expand all Loading... |
159 'stripped binary (%s, timestamp %d) older than ' | 153 'stripped binary (%s, timestamp %d) older than ' |
160 'source binary (%s, timestamp %d), build target %s' % | 154 'source binary (%s, timestamp %d), build target %s' % |
161 (target_name, target_mtime, self.suite_path, source_mtime, | 155 (target_name, target_mtime, self.suite_path, source_mtime, |
162 self.suite_name + '_stripped')) | 156 self.suite_name + '_stripped')) |
163 | 157 |
164 test_binary_path = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 158 test_binary_path = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
165 device.PushChangedFiles([(target_name, test_binary_path)]) | 159 device.PushChangedFiles([(target_name, test_binary_path)]) |
166 deps_path = self.suite_path + '_deps' | 160 deps_path = self.suite_path + '_deps' |
167 if os.path.isdir(deps_path): | 161 if os.path.isdir(deps_path): |
168 device.PushChangedFiles([(deps_path, test_binary_path + '_deps')]) | 162 device.PushChangedFiles([(deps_path, test_binary_path + '_deps')]) |
OLD | NEW |