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