| 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 sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 self.suite_path = os.path.join(constants.GetOutDirectory(), suite_name) | 30 self.suite_path = os.path.join(constants.GetOutDirectory(), suite_name) |
| 31 self._symbols_dir = os.path.join(constants.GetOutDirectory(), | 31 self._symbols_dir = os.path.join(constants.GetOutDirectory(), |
| 32 'lib.target') | 32 'lib.target') |
| 33 | 33 |
| 34 #override | 34 #override |
| 35 def GetGTestReturnCode(self, device): | 35 def GetGTestReturnCode(self, device): |
| 36 ret = None | 36 ret = None |
| 37 ret_code = 1 # Assume failure if we can't find it | 37 ret_code = 1 # Assume failure if we can't find it |
| 38 ret_code_file = tempfile.NamedTemporaryFile() | 38 ret_code_file = tempfile.NamedTemporaryFile() |
| 39 try: | 39 try: |
| 40 if not device.old_interface.Adb().Pull( | 40 if not device.PullFile( |
| 41 constants.TEST_EXECUTABLE_DIR + '/' + | 41 constants.TEST_EXECUTABLE_DIR + '/' + |
| 42 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE, | 42 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE, |
| 43 ret_code_file.name): | 43 ret_code_file.name): |
| 44 logging.critical('Unable to pull gtest ret val file %s', | 44 logging.critical('Unable to pull gtest ret val file %s', |
| 45 ret_code_file.name) | 45 ret_code_file.name) |
| 46 raise ValueError | 46 raise ValueError |
| 47 ret_code = file(ret_code_file.name).read() | 47 ret_code = file(ret_code_file.name).read() |
| 48 ret = int(ret_code) | 48 ret = int(ret_code) |
| 49 except ValueError: | 49 except ValueError: |
| 50 logging.critical('Error reading gtest ret val file %s [%s]', | 50 logging.critical('Error reading gtest ret val file %s [%s]', |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 '%s %s/%s --gtest_filter=%s %s\n' | 98 '%s %s/%s --gtest_filter=%s %s\n' |
| 99 'echo $? > %s' % | 99 'echo $? > %s' % |
| 100 (constants.TEST_EXECUTABLE_DIR, | 100 (constants.TEST_EXECUTABLE_DIR, |
| 101 self._AddNativeCoverageExports(device), | 101 self._AddNativeCoverageExports(device), |
| 102 tool_wrapper, constants.TEST_EXECUTABLE_DIR, | 102 tool_wrapper, constants.TEST_EXECUTABLE_DIR, |
| 103 self.suite_name, | 103 self.suite_name, |
| 104 test_filter, test_arguments, | 104 test_filter, test_arguments, |
| 105 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE)) | 105 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE)) |
| 106 sh_script_file.flush() | 106 sh_script_file.flush() |
| 107 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) | 107 cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name]) |
| 108 device.old_interface.PushIfNeeded( | 108 device.PushChangedFiles( |
| 109 sh_script_file.name, | 109 sh_script_file.name, |
| 110 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh') | 110 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh') |
| 111 logging.info('Conents of the test runner script: ') | 111 logging.info('Conents of the test runner script: ') |
| 112 for line in open(sh_script_file.name).readlines(): | 112 for line in open(sh_script_file.name).readlines(): |
| 113 logging.info(' ' + line.rstrip()) | 113 logging.info(' ' + line.rstrip()) |
| 114 | 114 |
| 115 #override | 115 #override |
| 116 def GetAllTests(self, device): | 116 def GetAllTests(self, device): |
| 117 all_tests = device.RunShellCommand( | 117 all_tests = device.RunShellCommand( |
| 118 '%s %s/%s --gtest_list_tests' % | 118 '%s %s/%s --gtest_list_tests' % |
| (...skipping 22 matching lines...) Expand all Loading... |
| 141 target_mtime = os.stat(target_name).st_mtime | 141 target_mtime = os.stat(target_name).st_mtime |
| 142 source_mtime = os.stat(self.suite_path).st_mtime | 142 source_mtime = os.stat(self.suite_path).st_mtime |
| 143 if target_mtime < source_mtime: | 143 if target_mtime < source_mtime: |
| 144 raise Exception( | 144 raise Exception( |
| 145 'stripped binary (%s, timestamp %d) older than ' | 145 'stripped binary (%s, timestamp %d) older than ' |
| 146 'source binary (%s, timestamp %d), build target %s' % | 146 'source binary (%s, timestamp %d), build target %s' % |
| 147 (target_name, target_mtime, self.suite_path, source_mtime, | 147 (target_name, target_mtime, self.suite_path, source_mtime, |
| 148 self.suite_name + '_stripped')) | 148 self.suite_name + '_stripped')) |
| 149 | 149 |
| 150 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 150 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
| 151 device.old_interface.PushIfNeeded(target_name, test_binary) | 151 device.PushChangedFiles(target_name, test_binary) |
| OLD | NEW |