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 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import shutil | 8 import shutil |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
11 | 11 |
12 import cmd_helper | 12 import cmd_helper |
13 import constants | 13 import constants |
14 from test_package import TestPackage | 14 from test_package import TestPackage |
15 from pylib import pexpect | 15 from pylib import pexpect |
16 | 16 |
17 | 17 |
18 class TestPackageExecutable(TestPackage): | 18 class TestPackageExecutable(TestPackage): |
19 """A helper class for running stand-alone executables.""" | 19 """A helper class for running stand-alone executables.""" |
20 | 20 |
21 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' | 21 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' |
22 | 22 |
23 def __init__(self, adb, device, test_suite, timeout, | 23 def __init__(self, adb, device, test_suite, timeout, |
24 performance_test, cleanup_test_files, tool, dump_debug_info, | 24 cleanup_test_files, tool, dump_debug_info, |
25 symbols_dir=None): | 25 symbols_dir=None): |
26 """ | 26 """ |
27 Args: | 27 Args: |
28 adb: ADB interface the tests are using. | 28 adb: ADB interface the tests are using. |
29 device: Device to run the tests. | 29 device: Device to run the tests. |
30 test_suite: A specific test suite to run, empty to run all. | 30 test_suite: A specific test suite to run, empty to run all. |
31 timeout: Timeout for each test. | 31 timeout: Timeout for each test. |
32 performance_test: Whether or not performance test(s). | |
33 cleanup_test_files: Whether or not to cleanup test files on device. | 32 cleanup_test_files: Whether or not to cleanup test files on device. |
34 tool: Name of the Valgrind tool. | 33 tool: Name of the Valgrind tool. |
35 dump_debug_info: A debug_info object. | 34 dump_debug_info: A debug_info object. |
36 symbols_dir: Directory to put the stripped binaries. | 35 symbols_dir: Directory to put the stripped binaries. |
37 """ | 36 """ |
38 TestPackage.__init__(self, adb, device, test_suite, timeout, | 37 TestPackage.__init__(self, adb, device, test_suite, timeout, |
39 performance_test, cleanup_test_files, | 38 cleanup_test_files, tool, dump_debug_info) |
40 tool, dump_debug_info) | |
41 self.symbols_dir = symbols_dir | 39 self.symbols_dir = symbols_dir |
42 | 40 |
43 def _GetGTestReturnCode(self): | 41 def _GetGTestReturnCode(self): |
44 ret = None | 42 ret = None |
45 ret_code = 1 # Assume failure if we can't find it | 43 ret_code = 1 # Assume failure if we can't find it |
46 ret_code_file = tempfile.NamedTemporaryFile() | 44 ret_code_file = tempfile.NamedTemporaryFile() |
47 try: | 45 try: |
48 if not self.adb.Adb().Pull( | 46 if not self.adb.Adb().Pull( |
49 constants.TEST_EXECUTABLE_DIR + '/' + | 47 constants.TEST_EXECUTABLE_DIR + '/' + |
50 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE, | 48 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 os.makedirs(self.symbols_dir) | 154 os.makedirs(self.symbols_dir) |
157 shutil.copy(self.test_suite, self.symbols_dir) | 155 shutil.copy(self.test_suite, self.symbols_dir) |
158 strip = os.environ['STRIP'] | 156 strip = os.environ['STRIP'] |
159 cmd_helper.RunCmd([strip, self.test_suite, '-o', target_name]) | 157 cmd_helper.RunCmd([strip, self.test_suite, '-o', target_name]) |
160 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.test_suite_basename | 158 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.test_suite_basename |
161 self.adb.PushIfNeeded(target_name, test_binary) | 159 self.adb.PushIfNeeded(target_name, test_binary) |
162 | 160 |
163 def _GetTestSuiteBaseName(self): | 161 def _GetTestSuiteBaseName(self): |
164 """Returns the base name of the test suite.""" | 162 """Returns the base name of the test suite.""" |
165 return os.path.basename(self.test_suite) | 163 return os.path.basename(self.test_suite) |
OLD | NEW |