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 shutil | 9 import shutil |
10 import sys | 10 import sys |
11 import tempfile | 11 import tempfile |
12 | 12 |
13 from pylib import cmd_helper | 13 from pylib import cmd_helper |
14 from pylib import constants | 14 from pylib import constants |
15 from pylib import pexpect | 15 from pylib import pexpect |
16 | 16 |
17 from test_package import TestPackage | 17 from test_package import TestPackage |
18 | 18 |
19 | 19 |
20 class TestPackageExecutable(TestPackage): | 20 class TestPackageExecutable(TestPackage): |
21 """A helper class for running stand-alone executables.""" | 21 """A helper class for running stand-alone executables.""" |
22 | 22 |
23 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' | 23 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' |
24 | 24 |
25 def __init__(self, suite_name, build_type): | 25 def __init__(self, suite_name): |
26 """ | 26 """ |
27 Args: | 27 Args: |
28 suite_name: Name of the test suite (e.g. base_unittests). | 28 suite_name: Name of the test suite (e.g. base_unittests). |
29 build_type: 'Release' or 'Debug'. | |
30 """ | 29 """ |
31 TestPackage.__init__(self, suite_name) | 30 TestPackage.__init__(self, suite_name) |
32 product_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) | 31 product_dir = os.path.join(cmd_helper.OutDirectory.get(), |
| 32 constants.GetBuildType()) |
33 self.suite_path = os.path.join(product_dir, suite_name) | 33 self.suite_path = os.path.join(product_dir, suite_name) |
34 self._symbols_dir = os.path.join(product_dir, 'lib.target') | 34 self._symbols_dir = os.path.join(product_dir, 'lib.target') |
35 | 35 |
36 #override | 36 #override |
37 def GetGTestReturnCode(self, adb): | 37 def GetGTestReturnCode(self, adb): |
38 ret = None | 38 ret = None |
39 ret_code = 1 # Assume failure if we can't find it | 39 ret_code = 1 # Assume failure if we can't find it |
40 ret_code_file = tempfile.NamedTemporaryFile() | 40 ret_code_file = tempfile.NamedTemporaryFile() |
41 try: | 41 try: |
42 if not adb.Adb().Pull( | 42 if not adb.Adb().Pull( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 'new one (%s).' % target_name) | 139 'new one (%s).' % target_name) |
140 # Whenever we generate a stripped binary, copy to the symbols dir. If we | 140 # Whenever we generate a stripped binary, copy to the symbols dir. If we |
141 # aren't stripping a new binary, assume it's there. | 141 # aren't stripping a new binary, assume it's there. |
142 if not os.path.exists(self._symbols_dir): | 142 if not os.path.exists(self._symbols_dir): |
143 os.makedirs(self._symbols_dir) | 143 os.makedirs(self._symbols_dir) |
144 shutil.copy(self.suite_path, self._symbols_dir) | 144 shutil.copy(self.suite_path, self._symbols_dir) |
145 strip = os.environ['STRIP'] | 145 strip = os.environ['STRIP'] |
146 cmd_helper.RunCmd([strip, self.suite_path, '-o', target_name]) | 146 cmd_helper.RunCmd([strip, self.suite_path, '-o', target_name]) |
147 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 147 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
148 adb.PushIfNeeded(target_name, test_binary) | 148 adb.PushIfNeeded(target_name, test_binary) |
OLD | NEW |