OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 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 # valgrind_test.py | 6 # valgrind_test.py |
7 | 7 |
8 '''Runs an exe through Valgrind and puts the intermediate files in a | 8 '''Runs an exe through Valgrind and puts the intermediate files in a |
9 directory. | 9 directory. |
10 ''' | 10 ''' |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 if (flag_value in ["1", "true", "yes"]): | 472 if (flag_value in ["1", "true", "yes"]): |
473 return True | 473 return True |
474 elif (flag_value in ["0", "false", "no"]): | 474 elif (flag_value in ["0", "false", "no"]): |
475 return False | 475 return False |
476 raise RuntimeError, "Can't parse flag value (%s)" % flag_value | 476 raise RuntimeError, "Can't parse flag value (%s)" % flag_value |
477 | 477 |
478 def ToolSpecificFlags(self): | 478 def ToolSpecificFlags(self): |
479 ret = [] | 479 ret = [] |
480 | 480 |
481 ignore_files = ["ignores.txt"] | 481 ignore_files = ["ignores.txt"] |
482 platform_suffix = common.PlatformName() | 482 for platform_suffix in common.PlatformNames(): |
483 ignore_files.append("ignores_%s.txt" % platform_suffix) | 483 ignore_files.append("ignores_%s.txt" % platform_suffix) |
484 for ignore_file in ignore_files: | 484 for ignore_file in ignore_files: |
485 fullname = os.path.join(self._source_dir, | 485 fullname = os.path.join(self._source_dir, |
486 "tools", "valgrind", "tsan", ignore_file) | 486 "tools", "valgrind", "tsan", ignore_file) |
487 if os.path.exists(fullname): | 487 if os.path.exists(fullname): |
488 ret += ["--ignore=%s" % fullname] | 488 ret += ["--ignore=%s" % fullname] |
489 | 489 |
490 # The -v flag is needed for printing the list of used suppressions. | 490 # The -v flag is needed for printing the list of used suppressions. |
491 ret += ["-v"] | 491 ret += ["-v"] |
492 | 492 |
493 # This should shorten filepaths for local builds. | 493 # This should shorten filepaths for local builds. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 return ret | 530 return ret |
531 | 531 |
532 | 532 |
533 class ToolFactory: | 533 class ToolFactory: |
534 def Create(self, tool_name): | 534 def Create(self, tool_name): |
535 if tool_name == "memcheck" and not common.IsWine(): | 535 if tool_name == "memcheck" and not common.IsWine(): |
536 return Memcheck() | 536 return Memcheck() |
537 if tool_name == "wine_memcheck" and common.IsWine(): | 537 if tool_name == "wine_memcheck" and common.IsWine(): |
538 return Memcheck() | 538 return Memcheck() |
539 if tool_name == "tsan": | 539 if tool_name == "tsan": |
540 if not common.IsLinux(): | 540 if common.IsWindows(): |
541 logging.info("WARNING: ThreadSanitizer may be unstable on Mac.") | 541 logging.info("WARNING: ThreadSanitizer Windows support is experimental."
) |
542 logging.info("See http://code.google.com/p/data-race-test/wiki/" | |
543 "ThreadSanitizerOnMacOsx for the details") | |
544 return ThreadSanitizer() | 542 return ThreadSanitizer() |
545 try: | 543 try: |
546 platform_name = common.PlatformName() | 544 platform_name = common.PlatformNames()[0] |
547 except common.NotImplementedError: | 545 except common.NotImplementedError: |
548 platform_name = sys.platform + "(Unknown)" | 546 platform_name = sys.platform + "(Unknown)" |
549 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, | 547 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, |
550 platform_name) | 548 platform_name) |
551 | 549 |
552 def RunTool(argv, module): | 550 def RunTool(argv, module): |
553 # TODO(timurrrr): customize optparse instead | 551 # TODO(timurrrr): customize optparse instead |
554 tool_name = "memcheck" | 552 tool_name = "memcheck" |
555 args = argv[1:] | 553 args = argv[1:] |
556 for arg in args: | 554 for arg in args: |
557 if arg.startswith("--tool="): | 555 if arg.startswith("--tool="): |
558 tool_name = arg[7:] | 556 tool_name = arg[7:] |
559 args.remove(arg) | 557 args.remove(arg) |
560 break | 558 break |
561 | 559 |
562 tool = ToolFactory().Create(tool_name) | 560 tool = ToolFactory().Create(tool_name) |
563 MODULES_TO_SANITY_CHECK = ["base"] | 561 MODULES_TO_SANITY_CHECK = ["base"] |
564 check_sanity = module in MODULES_TO_SANITY_CHECK | 562 check_sanity = module in MODULES_TO_SANITY_CHECK |
565 return tool.Main(args, check_sanity) | 563 return tool.Main(args, check_sanity) |
566 | 564 |
567 if __name__ == "__main__": | 565 if __name__ == "__main__": |
568 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: | 566 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: |
569 google.logging_utils.config_root(logging.DEBUG) | 567 google.logging_utils.config_root(logging.DEBUG) |
570 else: | 568 else: |
571 google.logging_utils.config_root() | 569 google.logging_utils.config_root() |
572 # TODO(timurrrr): valgrind tools may use -v/--verbose as well | 570 # TODO(timurrrr): valgrind tools may use -v/--verbose as well |
573 | 571 |
574 ret = RunTool(sys.argv) | 572 ret = RunTool(sys.argv) |
575 sys.exit(ret) | 573 sys.exit(ret) |
OLD | NEW |