diff options
author | sr527 <sr527@cornell.edu> | 2012-06-20 17:51:00 -0400 |
---|---|---|
committer | sr527 <sr527@cornell.edu> | 2012-06-20 17:51:00 -0400 |
commit | 0fdaf98792034c8e4a39663d915864b215894f9d (patch) | |
tree | 98eb6550a9d0b43d1f6b03c2936f987b24c130fb /buildscripts | |
parent | d49d729311ac09f9e267b44f94d0a5ec1c5f66e8 (diff) | |
download | mongo-0fdaf98792034c8e4a39663d915864b215894f9d.tar.gz |
added aggregate tracefile python script
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/aggregate_tracefiles.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/buildscripts/aggregate_tracefiles.py b/buildscripts/aggregate_tracefiles.py new file mode 100644 index 00000000000..37d3ee03f79 --- /dev/null +++ b/buildscripts/aggregate_tracefiles.py @@ -0,0 +1,52 @@ +import subprocess +import os +import sys + +""" 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] + + + if subprocess.call(args) != 0: + die("lcov failed") + +def die(message): + sys.stderr.write(message + "\n") + sys.exit(1) + +def main (argv): + inputs = [] + + if len(argv) < 3: + print "Usage: " + argv[0] + " input.(info|txt) ... output.info" + sys.exit(1) + + for path in argv[1:-1]: + 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: + die("unrecognized file type") + + aggregate(inputs, argv[-1]) + + return 0 + +if __name__ == '__main__': + rc = main(sys.argv) or 0 + sys.exit(rc) |