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 from collections import defaultdict | 6 from collections import defaultdict |
7 import os | 7 import os |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
11 import path_utils | |
12 | |
13 import suppressions | 11 import suppressions |
14 | 12 |
15 | 13 |
16 def ReadReportsFromFile(filename): | 14 def ReadReportsFromFile(filename): |
17 """ Returns a list of (report_hash, report) and the URL of the report on the | 15 """ Returns a list of (report_hash, report) and the URL of the report on the |
18 waterfall. | 16 waterfall. |
19 """ | 17 """ |
20 input_file = file(filename, 'r') | 18 input_file = file(filename, 'r') |
21 # reports is a list of (error hash, report) pairs. | 19 # reports is a list of (error hash, report) pairs. |
22 reports = [] | 20 reports = [] |
(...skipping 19 matching lines...) Expand all Loading... |
42 elif line == "{": | 40 elif line == "{": |
43 in_suppression = True | 41 in_suppression = True |
44 cur_supp = ["{"] | 42 cur_supp = ["{"] |
45 elif line.find("Suppression (error hash=#") == 0: | 43 elif line.find("Suppression (error hash=#") == 0: |
46 last_hash = line[25:41] | 44 last_hash = line[25:41] |
47 # The line at the end of the file is assumed to store the URL of the report. | 45 # The line at the end of the file is assumed to store the URL of the report. |
48 return reports,line | 46 return reports,line |
49 | 47 |
50 | 48 |
51 def main(argv): | 49 def main(argv): |
52 suppressions_root = path_utils.ScriptDir() | 50 supp = suppressions.GetSuppressions() |
53 JOIN = os.path.join | |
54 | |
55 supp_filename = JOIN(suppressions_root, "memcheck", "suppressions.txt") | |
56 vg_common = suppressions.ReadSuppressionsFromFile(supp_filename) | |
57 supp_filename = JOIN(suppressions_root, "tsan", "suppressions.txt") | |
58 tsan_common = suppressions.ReadSuppressionsFromFile(supp_filename) | |
59 common_suppressions = vg_common + tsan_common | |
60 | |
61 supp_filename = JOIN(suppressions_root, "memcheck", "suppressions_mac.txt") | |
62 vg_mac = suppressions.ReadSuppressionsFromFile(supp_filename) | |
63 supp_filename = JOIN(suppressions_root, "tsan", "suppressions_mac.txt") | |
64 tsan_mac = suppressions.ReadSuppressionsFromFile(supp_filename) | |
65 mac_suppressions = vg_mac + tsan_mac | |
66 | |
67 supp_filename = JOIN(suppressions_root, "tsan", "suppressions_win32.txt") | |
68 tsan_win = suppressions.ReadSuppressionsFromFile(supp_filename) | |
69 win_suppressions = tsan_win | |
70 | |
71 supp_filename = JOIN(suppressions_root, "..", "heapcheck", "suppressions.txt") | |
72 heapcheck_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) | |
73 | |
74 supp_filename = JOIN(suppressions_root, "drmemory", "suppressions.txt") | |
75 drmem_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) | |
76 supp_filename = JOIN(suppressions_root, "drmemory", "suppressions_full.txt") | |
77 drmem_full_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) | |
78 | 51 |
79 # all_reports is a map {report: list of urls containing this report} | 52 # all_reports is a map {report: list of urls containing this report} |
80 all_reports = defaultdict(list) | 53 all_reports = defaultdict(list) |
81 report_hashes = {} | 54 report_hashes = {} |
82 | 55 |
83 for f in argv: | 56 for f in argv: |
84 f_reports, url = ReadReportsFromFile(f) | 57 f_reports, url = ReadReportsFromFile(f) |
85 for (hash, report) in f_reports: | 58 for (hash, report) in f_reports: |
86 all_reports[report] += [url] | 59 all_reports[report] += [url] |
87 report_hashes[report] = hash | 60 report_hashes[report] = hash |
88 | 61 |
89 reports_count = 0 | 62 reports_count = 0 |
90 for r in all_reports: | 63 for r in all_reports: |
91 cur_supp = common_suppressions | 64 cur_supp = supp['common_suppressions'] |
92 if all([re.search("%20Mac%20|mac_valgrind", url) | 65 if all([re.search("%20Mac%20|mac_valgrind", url) |
93 for url in all_reports[r]]): | 66 for url in all_reports[r]]): |
94 # Include mac suppressions if the report is only present on Mac | 67 # Include mac suppressions if the report is only present on Mac |
95 cur_supp += mac_suppressions | 68 cur_supp += supp['mac_suppressions'] |
96 elif all([re.search("Windows%20", url) for url in all_reports[r]]): | 69 elif all([re.search("Windows%20", url) for url in all_reports[r]]): |
97 # Include win32 suppressions if the report is only present on Windows | 70 # Include win32 suppressions if the report is only present on Windows |
98 cur_supp += win_suppressions | 71 cur_supp += supp['win_suppressions'] |
99 elif all([re.search("%20Heapcheck", url) | 72 elif all([re.search("%20Heapcheck", url) |
100 for url in all_reports[r]]): | 73 for url in all_reports[r]]): |
101 cur_supp += heapcheck_suppressions | 74 cur_supp += supp['heapcheck_suppressions'] |
102 if all(["DrMemory" in url for url in all_reports[r]]): | 75 if all(["DrMemory" in url for url in all_reports[r]]): |
103 cur_supp += drmem_suppressions | 76 cur_supp += supp['drmem_suppressions'] |
104 if all(["DrMemory%20full" in url for url in all_reports[r]]): | 77 if all(["DrMemory%20full" in url for url in all_reports[r]]): |
105 cur_supp += drmem_full_suppressions | 78 cur_supp += supp['drmem_full_suppressions'] |
106 | 79 |
107 match = False | 80 match = False |
108 for s in cur_supp: | 81 for s in cur_supp: |
109 if s.Match(r.split("\n")): | 82 if s.Match(r.split("\n")): |
110 match = True | 83 match = True |
111 break | 84 break |
112 if not match: | 85 if not match: |
113 reports_count += 1 | 86 reports_count += 1 |
114 print "===================================" | 87 print "===================================" |
115 print "This report observed at" | 88 print "This report observed at" |
116 for url in all_reports[r]: | 89 for url in all_reports[r]: |
117 print " %s" % url | 90 print " %s" % url |
118 print "didn't match any suppressions:" | 91 print "didn't match any suppressions:" |
119 print "Suppression (error hash=#%s#):" % (report_hashes[r]) | 92 print "Suppression (error hash=#%s#):" % (report_hashes[r]) |
120 print r | 93 print r |
121 print "===================================" | 94 print "===================================" |
122 | 95 |
123 if reports_count > 0: | 96 if reports_count > 0: |
124 print ("%d unique reports don't match any of the suppressions" % | 97 print ("%d unique reports don't match any of the suppressions" % |
125 reports_count) | 98 reports_count) |
126 else: | 99 else: |
127 print "Congratulations! All reports are suppressed!" | 100 print "Congratulations! All reports are suppressed!" |
128 # TODO(timurrrr): also make sure none of the old suppressions | 101 # TODO(timurrrr): also make sure none of the old suppressions |
129 # were narrowed too much. | 102 # were narrowed too much. |
130 | 103 |
131 | 104 |
132 if __name__ == "__main__": | 105 if __name__ == "__main__": |
133 main(sys.argv[1:]) | 106 main(sys.argv[1:]) |
OLD | NEW |