Debian Codegraph @

scripts/kprobes_test/is_probed.py

raw
1 #!/usr/bin/python
2
3 # Copyright (C) 2008, 2010 Red Hat Inc.
4 #
5 # This file is part of systemtap, and is free software. You can
6 # redistribute it and/or modify it under the terms of the GNU General
7 # Public License (GPL); either version 2, or (at your option) any
8 # later version.
9
10 import re
11 import sys
12 import os
13 from config_opts import config_opts
14
15 def parse_module_output():
16 # Parse the output file, looking for probe points
17 pp_re = re.compile(": (-?\d+) (\S+)$")
18 f = open(config_opts['probes_result'], 'r')
19 pp = dict()
20 line = f.readline()
21 while line:
22 match = pp_re.search(line)
23 if match:
24 pp[match.group(2)] = int(match.group(1))
25 line = f.readline()
26 f.close()
27
28 if len(pp.keys()) == 0:
29 print >>sys.stderr, "No data found?"
30 return 1
31
32 # Parse the list of probe points.
33 f = open(config_opts['probes_current'], 'r')
34 passed = open(config_opts['probes_passed'], 'a')
35 failed = open(config_opts['probes_failed'], 'a')
36 untriggered = open(config_opts['probes_untriggered'], 'a')
37 unregistered = open(config_opts['probes_unregistered'], 'a')
38 line = f.readline().strip()
39 while line:
40 if pp.has_key(line):
41 if pp[line] > 0:
42 passed.write(line + '\n')
43 elif pp[line] == 0:
44 untriggered.write(line + '\n')
45 elif pp[line] == -1:
46 unregistered.write(line + '\n')
47 else:
48 failed.write(line + '\n')
49 line = f.readline().strip()
50 f.close()
51 passed.close()
52 failed.close()
53 untriggered.close()
54 unregistered.close()
55 return 0
56
57 def main():
58 rc = parse_module_output()
59 sys.exit(rc)
60
61 if __name__ == "__main__":
62 main()