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

Side by Side Diff: tools/test_lib.py

Issue 8439032: Add option to command tester for running a test multiple times. Use that (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: one more try Created 9 years, 1 month 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2011 The Native Client 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 """Testing Library For Nacl. 6 """Testing Library For Nacl.
7 7
8 """ 8 """
9 9
10 import difflib 10 import difflib
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 def __init__(self): 95 def __init__(self):
96 self._start_time = self._GetTime(None) 96 self._start_time = self._GetTime(None)
97 97
98 98
99 def ElapsedCpuTime(self, proc_handle): 99 def ElapsedCpuTime(self, proc_handle):
100 return self._GetTime(proc_handle) - self._start_time 100 return self._GetTime(proc_handle) - self._start_time
101 101
102 def PopenBufSize(): 102 def PopenBufSize():
103 return 1000 * 1000 103 return 1000 * 1000
104 104
105 def RunCmdWithInput(cmd, input_data):
106 try:
107 sys.stdout.flush() # Make sure stdout stays in sync on the bots.
108 p = subprocess.Popen(cmd,
109 bufsize=PopenBufSize(),
110 stdin=subprocess.PIPE)
111 p.communicate(input_data)
112 retcode = p.wait()
113 if retcode != 0:
114 print ('Failed to cmd %s (retcode=%d)' %
115 (cmd, retcode))
116 return False
117 except OSError:
118 print 'RunCmdWithInput exception: ' + str(sys.exc_info()[1])
119 return False
120 return True
121
122 def RunTestWithInput(cmd, input_data): 105 def RunTestWithInput(cmd, input_data):
123 """Run a test where we only care about the return code.""" 106 """Run a test where we only care about the return code."""
124 assert type(cmd) == list 107 assert type(cmd) == list
125 failed = 0 108 failed = 0
126 timer = SubprocessCpuTimer() 109 timer = SubprocessCpuTimer()
127 p = None 110 p = None
128 try: 111 try:
129 sys.stdout.flush() # Make sure stdout stays in sync on the bots. 112 sys.stdout.flush() # Make sure stdout stays in sync on the bots.
130 if type(input_data) == str: 113 if type(input_data) == str:
131 p = subprocess.Popen(cmd, 114 p = subprocess.Popen(cmd,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if group_only: 261 if group_only:
279 matched_strings = [] 262 matched_strings = []
280 for s in mobj.groups(): 263 for s in mobj.groups():
281 if s is not None: 264 if s is not None:
282 matched_strings.append(s) 265 matched_strings.append(s)
283 result.append(''.join(matched_strings)) 266 result.append(''.join(matched_strings))
284 else: 267 else:
285 result.append(line) 268 result.append(line)
286 269
287 return '\n'.join(result) 270 return '\n'.join(result)
OLDNEW
« tools/process_perf_combined.py ('K') | « tools/process_perf_combined.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698