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

Side by Side Diff: tools/test.py

Issue 155161: Add automatic tests for Tick Processor, take two. (Closed)
Patch Set: Created 11 years, 5 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
« no previous file with comments | « tools/linux-tick-processor ('k') | tools/tickprocessor.js » ('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/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2008 the V8 project authors. All rights reserved. 3 # Copyright 2008 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 def IsFailureOutput(self, output): 350 def IsFailureOutput(self, output):
351 return output.exit_code != 0 351 return output.exit_code != 0
352 352
353 def GetSource(self): 353 def GetSource(self):
354 return "(no source available)" 354 return "(no source available)"
355 355
356 def RunCommand(self, command): 356 def RunCommand(self, command):
357 full_command = self.context.processor(command) 357 full_command = self.context.processor(command)
358 output = Execute(full_command, self.context, self.context.timeout) 358 output = Execute(full_command, self.context, self.context.timeout)
359 self.Cleanup()
359 return TestOutput(self, full_command, output) 360 return TestOutput(self, full_command, output)
360 361
361 def Run(self): 362 def Run(self):
362 return self.RunCommand(self.GetCommand()) 363 return self.RunCommand(self.GetCommand())
363 364
365 def Cleanup(self):
366 return
367
364 368
365 class TestOutput(object): 369 class TestOutput(object):
366 370
367 def __init__(self, test, command, output): 371 def __init__(self, test, command, output):
368 self.test = test 372 self.test = test
369 self.command = command 373 self.command = command
370 self.output = output 374 self.output = output
371 375
372 def UnexpectedOutput(self): 376 def UnexpectedOutput(self):
373 if self.HasCrashed(): 377 if self.HasCrashed():
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if sleep_time > MAX_SLEEP_TIME: 470 if sleep_time > MAX_SLEEP_TIME:
467 sleep_time = MAX_SLEEP_TIME 471 sleep_time = MAX_SLEEP_TIME
468 return (process, exit_code, timed_out) 472 return (process, exit_code, timed_out)
469 473
470 474
471 def PrintError(str): 475 def PrintError(str):
472 sys.stderr.write(str) 476 sys.stderr.write(str)
473 sys.stderr.write('\n') 477 sys.stderr.write('\n')
474 478
475 479
480 def CheckedUnlink(name):
481 try:
482 os.unlink(name)
483 except OSError, e:
484 PrintError("os.unlink() " + str(e))
485
486
476 def Execute(args, context, timeout=None): 487 def Execute(args, context, timeout=None):
477 (fd_out, outname) = tempfile.mkstemp() 488 (fd_out, outname) = tempfile.mkstemp()
478 (fd_err, errname) = tempfile.mkstemp() 489 (fd_err, errname) = tempfile.mkstemp()
479 (process, exit_code, timed_out) = RunProcess( 490 (process, exit_code, timed_out) = RunProcess(
480 context, 491 context,
481 timeout, 492 timeout,
482 args = args, 493 args = args,
483 stdout = fd_out, 494 stdout = fd_out,
484 stderr = fd_err, 495 stderr = fd_err,
485 ) 496 )
486 os.close(fd_out) 497 os.close(fd_out)
487 os.close(fd_err) 498 os.close(fd_err)
488 output = file(outname).read() 499 output = file(outname).read()
489 errors = file(errname).read() 500 errors = file(errname).read()
490 def CheckedUnlink(name):
491 try:
492 os.unlink(name)
493 except OSError, e:
494 PrintError("os.unlink() " + str(e))
495 CheckedUnlink(outname) 501 CheckedUnlink(outname)
496 CheckedUnlink(errname) 502 CheckedUnlink(errname)
497 return CommandOutput(exit_code, timed_out, output, errors) 503 return CommandOutput(exit_code, timed_out, output, errors)
498 504
499 505
500 def ExecuteNoCapture(args, context, timeout=None): 506 def ExecuteNoCapture(args, context, timeout=None):
501 (process, exit_code, timed_out) = RunProcess( 507 (process, exit_code, timed_out) = RunProcess(
502 context, 508 context,
503 timeout, 509 timeout,
504 args = args, 510 args = args,
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 for entry in timed_tests[:20]: 1339 for entry in timed_tests[:20]:
1334 t = FormatTime(entry.duration) 1340 t = FormatTime(entry.duration)
1335 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) 1341 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
1336 index += 1 1342 index += 1
1337 1343
1338 return result 1344 return result
1339 1345
1340 1346
1341 if __name__ == '__main__': 1347 if __name__ == '__main__':
1342 sys.exit(Main()) 1348 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/linux-tick-processor ('k') | tools/tickprocessor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698