| 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 |
| 11 | 11 |
| 12 from pylib import cmd_helper | 12 from pylib import cmd_helper |
| 13 from pylib import constants | 13 from pylib import constants |
| 14 from pylib import pexpect | 14 from pylib import pexpect |
| 15 from pylib.device import device_errors | 15 from pylib.device import device_errors |
| 16 from pylib.gtest import gtest_test_instance |
| 16 from pylib.gtest.test_package import TestPackage | 17 from pylib.gtest.test_package import TestPackage |
| 17 | 18 |
| 18 | 19 |
| 19 class TestPackageExecutable(TestPackage): | 20 class TestPackageExecutable(TestPackage): |
| 20 """A helper class for running stand-alone executables.""" | 21 """A helper class for running stand-alone executables.""" |
| 21 | 22 |
| 22 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' | 23 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' |
| 23 | 24 |
| 24 def __init__(self, suite_name): | 25 def __init__(self, suite_name): |
| 25 """ | 26 """ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 #override | 120 #override |
| 120 def GetAllTests(self, device): | 121 def GetAllTests(self, device): |
| 121 cmd = '%s %s/%s --gtest_list_tests' % (self.tool.GetTestWrapper(), | 122 cmd = '%s %s/%s --gtest_list_tests' % (self.tool.GetTestWrapper(), |
| 122 constants.TEST_EXECUTABLE_DIR, self.suite_name) | 123 constants.TEST_EXECUTABLE_DIR, self.suite_name) |
| 123 lib_path = '%s/%s_deps' % (constants.TEST_EXECUTABLE_DIR, self.suite_name) | 124 lib_path = '%s/%s_deps' % (constants.TEST_EXECUTABLE_DIR, self.suite_name) |
| 124 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( | 125 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( |
| 125 cmd, lib_path=lib_path) | 126 cmd, lib_path=lib_path) |
| 126 if exit_code != 0: | 127 if exit_code != 0: |
| 127 raise Exception( | 128 raise Exception( |
| 128 'Failed to start binary:\n%s' % '\n'.join(output)) | 129 'Failed to start binary:\n%s' % '\n'.join(output)) |
| 129 return self._ParseGTestListTests(output) | 130 return gtest_test_instance.ParseGTestListTests(output) |
| 130 | 131 |
| 131 #override | 132 #override |
| 132 def SpawnTestProcess(self, device): | 133 def SpawnTestProcess(self, device): |
| 133 args = ['adb', '-s', str(device), 'shell', 'sh', | 134 args = ['adb', '-s', str(device), 'shell', 'sh', |
| 134 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh'] | 135 constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh'] |
| 135 logging.info(args) | 136 logging.info(args) |
| 136 return pexpect.spawn(args[0], args[1:], logfile=sys.stdout) | 137 return pexpect.spawn(args[0], args[1:], logfile=sys.stdout) |
| 137 | 138 |
| 138 #override | 139 #override |
| 139 def Install(self, device): | 140 def Install(self, device): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 152 'stripped binary (%s, timestamp %d) older than ' | 153 'stripped binary (%s, timestamp %d) older than ' |
| 153 'source binary (%s, timestamp %d), build target %s' % | 154 'source binary (%s, timestamp %d), build target %s' % |
| 154 (target_name, target_mtime, self.suite_path, source_mtime, | 155 (target_name, target_mtime, self.suite_path, source_mtime, |
| 155 self.suite_name + '_stripped')) | 156 self.suite_name + '_stripped')) |
| 156 | 157 |
| 157 test_binary_path = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 158 test_binary_path = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
| 158 device.PushChangedFiles([(target_name, test_binary_path)]) | 159 device.PushChangedFiles([(target_name, test_binary_path)]) |
| 159 deps_path = self.suite_path + '_deps' | 160 deps_path = self.suite_path + '_deps' |
| 160 if os.path.isdir(deps_path): | 161 if os.path.isdir(deps_path): |
| 161 device.PushChangedFiles([(deps_path, test_binary_path + '_deps')]) | 162 device.PushChangedFiles([(deps_path, test_binary_path + '_deps')]) |
| OLD | NEW |