Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(841)

Side by Side Diff: build/android/pylib/test_package_executable.py

Issue 10914199: Android: upstream latest changes for build/android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/test_package.py ('k') | build/android/run_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 import logging 6 import logging
7 import os 7 import os
8 import pexpect 8 import pexpect
9 import shutil 9 import shutil
10 import sys 10 import sys
11 import tempfile 11 import tempfile
12 12
13 import cmd_helper 13 import cmd_helper
14 import constants 14 import constants
15 from test_package import TestPackage 15 from test_package import TestPackage
16 16
17 17
18 class TestPackageExecutable(TestPackage): 18 class TestPackageExecutable(TestPackage):
19 """A helper class for running stand-alone executables.""" 19 """A helper class for running stand-alone executables."""
20 20
21 _TEST_RUNNER_RET_VAL_FILE = constants.TEST_DATA_DIR + '/gtest_retval' 21 _TEST_RUNNER_RET_VAL_FILE = 'gtest_retval'
22 22
23 def __init__(self, adb, device, test_suite, timeout, rebaseline, 23 def __init__(self, adb, device, test_suite, timeout, rebaseline,
24 performance_test, cleanup_test_files, tool, dump_debug_info, 24 performance_test, cleanup_test_files, tool, dump_debug_info,
25 symbols_dir=None): 25 symbols_dir=None):
26 """ 26 """
27 Args: 27 Args:
28 adb: ADB interface the tests are using. 28 adb: ADB interface the tests are using.
29 device: Device to run the tests. 29 device: Device to run the tests.
30 test_suite: A specific test suite to run, empty to run all. 30 test_suite: A specific test suite to run, empty to run all.
31 timeout: Timeout for each test. 31 timeout: Timeout for each test.
32 rebaseline: Whether or not to run tests in isolation and update the 32 rebaseline: Whether or not to run tests in isolation and update the
33 filter. 33 filter.
34 performance_test: Whether or not performance test(s). 34 performance_test: Whether or not performance test(s).
35 cleanup_test_files: Whether or not to cleanup test files on device. 35 cleanup_test_files: Whether or not to cleanup test files on device.
36 tool: Name of the Valgrind tool. 36 tool: Name of the Valgrind tool.
37 dump_debug_info: A debug_info object. 37 dump_debug_info: A debug_info object.
38 symbols_dir: Directory to put the stripped binaries. 38 symbols_dir: Directory to put the stripped binaries.
39 """ 39 """
40 TestPackage.__init__(self, adb, device, test_suite, timeout, 40 TestPackage.__init__(self, adb, device, test_suite, timeout,
41 rebaseline, performance_test, cleanup_test_files, 41 rebaseline, performance_test, cleanup_test_files,
42 tool, dump_debug_info) 42 tool, dump_debug_info)
43 self.symbols_dir = symbols_dir 43 self.symbols_dir = symbols_dir
44 44
45 def _GetGTestReturnCode(self): 45 def _GetGTestReturnCode(self):
46 ret = None 46 ret = None
47 ret_code = 1 # Assume failure if we can't find it 47 ret_code = 1 # Assume failure if we can't find it
48 ret_code_file = tempfile.NamedTemporaryFile() 48 ret_code_file = tempfile.NamedTemporaryFile()
49 try: 49 try:
50 if not self.adb.Adb().Pull( 50 if not self.adb.Adb().Pull(
51 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE, ret_code_file.name): 51 self.adb.GetExternalStorage() + '/' +
52 TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE,
53 ret_code_file.name):
52 logging.critical('Unable to pull gtest ret val file %s', 54 logging.critical('Unable to pull gtest ret val file %s',
53 ret_code_file.name) 55 ret_code_file.name)
54 raise ValueError 56 raise ValueError
55 ret_code = file(ret_code_file.name).read() 57 ret_code = file(ret_code_file.name).read()
56 ret = int(ret_code) 58 ret = int(ret_code)
57 except ValueError: 59 except ValueError:
58 logging.critical('Error reading gtest ret val file %s [%s]', 60 logging.critical('Error reading gtest ret val file %s [%s]',
59 ret_code_file.name, ret_code) 61 ret_code_file.name, ret_code)
60 ret = 1 62 ret = 1
61 return ret 63 return ret
62 64
63 def _AddNativeCoverageExports(self): 65 def _AddNativeCoverageExports(self):
64 # export GCOV_PREFIX set the path for native coverage results 66 # export GCOV_PREFIX set the path for native coverage results
65 # export GCOV_PREFIX_STRIP indicates how many initial directory 67 # export GCOV_PREFIX_STRIP indicates how many initial directory
66 # names to strip off the hardwired absolute paths. 68 # names to strip off the hardwired absolute paths.
67 # This value is calculated in buildbot.sh and 69 # This value is calculated in buildbot.sh and
68 # depends on where the tree is built. 70 # depends on where the tree is built.
69 # Ex: /usr/local/google/code/chrome will become 71 # Ex: /usr/local/google/code/chrome will become
70 # /code/chrome if GCOV_PREFIX_STRIP=3 72 # /code/chrome if GCOV_PREFIX_STRIP=3
71 try: 73 try:
72 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] 74 depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP']
73 except KeyError: 75 except KeyError:
74 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: ' 76 logging.info('NATIVE_COVERAGE_DEPTH_STRIP is not defined: '
75 'No native coverage.') 77 'No native coverage.')
76 return '' 78 return ''
77 export_string = 'export GCOV_PREFIX="%s/gcov"\n' % constants.TEST_DATA_DIR 79 export_string = ('export GCOV_PREFIX="%s/gcov"\n' %
80 self.adb.GetExternalStorage())
78 export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth 81 export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth
79 return export_string 82 return export_string
80 83
81 def GetAllTests(self): 84 def GetAllTests(self):
82 """Returns a list of all tests available in the test suite.""" 85 """Returns a list of all tests available in the test suite."""
83 all_tests = self.adb.RunShellCommand( 86 all_tests = self.adb.RunShellCommand(
84 '%s %s/%s --gtest_list_tests' % 87 '%s %s/%s --gtest_list_tests' %
85 (self.tool.GetTestWrapper(), 88 (self.tool.GetTestWrapper(),
86 constants.TEST_EXECUTABLE_DIR, 89 constants.TEST_EXECUTABLE_DIR,
87 self.test_suite_basename)) 90 self.test_suite_basename))
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 os.makedirs(self.symbols_dir) 158 os.makedirs(self.symbols_dir)
156 shutil.copy(self.test_suite, self.symbols_dir) 159 shutil.copy(self.test_suite, self.symbols_dir)
157 strip = os.environ['STRIP'] 160 strip = os.environ['STRIP']
158 cmd_helper.RunCmd([strip, self.test_suite, '-o', target_name]) 161 cmd_helper.RunCmd([strip, self.test_suite, '-o', target_name])
159 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.test_suite_basename 162 test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.test_suite_basename
160 self.adb.PushIfNeeded(target_name, test_binary) 163 self.adb.PushIfNeeded(target_name, test_binary)
161 164
162 def _GetTestSuiteBaseName(self): 165 def _GetTestSuiteBaseName(self):
163 """Returns the base name of the test suite.""" 166 """Returns the base name of the test suite."""
164 return os.path.basename(self.test_suite) 167 return os.path.basename(self.test_suite)
OLDNEW
« no previous file with comments | « build/android/pylib/test_package.py ('k') | build/android/run_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698