#!/usr/bin/env python import os, sys import re HEADER = """ PKCS#11 COVERAGE This is the test coverage of the p11-tests tool of the PKCS#11 interface. We're anxious to complete this, if you have patches please do contribute. """ # Matches a comment like /** comment */ PATTERN = re.compile(r"/\*\*.*?\*/") os.chdir("../src") # All the *.c files files = [ name for name in os.listdir(".") if name[-2:] == ".c" ] coverage = { } for file in files: data = open(file).read() section = "" # Find all the matching comments in this file matches = PATTERN.findall(data) for match in matches: # Strip all the comment stuff out start and of the match match = match.strip(" /*\t\n\r") if not match: continue if match[0] == '-' and section: coverage[section].append(match) continue section = match if section not in coverage: coverage[section] = [] sections = coverage.keys() sections.sort() print HEADER for section in sections: print section for match in coverage[section]: print match print