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

Side by Side Diff: tools/valgrind/chrome_tests.py

Issue 4054004: Move all Valgrind/TSan/Dr.Memory gtest exclude files to tools/valgrind/gtest_... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 # relative to the top of the tree. 82 # relative to the top of the tree.
83 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) 83 self._source_dir = os.path.dirname(os.path.dirname(script_dir))
84 # since this path is used for string matching, make sure it's always 84 # since this path is used for string matching, make sure it's always
85 # an absolute Unix-style path 85 # an absolute Unix-style path
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 module_dir = os.path.join(self._source_dir, module)
93
94 # We need multiple data dirs, the current script directory and a module
95 # specific one. The global suppression file lives in our directory, and the
96 # module specific suppression file lives with the module.
97 self._data_dirs = [path_utils.ScriptDir()]
98
99 if module == "chrome":
100 # unfortunately, not all modules have the same directory structure
101 self._data_dirs.append(os.path.join(module_dir, "test", "data",
102 "valgrind"))
103 else:
104 self._data_dirs.append(os.path.join(module_dir, "data", "valgrind"))
105 92
106 if not self._options.build_dir: 93 if not self._options.build_dir:
107 if common.IsWine(): 94 if common.IsWine():
108 self._options.build_dir = os.path.join( 95 self._options.build_dir = os.path.join(
109 self._source_dir, "chrome", "Debug") 96 self._source_dir, "chrome", "Debug")
110 else: 97 else:
111 dirs = [ 98 dirs = [
112 os.path.join(self._source_dir, "xcodebuild", "Debug"), 99 os.path.join(self._source_dir, "xcodebuild", "Debug"),
113 os.path.join(self._source_dir, "sconsbuild", "Debug"), 100 os.path.join(self._source_dir, "sconsbuild", "Debug"),
114 os.path.join(self._source_dir, "out", "Debug"), 101 os.path.join(self._source_dir, "out", "Debug"),
115 ] 102 ]
116 if exe: 103 if exe:
117 self._options.build_dir = FindDirContainingNewestFile(dirs, exe) 104 self._options.build_dir = FindDirContainingNewestFile(dirs, exe)
118 else: 105 else:
119 self._options.build_dir = FindNewestDir(dirs) 106 self._options.build_dir = FindNewestDir(dirs)
120 107
121 cmd = list(self._command_preamble) 108 cmd = list(self._command_preamble)
122 for directory in self._data_dirs: 109
123 tool_name = tool.ToolName(); 110 # Find all suppressions matching the following pattern:
124 suppression_file = os.path.join(directory, 111 # tools/valgrind/TOOL/suppressions[_PLATFORM].txt
125 "%s/suppressions.txt" % tool_name) 112 # and list them with --suppressions= prefix.
126 if os.path.exists(suppression_file): 113 script_dir = path_utils.ScriptDir()
127 cmd.append("--suppressions=%s" % suppression_file) 114 tool_name = tool.ToolName();
128 # Platform specific suppression 115 suppression_file = os.path.join(script_dir, tool_name, "suppressions.txt")
129 for suppression_platform in common.PlatformNames(): 116 if os.path.exists(suppression_file):
130 suppression_file_platform = \ 117 cmd.append("--suppressions=%s" % suppression_file)
131 os.path.join(directory, 118 # Platform-specific suppression
132 '%s/suppressions_%s.txt' % (tool_name, suppression_platform)) 119 for platform in common.PlatformNames():
133 if os.path.exists(suppression_file_platform): 120 platform_suppression_file = \
134 cmd.append("--suppressions=%s" % suppression_file_platform) 121 os.path.join(script_dir, tool_name, 'suppressions_%s.txt' % platform)
122 if os.path.exists(platform_suppression_file):
123 cmd.append("--suppressions=%s" % platform_suppression_file)
135 124
136 if self._options.valgrind_tool_flags: 125 if self._options.valgrind_tool_flags:
137 cmd += self._options.valgrind_tool_flags.split(" ") 126 cmd += self._options.valgrind_tool_flags.split(" ")
138 if valgrind_test_args != None: 127 if valgrind_test_args != None:
139 for arg in valgrind_test_args: 128 for arg in valgrind_test_args:
140 cmd.append(arg) 129 cmd.append(arg)
141 if exe: 130 if exe:
142 if common.IsWine(): 131 if common.IsWine():
143 cmd.append(os.environ.get('WINE')) 132 cmd.append(os.environ.get('WINE'))
144 exe = exe + '.exe' 133 exe = exe + '.exe'
145 cmd.append(os.path.join(self._options.build_dir, exe)) 134 cmd.append(os.path.join(self._options.build_dir, exe))
146 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time 135 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time
147 # so we can find the slowpokes. 136 # so we can find the slowpokes.
148 cmd.append("--gtest_print_time") 137 cmd.append("--gtest_print_time")
149 if self._options.gtest_repeat: 138 if self._options.gtest_repeat:
150 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) 139 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat)
151 return cmd 140 return cmd
152 141
153 def Run(self): 142 def Run(self):
154 ''' Runs the test specified by command-line argument --test ''' 143 ''' Runs the test specified by command-line argument --test '''
155 logging.info("running test %s" % (self._test)) 144 logging.info("running test %s" % (self._test))
156 return self._test_list[self._test](self) 145 return self._test_list[self._test](self)
157 146
158 def _ReadGtestFilterFile(self, tool, name, cmd): 147 def _ReadGtestFilterFile(self, tool, name, cmd):
159 '''Read a file which is a list of tests to filter out with --gtest_filter 148 '''Read a file which is a list of tests to filter out with --gtest_filter
160 and append the command-line option to cmd. 149 and append the command-line option to cmd.
161 ''' 150 '''
162 filters = [] 151 filters = []
163 for directory in self._data_dirs: 152 gtest_files_dir = os.path.join(path_utils.ScriptDir(), "gtest_exclude")
164 gtest_filter_files = [ 153
165 os.path.join(directory, name + ".gtest.txt"), 154 gtest_filter_files = [
166 os.path.join(directory, name + ".gtest-%s.txt" % \ 155 os.path.join(gtest_files_dir, name + ".gtest.txt"),
167 tool.ToolName())] 156 os.path.join(gtest_files_dir, name + ".gtest-%s.txt" % tool.ToolName())]
168 for platform_suffix in common.PlatformNames(): 157 for platform_suffix in common.PlatformNames():
169 gtest_filter_files += [ 158 gtest_filter_files += [
170 os.path.join(directory, name + ".gtest_%s.txt" % platform_suffix), 159 os.path.join(gtest_files_dir, name + ".gtest_%s.txt" % platform_suffix),
171 os.path.join(directory, name + ".gtest-%s_%s.txt" % \ 160 os.path.join(gtest_files_dir, name + ".gtest-%s_%s.txt" % \
172 (tool.ToolName(), platform_suffix))] 161 (tool.ToolName(), platform_suffix))]
173 for filename in gtest_filter_files: 162 for filename in gtest_filter_files:
174 if os.path.exists(filename): 163 if not os.path.exists(filename):
175 logging.info("reading gtest filters from %s" % filename) 164 logging.info("gtest filter file %s not found - skipping" % filename)
176 f = open(filename, 'r') 165 continue
177 for line in f.readlines(): 166 logging.info("Reading gtest filters from %s" % filename)
178 if line.startswith("#") or line.startswith("//") or line.isspace(): 167 f = open(filename, 'r')
179 continue 168 for line in f.readlines():
180 line = line.rstrip() 169 if line.startswith("#") or line.startswith("//") or line.isspace():
181 test_prefixes = ["FLAKY", "FAILS"] 170 continue
182 for p in test_prefixes: 171 line = line.rstrip()
183 # Strip prefixes from the test names. 172 test_prefixes = ["FLAKY", "FAILS"]
184 line = line.replace(".%s_" % p, ".") 173 for p in test_prefixes:
185 # Exclude the original test name. 174 # Strip prefixes from the test names.
186 filters.append(line) 175 line = line.replace(".%s_" % p, ".")
187 if line[-2:] != ".*": 176 # Exclude the original test name.
188 # List all possible prefixes if line doesn't end with ".*". 177 filters.append(line)
189 for p in test_prefixes: 178 if line[-2:] != ".*":
190 filters.append(line.replace(".", ".%s_" % p)) 179 # List all possible prefixes if line doesn't end with ".*".
180 for p in test_prefixes:
181 filters.append(line.replace(".", ".%s_" % p))
191 # Get rid of duplicates. 182 # Get rid of duplicates.
192 filters = set(filters) 183 filters = set(filters)
193 gtest_filter = self._gtest_filter 184 gtest_filter = self._gtest_filter
194 if len(filters): 185 if len(filters):
195 if gtest_filter: 186 if gtest_filter:
196 gtest_filter += ":" 187 gtest_filter += ":"
197 if gtest_filter.find("-") < 0: 188 if gtest_filter.find("-") < 0:
198 gtest_filter += "-" 189 gtest_filter += "-"
199 else: 190 else:
200 gtest_filter = "-" 191 gtest_filter = "-"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 for t in options.test: 443 for t in options.test:
453 tests = ChromeTests(options, args, t) 444 tests = ChromeTests(options, args, t)
454 ret = tests.Run() 445 ret = tests.Run()
455 if ret: return ret 446 if ret: return ret
456 return 0 447 return 0
457 448
458 449
459 if __name__ == "__main__": 450 if __name__ == "__main__":
460 ret = _main(sys.argv) 451 ret = _main(sys.argv)
461 sys.exit(ret) 452 sys.exit(ret)
OLDNEW
« no previous file with comments | « net/data/valgrind/suppressions.txt ('k') | tools/valgrind/gtest_exclude/app_unittests.gtest-tsan.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698