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 """ | 5 """ |
6 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 6 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
7 for more details on the presubmit API built into gcl. | 7 for more details on the presubmit API built into gcl. |
8 """ | 8 """ |
9 | 9 |
10 def CheckChange(input_api, output_api): | 10 def CheckChange(input_api, output_api): |
11 """Checks the memcheck suppressions files for bad data.""" | 11 """Checks the memcheck suppressions files for bad data.""" |
12 errors = [] | 12 errors = [] |
13 skip_next_line = False | 13 skip_next_line = False |
14 func_re = input_api.re.compile('[a-z_.]+\(.+\)$') | 14 func_re = input_api.re.compile('[a-z_.]+\(.+\)$') |
15 for f, line_num, line in input_api.RightHandSideLines(lambda x: | 15 for f, line_num, line in input_api.RightHandSideLines(lambda x: |
16 x.LocalPath().endswith('.txt')): | 16 x.LocalPath().endswith('.txt')): |
17 line = line.lstrip() | 17 line = line.lstrip() |
18 if line.startswith('#') or not line: | 18 if line.startswith('#') or not line: |
19 continue | 19 continue |
20 | 20 |
21 if skip_next_line: | 21 if skip_next_line: |
22 skip_next_line = False | 22 skip_next_line = False |
23 continue | 23 continue |
24 if line == '{' or line == "Memcheck:Param": | 24 if line == '{': |
25 skip_next_line = True | 25 skip_next_line = True |
26 continue | 26 continue |
27 if (line.startswith('fun:') or line.startswith('obj:') or | 27 if (line.startswith('fun:') or line.startswith('obj:') or |
28 line.startswith('Memcheck:') or line == '}' or | 28 line == 'Heapcheck:Leak' or line == '}' or |
29 line == '...'): | 29 line == '...'): |
30 continue | 30 continue |
31 if func_re.match(line): | 31 if func_re.match(line): |
32 continue | 32 continue |
33 errors.append('"%s" is probably wrong: %s line %s' % (line, f.LocalPath(), | 33 errors.append('"%s" is probably wrong: %s line %s' % (line, f.LocalPath(), |
34 line_num)) | 34 line_num)) |
35 if errors: | 35 if errors: |
36 return [output_api.PresubmitError('\n'.join(errors))] | 36 return [output_api.PresubmitError('\n'.join(errors))] |
37 return [] | 37 return [] |
38 | 38 |
39 def CheckChangeOnUpload(input_api, output_api): | 39 def CheckChangeOnUpload(input_api, output_api): |
40 return CheckChange(input_api, output_api) | 40 return CheckChange(input_api, output_api) |
41 | 41 |
42 def CheckChangeOnCommit(input_api, output_api): | 42 def CheckChangeOnCommit(input_api, output_api): |
43 return CheckChange(input_api, output_api) | 43 return CheckChange(input_api, output_api) |
44 | |
45 def GetPreferredTrySlaves(): | |
46 return ['linux_valgrind', 'mac_valgrind'] | |
OLD | NEW |