1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 from collections
import defaultdict
15 def ReadReportsFromFile(filename
):
16 """ Returns a list of (report_hash, report) and the URL of the report on the
19 input_file
= file(filename
, 'r')
20 # reports is a list of (error hash, report) pairs.
22 in_suppression
= False
24 # This stores the last error hash found while reading the file.
26 for line
in input_file
:
28 line
= line
.replace("</span><span class=\"stdout\">", "")
29 line
= line
.replace("</span><span class=\"stderr\">", "")
30 line
= line
.replace("<", "<")
31 line
= line
.replace(">", ">")
35 reports
+= [[last_hash
, "\n".join(cur_supp
)]]
36 in_suppression
= False
40 cur_supp
+= [" "*3 + line
]
44 elif line
.find("Suppression (error hash=#") == 0:
45 last_hash
= line
[25:41]
46 # The line at the end of the file is assumed to store the URL of the report.
51 suppressions_root
= path_utils
.ScriptDir()
54 supp_filename
= JOIN(suppressions_root
, "memcheck", "suppressions.txt")
55 vg_common
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
56 supp_filename
= JOIN(suppressions_root
, "tsan", "suppressions.txt")
57 tsan_common
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
58 common_suppressions
= vg_common
+ tsan_common
60 supp_filename
= JOIN(suppressions_root
, "memcheck", "suppressions_mac.txt")
61 vg_mac
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
62 supp_filename
= JOIN(suppressions_root
, "tsan", "suppressions_mac.txt")
63 tsan_mac
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
64 mac_suppressions
= vg_mac
+ tsan_mac
66 supp_filename
= JOIN(suppressions_root
, "tsan", "suppressions_win32.txt")
67 tsan_win
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
68 win_suppressions
= tsan_win
70 supp_filename
= JOIN(suppressions_root
, "..", "heapcheck", "suppressions.txt")
71 heapcheck_suppressions
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
73 supp_filename
= JOIN(suppressions_root
, "drmemory", "suppressions.txt")
74 drmem_suppressions
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
75 supp_filename
= JOIN(suppressions_root
, "drmemory", "suppressions_full.txt")
76 drmem_full_suppressions
= suppressions
.ReadSuppressionsFromFile(supp_filename
)
78 # all_reports is a map {report: list of urls containing this report}
79 all_reports
= defaultdict(list)
83 f_reports
, url
= ReadReportsFromFile(f
)
84 for (hash, report
) in f_reports
:
85 all_reports
[report
] += [url
]
86 report_hashes
[report
] = hash
90 cur_supp
= common_suppressions
91 if all([re
.search("%20Mac%20|mac_valgrind", url
)
92 for url
in all_reports
[r
]]):
93 # Include mac suppressions if the report is only present on Mac
94 cur_supp
+= mac_suppressions
95 elif all([re
.search("Windows%20", url
) for url
in all_reports
[r
]]):
96 # Include win32 suppressions if the report is only present on Windows
97 cur_supp
+= win_suppressions
98 elif all([re
.search("%20Heapcheck", url
)
99 for url
in all_reports
[r
]]):
100 cur_supp
+= heapcheck_suppressions
101 if all(["DrMemory" in url
for url
in all_reports
[r
]]):
102 cur_supp
+= drmem_suppressions
103 if all(["DrMemory%20full" in url
for url
in all_reports
[r
]]):
104 cur_supp
+= drmem_full_suppressions
108 if s
.Match(r
.split("\n")):
113 print "==================================="
114 print "This report observed at"
115 for url
in all_reports
[r
]:
117 print "didn't match any suppressions:"
118 print "Suppression (error hash=#%s#):" % (report_hashes
[r
])
120 print "==================================="
122 if reports_count
> 0:
123 print ("%d unique reports don't match any of the suppressions" %
126 print "Congratulations! All reports are suppressed!"
127 # TODO(timurrrr): also make sure none of the old suppressions
128 # were narrowed too much.
131 if __name__
== "__main__":