| OLD | NEW |
| 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 # 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 705 |
| 706 def ExtendOptionParser(self, parser): | 706 def ExtendOptionParser(self, parser): |
| 707 parser.add_option("", "--suppressions", default=[], | 707 parser.add_option("", "--suppressions", default=[], |
| 708 action="append", | 708 action="append", |
| 709 help="path to a drmemory suppression file") | 709 help="path to a drmemory suppression file") |
| 710 parser.add_option("", "--follow_python", action="store_true", | 710 parser.add_option("", "--follow_python", action="store_true", |
| 711 default=False, dest="follow_python", | 711 default=False, dest="follow_python", |
| 712 help="Monitor python child processes. If off, neither " | 712 help="Monitor python child processes. If off, neither " |
| 713 "python children nor any children of python children " | 713 "python children nor any children of python children " |
| 714 "will be monitored.") | 714 "will be monitored.") |
| 715 parser._parser.add_option("", "--indirect", action="store_true", |
| 716 default=False, |
| 717 help="set BROWSER_WRAPPER rather than " |
| 718 "running Dr. Memory directly on the harness") |
| 715 parser.add_option("", "--use_debug", action="store_true", | 719 parser.add_option("", "--use_debug", action="store_true", |
| 716 default=False, dest="use_debug", | 720 default=False, dest="use_debug", |
| 717 help="Run Dr. Memory debug build") | 721 help="Run Dr. Memory debug build") |
| 718 # TODO(bruening): I want to add --extraops that can take extra | 722 # TODO(bruening): I want to add --extraops that can take extra |
| 719 # args that are passed through to Dr. Memory, but the | 723 # args that are passed through to Dr. Memory, but the |
| 720 # chrome_tests.bat and chrome_tests.py layers combined w/ | 724 # chrome_tests.bat and chrome_tests.py layers combined w/ |
| 721 # chrome_tests.py parsing makes it not work out in practice. We | 725 # chrome_tests.py parsing makes it not work out in practice. We |
| 722 # should change chrome_tests.py to pass all unknown options | 726 # should change chrome_tests.py to pass all unknown options |
| 723 # through to valgrind_test.py so we don't need to use --tool_flags | 727 # through to valgrind_test.py so we don't need to use --tool_flags |
| 724 # and quote it, and ditto w/ valgrind_test.py passing unknown | 728 # and quote it, and ditto w/ valgrind_test.py passing unknown |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 | 809 |
| 806 # Un-comment to ignore uninitialized accesses | 810 # Un-comment to ignore uninitialized accesses |
| 807 #proc += ["-no_check_uninitialized"] | 811 #proc += ["-no_check_uninitialized"] |
| 808 | 812 |
| 809 # Un-comment to ignore leaks | 813 # Un-comment to ignore leaks |
| 810 #proc += ["-no_check_leaks", "-no_count_leaks"] | 814 #proc += ["-no_check_leaks", "-no_count_leaks"] |
| 811 | 815 |
| 812 # Dr.Memory requires -- to separate tool flags from the executable name. | 816 # Dr.Memory requires -- to separate tool flags from the executable name. |
| 813 proc += ["--"] | 817 proc += ["--"] |
| 814 | 818 |
| 819 if self._options.indirect: |
| 820 self.CreateBrowserWrapper(" ".join(proc)) |
| 821 proc = [] |
| 822 |
| 815 # Note that self._args begins with the name of the exe to be run. | 823 # Note that self._args begins with the name of the exe to be run. |
| 816 proc += self._args | 824 proc += self._args |
| 817 return proc | 825 return proc |
| 818 | 826 |
| 827 def CreateBrowserWrapper(self, command): |
| 828 os.putenv("BROWSER_WRAPPER", command) |
| 829 |
| 819 def Analyze(self, check_sanity=False): | 830 def Analyze(self, check_sanity=False): |
| 820 # Glob all the results files in the "testing.tmp" directory | 831 # Glob all the results files in the "testing.tmp" directory |
| 821 filenames = glob.glob(self.log_dir + "/*/results.txt") | 832 filenames = glob.glob(self.log_dir + "/*/results.txt") |
| 822 | 833 |
| 823 analyzer = drmemory_analyze.DrMemoryAnalyze(self._source_dir, filenames) | 834 analyzer = drmemory_analyze.DrMemoryAnalyze(self._source_dir, filenames) |
| 824 ret = analyzer.Report(check_sanity) | 835 ret = analyzer.Report(check_sanity) |
| 825 return ret | 836 return ret |
| 826 | 837 |
| 827 | 838 |
| 828 # RaceVerifier support. See | 839 # RaceVerifier support. See |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 platform_name = sys.platform + "(Unknown)" | 982 platform_name = sys.platform + "(Unknown)" |
| 972 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, | 983 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, |
| 973 platform_name) | 984 platform_name) |
| 974 | 985 |
| 975 def CreateTool(tool): | 986 def CreateTool(tool): |
| 976 return ToolFactory().Create(tool) | 987 return ToolFactory().Create(tool) |
| 977 | 988 |
| 978 if __name__ == '__main__': | 989 if __name__ == '__main__': |
| 979 logging.error(sys.argv[0] + " can not be run from command line") | 990 logging.error(sys.argv[0] + " can not be run from command line") |
| 980 sys.exit(1) | 991 sys.exit(1) |
| OLD | NEW |