| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from collections import defaultdict | 5 from collections import defaultdict |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 import path_utils | 10 import path_utils |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 reports += ["\n".join(cur_supp)] | 29 reports += ["\n".join(cur_supp)] |
| 30 in_suppression = False | 30 in_suppression = False |
| 31 cur_supp = [] | 31 cur_supp = [] |
| 32 else: | 32 else: |
| 33 cur_supp += [" "*3 + line] | 33 cur_supp += [" "*3 + line] |
| 34 elif line == "{": | 34 elif line == "{": |
| 35 in_suppression = True | 35 in_suppression = True |
| 36 cur_supp = ["{"] | 36 cur_supp = ["{"] |
| 37 return reports,line | 37 return reports,line |
| 38 | 38 |
| 39 filenames = [ | |
| 40 "memcheck/suppressions.txt", | |
| 41 ] | |
| 42 # TODO(timurrrr): Support platform-specific suppressions | |
| 43 | |
| 44 all_suppressions = [] | |
| 45 suppressions_root = path_utils.ScriptDir() | 39 suppressions_root = path_utils.ScriptDir() |
| 46 | 40 |
| 47 for f in filenames: | 41 supp_filename = os.path.join(suppressions_root, |
| 48 supp_filename = os.path.join(suppressions_root, f) | 42 "memcheck", "suppressions.txt") |
| 49 all_suppressions += suppressions.ReadSuppressionsFromFile(supp_filename) | 43 common_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) |
| 44 |
| 45 supp_filename = os.path.join(suppressions_root, |
| 46 "memcheck", "suppressions_mac.txt") |
| 47 mac_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) |
| 50 | 48 |
| 51 # all_reports is a map {report: list of urls containing this report} | 49 # all_reports is a map {report: list of urls containing this report} |
| 52 all_reports = defaultdict(list) | 50 all_reports = defaultdict(list) |
| 53 | 51 |
| 54 for f in sys.argv[1:]: | 52 for f in sys.argv[1:]: |
| 55 f_reports, url = ReadReportsFromFile(f) | 53 f_reports, url = ReadReportsFromFile(f) |
| 56 for report in f_reports: | 54 for report in f_reports: |
| 57 all_reports[report] += [url] | 55 all_reports[report] += [url] |
| 58 | 56 |
| 59 reports_count = 0 | 57 reports_count = 0 |
| 60 for r in all_reports: | 58 for r in all_reports: |
| 59 if set([False]) == set([not re.search("%20Mac%20", url)\ |
| 60 for url in all_reports[r]]): |
| 61 # Include mac suppressions if the report is only present on Mac |
| 62 cur_supp = common_suppressions + mac_suppressions |
| 63 else: |
| 64 cur_supp = common_suppressions |
| 65 |
| 61 match = False | 66 match = False |
| 62 for s in all_suppressions: | 67 for s in cur_supp: |
| 63 if s.Match(r.split("\n")): | 68 if s.Match(r.split("\n")): |
| 64 match = True | 69 match = True |
| 65 break | 70 break |
| 66 if not match: | 71 if not match: |
| 67 reports_count += 1 | 72 reports_count += 1 |
| 68 print "===================================" | 73 print "===================================" |
| 69 print "This report observed in:" | 74 print "This report observed at" |
| 70 for url in all_reports[r]: | 75 for url in all_reports[r]: |
| 71 print " %s" % url | 76 print " %s" % url |
| 72 print "didn't match any suppressions:" | 77 print "didn't match any suppressions:" |
| 73 print r | 78 print r |
| 74 print "===================================" | 79 print "===================================" |
| 75 | 80 |
| 76 if reports_count > 0: | 81 if reports_count > 0: |
| 77 print "%d unique reports don't match any of the suppressions" % reports_count | 82 print "%d unique reports don't match any of the suppressions" % reports_count |
| 78 else: | 83 else: |
| 79 print "Congratulations! All reports are suppressed!" | 84 print "Congratulations! All reports are suppressed!" |
| 80 # TODO(timurrrr): also make sure none of the old suppressions | 85 # TODO(timurrrr): also make sure none of the old suppressions |
| 81 # were narrowed too much. | 86 # were narrowed too much. |
| OLD | NEW |