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
4 # found in the LICENSE file.
6 from collections
import defaultdict
14 def ReadReportsFromFile(filename
):
15 """ Returns a list of (report_hash, report) and the URL of the report on the
18 input_file
= file(filename
, 'r')
19 # reports is a list of (error hash, report) pairs.
21 in_suppression
= False
23 # This stores the last error hash found while reading the file.
25 for line
in input_file
:
27 line
= line
.replace("</span><span class=\"stdout\">", "")
28 line
= line
.replace("</span><span class=\"stderr\">", "")
29 line
= line
.replace("<", "<")
30 line
= line
.replace(">", ">")
34 reports
+= [[last_hash
, "\n".join(cur_supp
)]]
35 in_suppression
= False
39 cur_supp
+= [" "*3 + line
]
43 elif line
.find("Suppression (error hash=#") == 0:
44 last_hash
= line
[25:41]
45 # The line at the end of the file is assumed to store the URL of the report.
50 supp
= suppressions
.GetSuppressions()
52 # all_reports is a map {report: list of urls containing this report}
53 all_reports
= defaultdict(list)
57 f_reports
, url
= ReadReportsFromFile(f
)
58 for (hash, report
) in f_reports
:
59 all_reports
[report
] += [url
]
60 report_hashes
[report
] = hash
64 cur_supp
= supp
['common_suppressions']
65 if all([re
.search("%20Mac%20|mac_valgrind", url
)
66 for url
in all_reports
[r
]]):
67 # Include mac suppressions if the report is only present on Mac
68 cur_supp
+= supp
['mac_suppressions']
69 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
71 cur_supp
+= supp
['win_suppressions']
72 elif all([re
.search("Linux%20", url
) for url
in all_reports
[r
]]):
73 cur_supp
+= supp
['linux_suppressions']
74 elif all([re
.search("%20Heapcheck", url
)
75 for url
in all_reports
[r
]]):
76 cur_supp
+= supp
['heapcheck_suppressions']
77 if all(["DrMemory" in url
for url
in all_reports
[r
]]):
78 cur_supp
+= supp
['drmem_suppressions']
79 if all(["DrMemory%20full" in url
for url
in all_reports
[r
]]):
80 cur_supp
+= supp
['drmem_full_suppressions']
84 if s
.Match(r
.split("\n")):
89 print "==================================="
90 print "This report observed at"
91 for url
in all_reports
[r
]:
93 print "didn't match any suppressions:"
94 print "Suppression (error hash=#%s#):" % (report_hashes
[r
])
96 print "==================================="
99 print ("%d unique reports don't match any of the suppressions" %
102 print "Congratulations! All reports are suppressed!"
103 # TODO(timurrrr): also make sure none of the old suppressions
104 # were narrowed too much.
107 if __name__
== "__main__":