OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 ''' Runs various chrome tests through valgrind_test.py.''' | 6 ''' Runs various chrome tests through valgrind_test.py.''' |
7 | 7 |
8 import glob | 8 import glob |
9 import logging | 9 import logging |
10 import optparse | 10 import optparse |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if self._test not in self._test_list: | 43 if self._test not in self._test_list: |
44 raise TestNotFound("Unknown test: %s" % test) | 44 raise TestNotFound("Unknown test: %s" % test) |
45 | 45 |
46 if options.gtest_filter and options.gtest_filter != self._gtest_filter: | 46 if options.gtest_filter and options.gtest_filter != self._gtest_filter: |
47 raise MultipleGTestFiltersSpecified("Can not specify both --gtest_filter " | 47 raise MultipleGTestFiltersSpecified("Can not specify both --gtest_filter " |
48 "and --test %s" % test) | 48 "and --test %s" % test) |
49 | 49 |
50 self._options = options | 50 self._options = options |
51 self._args = args | 51 self._args = args |
52 | 52 |
53 script_dir = path_utils.ScriptDir() | 53 # Compute the top of the tree (the "source dir") from the script dir |
54 # Compute the top of the tree (the "source dir") from the script dir (where | 54 # (where this script lives). We assume that the script dir is in |
55 # this script lives). We assume that the script dir is in tools/valgrind/ | 55 # tools/drmemory/scripts relative to the top of the tree. |
56 # relative to the top of the tree. | 56 script_dir = os.path.dirname(path_utils.ScriptDir()) |
57 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) | 57 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) |
58 # since this path is used for string matching, make sure it's always | 58 # since this path is used for string matching, make sure it's always |
59 # an absolute Unix-style path | 59 # an absolute Unix-style path |
60 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') | 60 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') |
61 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") | 61 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") |
62 self._command_preamble = ["--source-dir=%s" % (self._source_dir)] | 62 self._command_preamble = ["--source-dir=%s" % (self._source_dir)] |
63 | 63 |
64 if not self._options.build_dir: | 64 if not self._options.build_dir: |
65 dirs = [ | 65 dirs = [ |
66 os.path.join(self._source_dir, "xcodebuild", "Debug"), | 66 os.path.join(self._source_dir, "xcodebuild", "Debug"), |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 cmd = self._DefaultCommand(tool, None, self._args) | 262 cmd = self._DefaultCommand(tool, None, self._args) |
263 self.SetupLdPath(False) | 263 self.SetupLdPath(False) |
264 return tool.Run(cmd, None) | 264 return tool.Run(cmd, None) |
265 | 265 |
266 def TestPDFiumUnitTests(self): | 266 def TestPDFiumUnitTests(self): |
267 return self.SimpleTest("pdfium_unittests", "pdfium_unittests") | 267 return self.SimpleTest("pdfium_unittests", "pdfium_unittests") |
268 | 268 |
269 def TestPDFiumEmbedderTests(self): | 269 def TestPDFiumEmbedderTests(self): |
270 return self.SimpleTest("pdfium_embeddertests", "pdfium_embeddertests") | 270 return self.SimpleTest("pdfium_embeddertests", "pdfium_embeddertests") |
271 | 271 |
| 272 def TestPDFiumTest(self, script_name): |
| 273 # Build the command line in 'cmd'. |
| 274 # It's going to be roughly |
| 275 # python valgrind_test.py ... |
| 276 # but we'll use the --indirect_pdfium_test flag to valgrind_test.py |
| 277 # to avoid valgrinding python. |
| 278 |
| 279 # Start by building the valgrind_test.py commandline. |
| 280 tool = valgrind_test.CreateTool(self._options.valgrind_tool) |
| 281 cmd = self._DefaultCommand(tool) |
| 282 cmd.append("--trace_children") |
| 283 cmd.append("--indirect_pdfium_test") |
| 284 cmd.append("--ignore_exit_code") |
| 285 # Now build script_cmd, the run_corpus_tests commandline. |
| 286 script = os.path.join(self._source_dir, "testing", "tools", script_name) |
| 287 script_cmd = ["python", script] |
| 288 if self._options.build_dir: |
| 289 script_cmd.extend(["--build-dir", self._options.build_dir]) |
| 290 # TODO(zhaoqin): it only runs in single process mode now, |
| 291 # need figure out why it does not work with test_one_file_parallel |
| 292 # in run_corpus_tests.py. |
| 293 if script_name == "run_corpus_tests.py": |
| 294 script_cmd.extend(["-j", "1"]) |
| 295 # Now run script_cmd with the wrapper in cmd |
| 296 cmd.append("--") |
| 297 cmd.extend(script_cmd) |
| 298 |
| 299 ret = tool.Run(cmd, "layout", min_runtime_in_seconds=0) |
| 300 return ret |
| 301 |
| 302 def TestPDFiumJavascript(self): |
| 303 return self.TestPDFiumTest("run_javascript_tests.py") |
| 304 |
| 305 def TestPDFiumPixel(self): |
| 306 return self.TestPDFiumTest("run_pixel_tests.py") |
| 307 |
| 308 def TestPDFiumCorpus(self): |
| 309 return self.TestPDFiumTest("run_corpus_tests.py") |
| 310 |
272 # The known list of tests. | 311 # The known list of tests. |
273 _test_list = { | 312 _test_list = { |
274 "cmdline" : RunCmdLine, | 313 "cmdline" : RunCmdLine, |
275 "pdfium_unittests": TestPDFiumUnitTests, | 314 "pdfium_corpus": TestPDFiumCorpus, |
276 "pdfium_embeddertests": TestPDFiumEmbedderTests, | 315 "pdfium_embeddertests": TestPDFiumEmbedderTests, |
| 316 "pdfium_javascript": TestPDFiumJavascript, |
| 317 "pdfium_pixel": TestPDFiumPixel, |
| 318 "pdfium_unittests": TestPDFiumUnitTests, |
277 } | 319 } |
278 | 320 |
279 | 321 |
280 def _main(): | 322 def _main(): |
281 parser = optparse.OptionParser("usage: %prog -b <dir> -t <test> " | 323 parser = optparse.OptionParser("usage: %prog -b <dir> -t <test> " |
282 "[-t <test> ...]") | 324 "[-t <test> ...]") |
283 | 325 |
284 parser.add_option("--help-tests", dest="help_tests", action="store_true", | 326 parser.add_option("--help-tests", dest="help_tests", action="store_true", |
285 default=False, help="List all available tests") | 327 default=False, help="List all available tests") |
286 parser.add_option("-b", "--build-dir", | 328 parser.add_option("-b", "--build-dir", |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 386 |
345 for t in options.test: | 387 for t in options.test: |
346 tests = ChromeTests(options, args, t) | 388 tests = ChromeTests(options, args, t) |
347 ret = tests.Run() | 389 ret = tests.Run() |
348 if ret: return ret | 390 if ret: return ret |
349 return 0 | 391 return 0 |
350 | 392 |
351 | 393 |
352 if __name__ == "__main__": | 394 if __name__ == "__main__": |
353 sys.exit(_main()) | 395 sys.exit(_main()) |
OLD | NEW |