diff options
-rwxr-xr-x | tools/heapcheck/PRESUBMIT.py | 8 | ||||
-rwxr-xr-x | tools/valgrind/memcheck/PRESUBMIT.py | 21 |
2 files changed, 27 insertions, 2 deletions
diff --git a/tools/heapcheck/PRESUBMIT.py b/tools/heapcheck/PRESUBMIT.py index 415400c..1b47afc 100755 --- a/tools/heapcheck/PRESUBMIT.py +++ b/tools/heapcheck/PRESUBMIT.py @@ -9,6 +9,7 @@ for more details on the presubmit API built into gcl. def CheckChange(input_api, output_api): """Checks the memcheck suppressions files for bad data.""" + suppressions = {} errors = [] skip_next_line = False func_re = input_api.re.compile('[a-z_.]+\(.+\)$') @@ -19,6 +20,13 @@ def CheckChange(input_api, output_api): continue if skip_next_line: + if suppressions.has_key(line): + errors.append('suppression with name "%s" at %s line %s has already ' + 'been defined at line %s' % (line, f.LocalPath(), + line_num, + suppressions[line][1])) + else: + suppressions[line] = (f, line_num) skip_next_line = False continue if line == '{': diff --git a/tools/valgrind/memcheck/PRESUBMIT.py b/tools/valgrind/memcheck/PRESUBMIT.py index a31a596..182c800 100755 --- a/tools/valgrind/memcheck/PRESUBMIT.py +++ b/tools/valgrind/memcheck/PRESUBMIT.py @@ -9,7 +9,12 @@ for more details on the presubmit API built into gcl. def CheckChange(input_api, output_api): """Checks the memcheck suppressions files for bad data.""" + suppressions = {} errors = [] + # skip_next_line has 3 possible values: + # - False: don't skip the next line. + # - 'skip_suppression_name': the next line is a suppression name, skip. + # - 'skip_param': the next line is a system call parameter error, skip. skip_next_line = False func_re = input_api.re.compile('[a-z_.]+\(.+\)$') for f, line_num, line in input_api.RightHandSideLines(lambda x: @@ -19,11 +24,23 @@ def CheckChange(input_api, output_api): continue if skip_next_line: + if skip_next_line == 'skip_suppression_name': + if suppressions.has_key(line): + errors.append('suppression with name "%s" at %s line %s has already ' + 'been defined at line %s' % (line, f.LocalPath(), + line_num, + suppressions[line][1])) + else: + suppressions[line] = (f, line_num) skip_next_line = False continue - if line == '{' or line == "Memcheck:Param": - skip_next_line = True + if line == '{': + skip_next_line = 'skip_suppression_name' continue + if line == "Memcheck:Param": + skip_next_line = 'skip_param' + continue + if (line.startswith('fun:') or line.startswith('obj:') or line.startswith('Memcheck:') or line == '}' or line == '...'): |