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 | 15 from pylib.gtest.test_package import TestPackage |
16 from test_package import TestPackage | |
17 | 16 |
18 | 17 |
19 class TestPackageExecutable(TestPackage): | 18 class TestPackageExecutable(TestPackage): |
20 """A helper class for running stand-alone executables.""" | 19 """A helper class for running stand-alone executables.""" |
21 | 20 |
22 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' | 21 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' |
23 | 22 |
24 def __init__(self, suite_name): | 23 def __init__(self, suite_name): |
25 """ | 24 """ |
26 Args: | 25 Args: |
(...skipping 18 matching lines...) Expand all Loading... |
45 ret_code_file.name) | 44 ret_code_file.name) |
46 raise ValueError | 45 raise ValueError |
47 ret_code = file(ret_code_file.name).read() | 46 ret_code = file(ret_code_file.name).read() |
48 ret = int(ret_code) | 47 ret = int(ret_code) |
49 except ValueError: | 48 except ValueError: |
50 logging.critical('Error reading gtest ret val file %s [%s]', | 49 logging.critical('Error reading gtest ret val file %s [%s]', |
51 ret_code_file.name, ret_code) | 50 ret_code_file.name, ret_code) |
52 ret = 1 | 51 ret = 1 |
53 return ret | 52 return ret |
54 | 53 |
55 def _AddNativeCoverageExports(self, adb): | 54 @staticmethod |
| 55 def _AddNativeCoverageExports(adb): |
56 # export GCOV_PREFIX set the path for native coverage results | 56 # export GCOV_PREFIX set the path for native coverage results |
57 # export GCOV_PREFIX_STRIP indicates how many initial directory | 57 # export GCOV_PREFIX_STRIP indicates how many initial directory |
58 # names to strip off the hardwired absolute paths. | 58 # names to strip off the hardwired absolute paths. |
59 # This value is calculated in buildbot.sh and | 59 # This value is calculated in buildbot.sh and |
60 # depends on where the tree is built. | 60 # depends on where the tree is built. |
61 # Ex: /usr/local/google/code/chrome will become | 61 # Ex: /usr/local/google/code/chrome will become |
62 # /code/chrome if GCOV_PREFIX_STRIP=3 | 62 # /code/chrome if GCOV_PREFIX_STRIP=3 |
63 try: | 63 try: |
64 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] | 64 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] |
65 except KeyError: | 65 except KeyError: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 source_mtime = os.stat(self.suite_path).st_mtime | 130 source_mtime = os.stat(self.suite_path).st_mtime |
131 if target_mtime < source_mtime: | 131 if target_mtime < source_mtime: |
132 raise Exception( | 132 raise Exception( |
133 'stripped binary (%s, timestamp %d) older than ' | 133 'stripped binary (%s, timestamp %d) older than ' |
134 'source binary (%s, timestamp %d), build target %s' % | 134 'source binary (%s, timestamp %d), build target %s' % |
135 (target_name, target_mtime, self.suite_path, source_mtime, | 135 (target_name, target_mtime, self.suite_path, source_mtime, |
136 self.suite_name + '_stripped')) | 136 self.suite_name + '_stripped')) |
137 | 137 |
138 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 138 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
139 adb.PushIfNeeded(target_name, test_binary) | 139 adb.PushIfNeeded(target_name, test_binary) |
OLD | NEW |