Add codegen to the tracked files
[platform/upstream/gst-editing-services.git] / bindings / python / codegen / code-coverage.py
1 from __future__ import generators
2 import sys, os
3
4 def read_symbols(file, type=None, dynamic=0):
5     if dynamic:
6         cmd = 'nm -D %s' % file
7     else:
8         cmd = 'nm %s' % file
9     for line in os.popen(cmd, 'r'):
10         if line[0] != ' ':  # has an address as first bit of line
11             while line[0] != ' ':
12                 line = line[1:]
13         while line[0] == ' ':
14             line = line[1:]
15         # we should be up to "type symbolname" now
16         sym_type = line[0]
17         symbol = line[1:].strip()
18
19         if not type or type == sym_type:
20             yield symbol
21
22 def main():
23     if len(sys.argv) != 3:
24         sys.stderr.write('usage: coverage-check library.so wrapper.so\n')
25         sys.exit(1)
26     library = sys.argv[1]
27     wrapper = sys.argv[2]
28
29     # first create a dict with all referenced symbols in the wrapper
30     # should really be a set, but a dict will do ...
31     wrapper_symbols = {}
32     for symbol in read_symbols(wrapper, type='U', dynamic=1):
33         wrapper_symbols[symbol] = 1
34
35     # now go through the library looking for matches on the defined symbols:
36     for symbol in read_symbols(library, type='T', dynamic=1):
37         if symbol[0] == '_': continue
38         if symbol not in wrapper_symbols:
39             print symbol
40
41 if __name__ == '__main__':
42     main()