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

Side by Side Diff: testing/tools/run_pixel_tests.py

Issue 1464453003: Enable Dr. Memory to run javascript, pixel, and corpus tests (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: PTAL Created 5 years, 1 month 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The PDFium Authors. All rights reserved. 2 # Copyright 2015 The PDFium 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 import optparse 6 import optparse
7 import os 7 import os
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 import common 12 import common
13 import pngdiffer 13 import pngdiffer
14 import suppressor 14 import suppressor
15 15
16 # Nomenclature: 16 # Nomenclature:
17 # x_root - "x" 17 # x_root - "x"
18 # x_filename - "x.ext" 18 # x_filename - "x.ext"
19 # x_path - "path/to/a/b/c/x.ext" 19 # x_path - "path/to/a/b/c/x.ext"
20 # c_dir - "path/to/a/b/c" 20 # c_dir - "path/to/a/b/c"
21 21
22 def generate_and_test(input_filename, source_dir, working_dir, 22 def generate_and_test(input_filename, source_dir, working_dir,
23 fixup_path, pdfium_test_path, image_differ): 23 fixup_path, pdfium_test_path, image_differ,
24 drmem_wrapper):
24 input_root, _ = os.path.splitext(input_filename) 25 input_root, _ = os.path.splitext(input_filename)
25 input_path = os.path.join(source_dir, input_root + '.in') 26 input_path = os.path.join(source_dir, input_root + '.in')
26 pdf_path = os.path.join(working_dir, input_root + '.pdf') 27 pdf_path = os.path.join(working_dir, input_root + '.pdf')
27 28
28 # Remove any existing generated images from previous runs. 29 # Remove any existing generated images from previous runs.
29 actual_images = image_differ.GetActualFiles( 30 actual_images = image_differ.GetActualFiles(
30 input_filename, source_dir, working_dir) 31 input_filename, source_dir, working_dir)
31 for image in actual_images: 32 for image in actual_images:
32 if os.path.exists(image): 33 if os.path.exists(image):
33 os.remove(image) 34 os.remove(image)
34 35
35 try: 36 try:
36 sys.stdout.flush() 37 sys.stdout.flush()
37 subprocess.check_call( 38 subprocess.check_call(
38 [sys.executable, fixup_path, '--output-dir=' + working_dir, input_path]) 39 [sys.executable, fixup_path, '--output-dir=' + working_dir, input_path])
39 subprocess.check_call([pdfium_test_path, '--png', pdf_path]) 40 # add Dr. Memory wrapper if exist
41 cmd_to_run = common.DrMemoryWrapper(drmem_wrapper, input_root)
42 cmd_to_run.extend([pdfium_test_path, '--png', pdf_path])
43 # run test
44 subprocess.check_call(cmd_to_run)
40 except subprocess.CalledProcessError as e: 45 except subprocess.CalledProcessError as e:
41 print "FAILURE: " + input_filename + "; " + str(e) 46 print "FAILURE: " + input_filename + "; " + str(e)
42 return False 47 return False
43 if image_differ.HasDifferences(input_filename, source_dir, working_dir): 48 if image_differ.HasDifferences(input_filename, source_dir, working_dir):
44 print "FAILURE: " + input_filename 49 print "FAILURE: " + input_filename
45 return False 50 return False
46 return True 51 return True
47 52
48 53
49 def main(): 54 def main():
50 parser = optparse.OptionParser() 55 parser = optparse.OptionParser()
51 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), 56 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
52 help='relative path from the base source directory') 57 help='relative path from the base source directory')
58 parser.add_option('--wrapper', default='', dest="wrapper",
59 help='Dr. Memory wrapper for running test under Dr. Memory')
53 options, args = parser.parse_args() 60 options, args = parser.parse_args()
54 finder = common.DirectoryFinder(options.build_dir) 61 finder = common.DirectoryFinder(options.build_dir)
55 fixup_path = finder.ScriptPath('fixup_pdf_template.py') 62 fixup_path = finder.ScriptPath('fixup_pdf_template.py')
56 source_dir = finder.TestingDir(os.path.join('resources', 'pixel')) 63 source_dir = finder.TestingDir(os.path.join('resources', 'pixel'))
57 pdfium_test_path = finder.ExecutablePath('pdfium_test') 64 pdfium_test_path = finder.ExecutablePath('pdfium_test')
58 if not os.path.exists(pdfium_test_path): 65 if not os.path.exists(pdfium_test_path):
59 print "FAILURE: Can't find test executable '%s'" % pdfium_test_path 66 print "FAILURE: Can't find test executable '%s'" % pdfium_test_path
60 print "Use --build-dir to specify its location." 67 print "Use --build-dir to specify its location."
61 return 1 68 return 1
62 working_dir = finder.WorkingDir(os.path.join('testing', 'pixel')) 69 working_dir = finder.WorkingDir(os.path.join('testing', 'pixel'))
(...skipping 12 matching lines...) Expand all
75 82
76 failures = [] 83 failures = []
77 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$') 84 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
78 for input_filename in input_files: 85 for input_filename in input_files:
79 if input_file_re.match(input_filename): 86 if input_file_re.match(input_filename):
80 input_path = os.path.join(source_dir, input_filename) 87 input_path = os.path.join(source_dir, input_filename)
81 if os.path.isfile(input_path): 88 if os.path.isfile(input_path):
82 if test_suppressor.IsSuppressed(input_filename): 89 if test_suppressor.IsSuppressed(input_filename):
83 continue 90 continue
84 if not generate_and_test(input_filename, source_dir, working_dir, 91 if not generate_and_test(input_filename, source_dir, working_dir,
85 fixup_path, pdfium_test_path, image_differ): 92 fixup_path, pdfium_test_path, image_differ,
93 options.wrapper):
86 failures.append(input_path) 94 failures.append(input_path)
87 95
88 if failures: 96 if failures:
89 failures.sort() 97 failures.sort()
90 print '\n\nSummary of Failures:' 98 print '\n\nSummary of Failures:'
91 for failure in failures: 99 for failure in failures:
92 print failure 100 print failure
93 return 1 101 return 1
94 return 0 102 return 0
95 103
96 104
97 if __name__ == '__main__': 105 if __name__ == '__main__':
98 sys.exit(main()) 106 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698