OLD | NEW |
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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 def UnexpectedOutput(self): | 363 def UnexpectedOutput(self): |
364 if self.HasCrashed(): | 364 if self.HasCrashed(): |
365 outcome = CRASH | 365 outcome = CRASH |
366 elif self.HasFailed(): | 366 elif self.HasFailed(): |
367 outcome = FAIL | 367 outcome = FAIL |
368 else: | 368 else: |
369 outcome = PASS | 369 outcome = PASS |
370 return not outcome in self.test.outcomes | 370 return not outcome in self.test.outcomes |
371 | 371 |
372 def HasCrashed(self): | 372 def HasCrashed(self): |
373 if platform.system() == 'Windows': | 373 if utils.IsWindows(): |
374 return 0x80000000 & self.output.exit_code and not (0x3FFFFF00 & self.outpu
t.exit_code) | 374 return 0x80000000 & self.output.exit_code and not (0x3FFFFF00 & self.outpu
t.exit_code) |
375 else: | 375 else: |
376 # Timed out tests will have exit_code -signal.SIGTERM. | 376 # Timed out tests will have exit_code -signal.SIGTERM. |
377 if self.output.timed_out: | 377 if self.output.timed_out: |
378 return False | 378 return False |
379 return self.output.exit_code < 0 and \ | 379 return self.output.exit_code < 0 and \ |
380 self.output.exit_code != -signal.SIGABRT | 380 self.output.exit_code != -signal.SIGABRT |
381 | 381 |
382 def HasFailed(self): | 382 def HasFailed(self): |
383 execution_failed = self.test.DidFail(self.output) | 383 execution_failed = self.test.DidFail(self.output) |
384 if self.test.IsNegative(): | 384 if self.test.IsNegative(): |
385 return not execution_failed | 385 return not execution_failed |
386 else: | 386 else: |
387 return execution_failed | 387 return execution_failed |
388 | 388 |
389 | 389 |
390 def KillProcessWithID(pid): | 390 def KillProcessWithID(pid): |
391 if platform.system() == 'Windows': | 391 if utils.IsWindows(): |
392 os.popen('taskkill /T /F /PID %d' % pid) | 392 os.popen('taskkill /T /F /PID %d' % pid) |
393 else: | 393 else: |
394 os.kill(pid, signal.SIGTERM) | 394 os.kill(pid, signal.SIGTERM) |
395 | 395 |
396 | 396 |
397 MAX_SLEEP_TIME = 0.1 | 397 MAX_SLEEP_TIME = 0.1 |
398 INITIAL_SLEEP_TIME = 0.0001 | 398 INITIAL_SLEEP_TIME = 0.0001 |
399 SLEEP_TIME_FACTOR = 1.25 | 399 SLEEP_TIME_FACTOR = 1.25 |
400 | 400 |
401 SEM_INVALID_VALUE = -1 | 401 SEM_INVALID_VALUE = -1 |
402 SEM_NOGPFAULTERRORBOX = 0x0002 # Microsoft Platform SDK WinBase.h | 402 SEM_NOGPFAULTERRORBOX = 0x0002 # Microsoft Platform SDK WinBase.h |
403 | 403 |
404 def Win32SetErrorMode(mode): | 404 def Win32SetErrorMode(mode): |
405 prev_error_mode = SEM_INVALID_VALUE | 405 prev_error_mode = SEM_INVALID_VALUE |
406 try: | 406 try: |
407 import ctypes | 407 import ctypes |
408 prev_error_mode = ctypes.windll.kernel32.SetErrorMode(mode); | 408 prev_error_mode = ctypes.windll.kernel32.SetErrorMode(mode); |
409 except ImportError: | 409 except ImportError: |
410 pass | 410 pass |
411 return prev_error_mode | 411 return prev_error_mode |
412 | 412 |
413 def RunProcess(context, timeout, args, **rest): | 413 def RunProcess(context, timeout, args, **rest): |
414 if context.verbose: print "#", " ".join(args) | 414 if context.verbose: print "#", " ".join(args) |
415 popen_args = args | 415 popen_args = args |
416 prev_error_mode = SEM_INVALID_VALUE; | 416 prev_error_mode = SEM_INVALID_VALUE; |
417 if platform.system() == 'Windows': | 417 if utils.IsWindows(): |
418 popen_args = '"' + subprocess.list2cmdline(args) + '"' | 418 popen_args = '"' + subprocess.list2cmdline(args) + '"' |
419 if context.suppress_dialogs: | 419 if context.suppress_dialogs: |
420 # Try to change the error mode to avoid dialogs on fatal errors. | 420 # Try to change the error mode to avoid dialogs on fatal errors. |
421 Win32SetErrorMode(SEM_NOGPFAULTERRORBOX) | 421 Win32SetErrorMode(SEM_NOGPFAULTERRORBOX) |
422 process = subprocess.Popen( | 422 process = subprocess.Popen( |
423 shell = (platform.system() == 'Windows'), | 423 shell = utils.IsWindows(), |
424 args = popen_args, | 424 args = popen_args, |
425 **rest | 425 **rest |
426 ) | 426 ) |
427 if platform.system() == 'Windows' and context.suppress_dialogs and prev_error_
mode != SEM_INVALID_VALUE: | 427 if utils.IsWindows() and context.suppress_dialogs and prev_error_mode != SEM_I
NVALID_VALUE: |
428 Win32SetErrorMode(prev_error_mode) | 428 Win32SetErrorMode(prev_error_mode) |
429 # Compute the end time - if the process crosses this limit we | 429 # Compute the end time - if the process crosses this limit we |
430 # consider it timed out. | 430 # consider it timed out. |
431 if timeout is None: end_time = None | 431 if timeout is None: end_time = None |
432 else: end_time = time.time() + timeout | 432 else: end_time = time.time() + timeout |
433 timed_out = False | 433 timed_out = False |
434 # Repeatedly check the exit code from the process in a | 434 # Repeatedly check the exit code from the process in a |
435 # loop and keep track of whether or not it times out. | 435 # loop and keep track of whether or not it times out. |
436 exit_code = None | 436 exit_code = None |
437 sleep_time = INITIAL_SLEEP_TIME | 437 sleep_time = INITIAL_SLEEP_TIME |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 self.workspace = workspace | 593 self.workspace = workspace |
594 self.buildspace = buildspace | 594 self.buildspace = buildspace |
595 self.verbose = verbose | 595 self.verbose = verbose |
596 self.vm_root = vm | 596 self.vm_root = vm |
597 self.timeout = timeout | 597 self.timeout = timeout |
598 self.processor = processor | 598 self.processor = processor |
599 self.suppress_dialogs = suppress_dialogs | 599 self.suppress_dialogs = suppress_dialogs |
600 | 600 |
601 def GetVm(self, mode): | 601 def GetVm(self, mode): |
602 name = self.vm_root + PREFIX[mode] | 602 name = self.vm_root + PREFIX[mode] |
603 if platform.system() == 'Windows': | 603 if utils.IsWindows(): |
604 return name + '.exe' | 604 return name + '.exe' |
605 else: | 605 else: |
606 return name | 606 return name |
607 | 607 |
608 def RunTestCases(all_cases, progress, tasks): | 608 def RunTestCases(all_cases, progress, tasks): |
609 def DoSkip(case): | 609 def DoSkip(case): |
610 return SKIP in c.outcomes or SLOW in c.outcomes | 610 return SKIP in c.outcomes or SLOW in c.outcomes |
611 cases_to_run = [ c for c in all_cases if not DoSkip(c) ] | 611 cases_to_run = [ c for c in all_cases if not DoSkip(c) ] |
612 progress = PROGRESS_INDICATORS[progress](cases_to_run) | 612 progress = PROGRESS_INDICATORS[progress](cases_to_run) |
613 return progress.Run(tasks) | 613 return progress.Run(tasks) |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 """Parses a logical expression into an Expression object""" | 913 """Parses a logical expression into an Expression object""" |
914 tokens = Tokenizer(expr).Tokenize() | 914 tokens = Tokenizer(expr).Tokenize() |
915 if not tokens: | 915 if not tokens: |
916 print "Malformed expression: '%s'" % expr | 916 print "Malformed expression: '%s'" % expr |
917 return None | 917 return None |
918 scan = Scanner(tokens) | 918 scan = Scanner(tokens) |
919 ast = ParseLogicalExpression(scan) | 919 ast = ParseLogicalExpression(scan) |
920 if not ast: | 920 if not ast: |
921 print "Malformed expression: '%s'" % expr | 921 print "Malformed expression: '%s'" % expr |
922 return None | 922 return None |
| 923 if scan.HasMore(): |
| 924 print "Malformed expression: '%s'" % expr |
| 925 return None |
923 return ast | 926 return ast |
924 | 927 |
925 | 928 |
926 class ClassifiedTest(object): | 929 class ClassifiedTest(object): |
927 | 930 |
928 def __init__(self, case, outcomes): | 931 def __init__(self, case, outcomes): |
929 self.case = case | 932 self.case = case |
930 self.outcomes = outcomes | 933 self.outcomes = outcomes |
931 | 934 |
932 | 935 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 | 1234 |
1232 # List the tests | 1235 # List the tests |
1233 all_cases = [ ] | 1236 all_cases = [ ] |
1234 all_unused = [ ] | 1237 all_unused = [ ] |
1235 unclassified_tests = [ ] | 1238 unclassified_tests = [ ] |
1236 globally_unused_rules = None | 1239 globally_unused_rules = None |
1237 for path in paths: | 1240 for path in paths: |
1238 for mode in options.mode: | 1241 for mode in options.mode: |
1239 env = { | 1242 env = { |
1240 'mode': mode, | 1243 'mode': mode, |
1241 'system': platform.system().lower(), | 1244 'system': utils.GuessOS(), |
1242 'arch': options.arch | 1245 'arch': options.arch |
1243 } | 1246 } |
1244 test_list = root.ListTests([], path, context, mode) | 1247 test_list = root.ListTests([], path, context, mode) |
1245 unclassified_tests += test_list | 1248 unclassified_tests += test_list |
1246 (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env) | 1249 (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env) |
1247 if globally_unused_rules is None: | 1250 if globally_unused_rules is None: |
1248 globally_unused_rules = set(unused_rules) | 1251 globally_unused_rules = set(unused_rules) |
1249 else: | 1252 else: |
1250 globally_unused_rules = globally_unused_rules.intersection(unused_rules) | 1253 globally_unused_rules = globally_unused_rules.intersection(unused_rules) |
1251 all_cases += cases | 1254 all_cases += cases |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 for entry in timed_tests[:20]: | 1301 for entry in timed_tests[:20]: |
1299 t = FormatTime(entry.duration) | 1302 t = FormatTime(entry.duration) |
1300 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) | 1303 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) |
1301 index += 1 | 1304 index += 1 |
1302 | 1305 |
1303 return result | 1306 return result |
1304 | 1307 |
1305 | 1308 |
1306 if __name__ == '__main__': | 1309 if __name__ == '__main__': |
1307 sys.exit(Main()) | 1310 sys.exit(Main()) |
OLD | NEW |