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