-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_suppressions.py
51 lines (34 loc) · 1.03 KB
/
parse_suppressions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Crude parser for an LSAN suppression file.
import sys
def load_suppressions(fname):
try:
f = open(fname, 'r')
except:
sys.stderr.write('Error opening file ' + fname + '\n')
exit(-1)
supps = []
for l in f:
if len(l) == 1:
# blank line
continue
if l[0] == '#':
# comment
continue
if not l.startswith('leak:'):
print 'Expected line to start with "#" or "leak:":', l[:-1]
exit(-1)
supps.append(l[5:-1])
f.close()
return supps
def print_suppressions(supps):
for s in supps:
print s
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write('Not enough arguments.\n')
exit()
print_suppressions(load_suppressions(sys.argv[1]))