summaryrefslogtreecommitdiff
path: root/buildscripts/aggregate_tracefiles.py
diff options
context:
space:
mode:
authorsr527 <sr527@cornell.edu>2012-06-20 17:51:00 -0400
committersr527 <sr527@cornell.edu>2012-06-20 17:51:00 -0400
commit0fdaf98792034c8e4a39663d915864b215894f9d (patch)
tree98eb6550a9d0b43d1f6b03c2936f987b24c130fb /buildscripts/aggregate_tracefiles.py
parentd49d729311ac09f9e267b44f94d0a5ec1c5f66e8 (diff)
downloadmongo-0fdaf98792034c8e4a39663d915864b215894f9d.tar.gz
added aggregate tracefile python script
Diffstat (limited to 'buildscripts/aggregate_tracefiles.py')
-rw-r--r--buildscripts/aggregate_tracefiles.py52
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)