#!/usr/bin/env python import sys import getopt import re import os # re patterns for the following line: # TOTALCOV -- '../../MConfig.c': Lines(1020) - executed:1.37% # line_prog = re.compile(".*TOTALCOV -- (.*): Lines\(([0-9]+)\) - executed:(.+)%.*") count_pat = re.compile(r'.*[fF]ailures?:\s*(\d+),\s*[eE]rrors?: (\d+)') loc_pat = re.compile(r"Entering directory `(.*)'$") # Given file name, open and parse it, expecting output generated by 'gcov' coverage tool # argument: file path to gcov output file # argument: Diction to store results from the file def process_file(file, report): root = '' if (file != None): root = os.path.dirname(os.path.abspath(file)) try: input = open(file, 'r', 1) except IOError as (errno, strerror): print "'{0}' I/O error({1}): {2}".format(file,errno, strerror) return except: print "Unexpected error:", sys.exc_info()[0] return else: input = sys.stdin # read each line looking for: # 1) File '