blob: a56b9d3f157891108f0f79eea3445a674581c9c6 (
plain)
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
52
53
54
55
|
import subprocess
import os
import sys
from optparse import OptionParser
""" This script aggregates several tracefiles into one tracefile
All but the last argument are input tracefiles or .txt files which list tracefiles.
The last argument is the tracefile to which the output will be written
"""
def aggregate(inputs, output):
"""Aggregates the tracefiles given in inputs to a tracefile given by output"""
args = ['lcov']
for name in inputs:
args += ['-a', name]
args += ['-o', output]
return subprocess.call(args)
def die(message):
sys.stderr.write(message + "\n")
return 1
def main ():
inputs = []
usage = "usage: %prog [options] input1.info input2.info ..."
parser = OptionParser(usage=usage)
parser.add_option('-o', '--output', dest="output",
help="tracefile to which output will be written")
(options, args) = parser.parse_args()
if len(args) == 0:
return die("must supply input files")
for path in args:
name, ext = os.path.splitext(path)
if ext == '.info':
if os.path.getsize(path) > 0:
inputs.append(path)
elif ext == '.txt':
inputs += [line.strip() for line in open(path)
if os.path.getsize(line.strip()) > 0]
else:
return die("unrecognized file type")
return aggregate(inputs, options.output)
if __name__ == '__main__':
rc = main() or 0
sys.exit(rc)
|