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): | 25 def __init__(self, suite_name): |
26 """ | 26 """ |
27 Args: | 27 Args: |
(...skipping 18 matching lines...) Expand all Loading... |
46 ret_code_file.name) | 46 ret_code_file.name) |
47 raise ValueError | 47 raise ValueError |
48 ret_code = file(ret_code_file.name).read() | 48 ret_code = file(ret_code_file.name).read() |
49 ret = int(ret_code) | 49 ret = int(ret_code) |
50 except ValueError: | 50 except ValueError: |
51 logging.critical('Error reading gtest ret val file %s [%s]', | 51 logging.critical('Error reading gtest ret val file %s [%s]', |
52 ret_code_file.name, ret_code) | 52 ret_code_file.name, ret_code) |
53 ret = 1 | 53 ret = 1 |
54 return ret | 54 return ret |
55 | 55 |
56 def _AddNativeCoverageExports(self, adb): | 56 @staticmethod |
| 57 def _AddNativeCoverageExports(adb): |
57 # export GCOV_PREFIX set the path for native coverage results | 58 # export GCOV_PREFIX set the path for native coverage results |
58 # export GCOV_PREFIX_STRIP indicates how many initial directory | 59 # export GCOV_PREFIX_STRIP indicates how many initial directory |
59 # names to strip off the hardwired absolute paths. | 60 # names to strip off the hardwired absolute paths. |
60 # This value is calculated in buildbot.sh and | 61 # This value is calculated in buildbot.sh and |
61 # depends on where the tree is built. | 62 # depends on where the tree is built. |
62 # Ex: /usr/local/google/code/chrome will become | 63 # Ex: /usr/local/google/code/chrome will become |
63 # /code/chrome if GCOV_PREFIX_STRIP=3 | 64 # /code/chrome if GCOV_PREFIX_STRIP=3 |
64 try: | 65 try: |
65 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] | 66 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] |
66 except KeyError: | 67 except KeyError: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 'new one (%s).' % target_name) | 139 'new one (%s).' % target_name) |
139 # 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 |
140 # aren't stripping a new binary, assume it's there. | 141 # aren't stripping a new binary, assume it's there. |
141 if not os.path.exists(self._symbols_dir): | 142 if not os.path.exists(self._symbols_dir): |
142 os.makedirs(self._symbols_dir) | 143 os.makedirs(self._symbols_dir) |
143 shutil.copy(self.suite_path, self._symbols_dir) | 144 shutil.copy(self.suite_path, self._symbols_dir) |
144 strip = os.environ['STRIP'] | 145 strip = os.environ['STRIP'] |
145 cmd_helper.RunCmd([strip, self.suite_path, '-o', target_name]) | 146 cmd_helper.RunCmd([strip, self.suite_path, '-o', target_name]) |
146 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 147 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
147 adb.PushIfNeeded(target_name, test_binary) | 148 adb.PushIfNeeded(target_name, test_binary) |
OLD | NEW |