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

Side by Side Diff: build/android/test_package.py

Issue 8383020: Upstream: Android Test scripts (phase 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 2 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/perf_tests_helper.py ('k') | build/android/valgrind_tools.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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 import logging 7 import logging
8 import re 8 import re
9 import os 9 import os
10 import pexpect 10 import pexpect
(...skipping 22 matching lines...) Expand all
33 """ 33 """
34 34
35 def __init__(self, adb, device, test_suite, timeout, rebaseline, 35 def __init__(self, adb, device, test_suite, timeout, rebaseline,
36 performance_test, cleanup_test_files, tool, dump_debug_info): 36 performance_test, cleanup_test_files, tool, dump_debug_info):
37 self.adb = adb 37 self.adb = adb
38 self.device = device 38 self.device = device
39 self.test_suite = os.path.splitext(test_suite)[0] 39 self.test_suite = os.path.splitext(test_suite)[0]
40 self.test_suite_basename = os.path.basename(self.test_suite) 40 self.test_suite_basename = os.path.basename(self.test_suite)
41 self.test_suite_dirname = os.path.dirname(self.test_suite) 41 self.test_suite_dirname = os.path.dirname(self.test_suite)
42 self.rebaseline = rebaseline 42 self.rebaseline = rebaseline
43 self._performance_test = performance_test 43 self.performance_test = performance_test
44 self.cleanup_test_files = cleanup_test_files 44 self.cleanup_test_files = cleanup_test_files
45 self.tool = CreateTool(tool, self.adb) 45 self.tool = CreateTool(tool, self.adb)
46 if timeout == 0: 46 if timeout == 0:
47 if self.test_suite_basename == 'page_cycler_tests': 47 if self.test_suite_basename == 'page_cycler_tests':
48 timeout = 900 48 timeout = 900
49 else: 49 else:
50 timeout = 60 50 timeout = 60
51 self.timeout = timeout * self.tool.GetTimeoutScale() 51 self.timeout = timeout * self.tool.GetTimeoutScale()
52 self.dump_debug_info = dump_debug_info 52 self.dump_debug_info = dump_debug_info
53 53
54 def _BeginGetIOStats(self): 54 def _BeginGetIOStats(self):
55 """Gets I/O statistics before running test. 55 """Gets I/O statistics before running test.
56 56
57 Return: 57 Return:
58 Tuple of (I/O stats object, flag of ready to continue). When encountering 58 Tuple of (I/O stats object, flag of ready to continue). When encountering
59 error, ready-to-continue flag is False, True otherwise. The I/O stats 59 error, ready-to-continue flag is False, True otherwise. The I/O stats
60 object may be None if the test is not performance test. 60 object may be None if the test is not performance test.
61 """ 61 """
62 initial_io_stats = None 62 initial_io_stats = None
63 # Try to get the disk I/O statistics for all performance tests. 63 # Try to get the disk I/O statistics for all performance tests.
64 if self._performance_test and not self.rebaseline: 64 if self.performance_test and not self.rebaseline:
65 initial_io_stats = self.adb.GetIoStats() 65 initial_io_stats = self.adb.GetIoStats()
66 # Get rid of the noise introduced by launching Chrome for page cycler. 66 # Get rid of the noise introduced by launching Chrome for page cycler.
67 if self.test_suite_basename == 'page_cycler_tests': 67 if self.test_suite_basename == 'page_cycler_tests':
68 try: 68 try:
69 chrome_launch_done_re = re.compile( 69 chrome_launch_done_re = re.compile(
70 re.escape('Finish waiting for browser launch!')) 70 re.escape('Finish waiting for browser launch!'))
71 self.adb.WaitForLogMatch(chrome_launch_done_re) 71 self.adb.WaitForLogMatch(chrome_launch_done_re)
72 initial_io_stats = self.adb.GetIoStats() 72 initial_io_stats = self.adb.GetIoStats()
73 except pexpect.TIMEOUT: 73 except pexpect.TIMEOUT:
74 logging.error('Test terminated because Chrome launcher has no' 74 logging.error('Test terminated because Chrome launcher has no'
75 'response after 120 second.') 75 'response after 120 second.')
76 return (None, False) 76 return (None, False)
77 finally: 77 finally:
78 if self.dump_debug_info: 78 if self.dump_debug_info:
79 self.dump_debug_info.TakeScreenshot('_Launch_Chrome_') 79 self.dump_debug_info.TakeScreenshot('_Launch_Chrome_')
80 return (initial_io_stats, True) 80 return (initial_io_stats, True)
81 81
82 def _EndGetIOStats(self, initial_io_stats): 82 def _EndGetIOStats(self, initial_io_stats):
83 """Gets I/O statistics after running test and calcuate the I/O delta. 83 """Gets I/O statistics after running test and calcuate the I/O delta.
84 84
85 Args: 85 Args:
86 initial_io_stats: I/O stats object got from _BeginGetIOStats. 86 initial_io_stats: I/O stats object got from _BeginGetIOStats.
87 87
88 Return: 88 Return:
89 String for formated diso I/O statistics. 89 String for formated diso I/O statistics.
90 """ 90 """
91 disk_io = '' 91 disk_io = ''
92 if self._performance_test and initial_io_stats: 92 if self.performance_test and initial_io_stats:
93 final_io_stats = self.adb.GetIoStats() 93 final_io_stats = self.adb.GetIoStats()
94 for stat in final_io_stats: 94 for stat in final_io_stats:
95 disk_io += '\n' + PrintPerfResult(stat, stat, 95 disk_io += '\n' + PrintPerfResult(stat, stat,
96 [final_io_stats[stat] - 96 [final_io_stats[stat] -
97 initial_io_stats[stat]], 97 initial_io_stats[stat]],
98 stat.split('_')[1], True, False) 98 stat.split('_')[1], True, False)
99 logging.info(disk_io) 99 logging.info(disk_io)
100 return disk_io 100 return disk_io
101 101
102 def GetDisabledPrefixes(self): 102 def GetDisabledPrefixes(self):
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if not self.rebaseline and ready_to_continue: 155 if not self.rebaseline and ready_to_continue:
156 ok_tests += self._EndGetIOStats(io_stats_before) 156 ok_tests += self._EndGetIOStats(io_stats_before)
157 ret_code = self._GetGTestReturnCode() 157 ret_code = self._GetGTestReturnCode()
158 if ret_code: 158 if ret_code:
159 failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, 159 failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code,
160 'pexpect.before: %s' 160 'pexpect.before: %s'
161 '\npexpect.after: %s' 161 '\npexpect.after: %s'
162 % (p.before, 162 % (p.before,
163 p.after))] 163 p.after))]
164 return TestResults.FromOkAndFailed(ok_tests, failed_tests) 164 return TestResults.FromOkAndFailed(ok_tests, failed_tests)
OLDNEW
« no previous file with comments | « build/android/perf_tests_helper.py ('k') | build/android/valgrind_tools.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698