| 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 # chrome_tests.py | 6 # chrome_tests.py |
| 7 | 7 |
| 8 ''' Runs various chrome tests through valgrind_test.py.''' | 8 ''' Runs various chrome tests through valgrind_test.py.''' |
| 9 | 9 |
| 10 import glob | 10 import glob |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') | 86 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') |
| 87 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") | 87 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") |
| 88 self._command_preamble = ["--source_dir=%s" % (self._source_dir)] | 88 self._command_preamble = ["--source_dir=%s" % (self._source_dir)] |
| 89 | 89 |
| 90 def _DefaultCommand(self, tool, module, exe=None, valgrind_test_args=None): | 90 def _DefaultCommand(self, tool, module, exe=None, valgrind_test_args=None): |
| 91 '''Generates the default command array that most tests will use.''' | 91 '''Generates the default command array that most tests will use.''' |
| 92 if exe and common.IsWindows(): | 92 if exe and common.IsWindows(): |
| 93 exe = exe + '.exe' | 93 exe = exe + '.exe' |
| 94 | 94 |
| 95 if not self._options.build_dir: | 95 if not self._options.build_dir: |
| 96 if common.IsWine(): | 96 dirs = [ |
| 97 self._options.build_dir = os.path.join( | 97 os.path.join(self._source_dir, "xcodebuild", "Debug"), |
| 98 self._source_dir, "chrome", "Debug") | 98 os.path.join(self._source_dir, "out", "Debug"), |
| 99 os.path.join(self._source_dir, "build", "Debug"), |
| 100 ] |
| 101 if exe: |
| 102 self._options.build_dir = FindDirContainingNewestFile(dirs, exe) |
| 99 else: | 103 else: |
| 100 dirs = [ | 104 self._options.build_dir = FindNewestDir(dirs) |
| 101 os.path.join(self._source_dir, "xcodebuild", "Debug"), | |
| 102 os.path.join(self._source_dir, "out", "Debug"), | |
| 103 os.path.join(self._source_dir, "build", "Debug"), | |
| 104 ] | |
| 105 if exe: | |
| 106 self._options.build_dir = FindDirContainingNewestFile(dirs, exe) | |
| 107 else: | |
| 108 self._options.build_dir = FindNewestDir(dirs) | |
| 109 | 105 |
| 110 cmd = list(self._command_preamble) | 106 cmd = list(self._command_preamble) |
| 111 | 107 |
| 112 # Find all suppressions matching the following pattern: | 108 # Find all suppressions matching the following pattern: |
| 113 # tools/valgrind/TOOL/suppressions[_PLATFORM].txt | 109 # tools/valgrind/TOOL/suppressions[_PLATFORM].txt |
| 114 # and list them with --suppressions= prefix. | 110 # and list them with --suppressions= prefix. |
| 115 script_dir = path_utils.ScriptDir() | 111 script_dir = path_utils.ScriptDir() |
| 116 tool_name = tool.ToolName(); | 112 tool_name = tool.ToolName(); |
| 117 suppression_file = os.path.join(script_dir, tool_name, "suppressions.txt") | 113 suppression_file = os.path.join(script_dir, tool_name, "suppressions.txt") |
| 118 if os.path.exists(suppression_file): | 114 if os.path.exists(suppression_file): |
| 119 cmd.append("--suppressions=%s" % suppression_file) | 115 cmd.append("--suppressions=%s" % suppression_file) |
| 120 # Platform-specific suppression | 116 # Platform-specific suppression |
| 121 for platform in common.PlatformNames(): | 117 for platform in common.PlatformNames(): |
| 122 platform_suppression_file = \ | 118 platform_suppression_file = \ |
| 123 os.path.join(script_dir, tool_name, 'suppressions_%s.txt' % platform) | 119 os.path.join(script_dir, tool_name, 'suppressions_%s.txt' % platform) |
| 124 if os.path.exists(platform_suppression_file): | 120 if os.path.exists(platform_suppression_file): |
| 125 cmd.append("--suppressions=%s" % platform_suppression_file) | 121 cmd.append("--suppressions=%s" % platform_suppression_file) |
| 126 | 122 |
| 127 if self._options.valgrind_tool_flags: | 123 if self._options.valgrind_tool_flags: |
| 128 cmd += self._options.valgrind_tool_flags.split(" ") | 124 cmd += self._options.valgrind_tool_flags.split(" ") |
| 129 if valgrind_test_args != None: | 125 if valgrind_test_args != None: |
| 130 for arg in valgrind_test_args: | 126 for arg in valgrind_test_args: |
| 131 cmd.append(arg) | 127 cmd.append(arg) |
| 132 if exe: | 128 if exe: |
| 133 if common.IsWine(): | |
| 134 cmd.append(os.environ.get('WINE')) | |
| 135 exe = exe + '.exe' | |
| 136 cmd.append(os.path.join(self._options.build_dir, exe)) | 129 cmd.append(os.path.join(self._options.build_dir, exe)) |
| 137 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time | 130 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time |
| 138 # so we can find the slowpokes. | 131 # so we can find the slowpokes. |
| 139 cmd.append("--gtest_print_time") | 132 cmd.append("--gtest_print_time") |
| 140 if self._options.gtest_repeat: | 133 if self._options.gtest_repeat: |
| 141 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) | 134 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) |
| 142 return cmd | 135 return cmd |
| 143 | 136 |
| 144 def Run(self): | 137 def Run(self): |
| 145 ''' Runs the test specified by command-line argument --test ''' | 138 ''' Runs the test specified by command-line argument --test ''' |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 for t in options.test: | 479 for t in options.test: |
| 487 tests = ChromeTests(options, args, t) | 480 tests = ChromeTests(options, args, t) |
| 488 ret = tests.Run() | 481 ret = tests.Run() |
| 489 if ret: return ret | 482 if ret: return ret |
| 490 return 0 | 483 return 0 |
| 491 | 484 |
| 492 | 485 |
| 493 if __name__ == "__main__": | 486 if __name__ == "__main__": |
| 494 ret = _main(sys.argv) | 487 ret = _main(sys.argv) |
| 495 sys.exit(ret) | 488 sys.exit(ret) |
| OLD | NEW |