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 from pylib.device import device_errors |
15 from pylib.gtest.test_package import TestPackage | 16 from pylib.gtest.test_package import TestPackage |
16 | 17 |
17 | 18 |
18 class TestPackageExecutable(TestPackage): | 19 class TestPackageExecutable(TestPackage): |
19 """A helper class for running stand-alone executables.""" | 20 """A helper class for running stand-alone executables.""" |
20 | 21 |
21 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' | 22 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval' |
22 | 23 |
23 def __init__(self, suite_name): | 24 def __init__(self, suite_name): |
24 """ | 25 """ |
(...skipping 30 matching lines...) Expand all Loading... |
55 def _AddNativeCoverageExports(device): | 56 def _AddNativeCoverageExports(device): |
56 # export GCOV_PREFIX set the path for native coverage results | 57 # export GCOV_PREFIX set the path for native coverage results |
57 # export GCOV_PREFIX_STRIP indicates how many initial directory | 58 # export GCOV_PREFIX_STRIP indicates how many initial directory |
58 # names to strip off the hardwired absolute paths. | 59 # names to strip off the hardwired absolute paths. |
59 # This value is calculated in buildbot.sh and | 60 # This value is calculated in buildbot.sh and |
60 # depends on where the tree is built. | 61 # depends on where the tree is built. |
61 # Ex: /usr/local/google/code/chrome will become | 62 # Ex: /usr/local/google/code/chrome will become |
62 # /code/chrome if GCOV_PREFIX_STRIP=3 | 63 # /code/chrome if GCOV_PREFIX_STRIP=3 |
63 try: | 64 try: |
64 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] | 65 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] |
| 66 export_string = ('export GCOV_PREFIX="%s/gcov"\n' % |
| 67 device.GetExternalStoragePath()) |
| 68 export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth |
| 69 return export_string |
65 except KeyError: | 70 except KeyError: |
66 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: ' | 71 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: ' |
67 'No native coverage.') | 72 'No native coverage.') |
68 return '' | 73 return '' |
69 export_string = ('export GCOV_PREFIX="%s/gcov"\n' % | 74 except device_errors.CommandFailedError: |
70 device.old_interface.GetExternalStorage()) | 75 logging.info('No external storage found: No native coverage.') |
71 export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth | 76 return '' |
72 return export_string | |
73 | 77 |
74 #override | 78 #override |
75 def ClearApplicationState(self, device): | 79 def ClearApplicationState(self, device): |
76 device.old_interface.KillAllBlocking(self.suite_name, 30) | 80 device.old_interface.KillAllBlocking(self.suite_name, 30) |
77 | 81 |
78 #override | 82 #override |
79 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): | 83 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): |
80 tool_wrapper = self.tool.GetTestWrapper() | 84 tool_wrapper = self.tool.GetTestWrapper() |
81 sh_script_file = tempfile.NamedTemporaryFile() | 85 sh_script_file = tempfile.NamedTemporaryFile() |
82 # We need to capture the exit status from the script since adb shell won't | 86 # We need to capture the exit status from the script since adb shell won't |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 source_mtime = os.stat(self.suite_path).st_mtime | 134 source_mtime = os.stat(self.suite_path).st_mtime |
131 if target_mtime < source_mtime: | 135 if target_mtime < source_mtime: |
132 raise Exception( | 136 raise Exception( |
133 'stripped binary (%s, timestamp %d) older than ' | 137 'stripped binary (%s, timestamp %d) older than ' |
134 'source binary (%s, timestamp %d), build target %s' % | 138 'source binary (%s, timestamp %d), build target %s' % |
135 (target_name, target_mtime, self.suite_path, source_mtime, | 139 (target_name, target_mtime, self.suite_path, source_mtime, |
136 self.suite_name + '_stripped')) | 140 self.suite_name + '_stripped')) |
137 | 141 |
138 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name | 142 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name |
139 device.old_interface.PushIfNeeded(target_name, test_binary) | 143 device.old_interface.PushIfNeeded(target_name, test_binary) |
OLD | NEW |