#!/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'\bP11T_([A-Z_]+)\("(.+?)"') os.chdir("../src") # All the *.c files files = [ name for name in os.listdir(".") if name[-2:] == ".c" ] coverage = { } for file in files: lines = open(file).readlines() section = "" for line in lines: match = PATTERN.search(line) if not match: continue name = match.group(1) value = match.group(2) if name.find("SECTION") != -1: section = value if section not in coverage: coverage[section] = [] elif name.find("CHECK") != -1: if section in coverage: coverage[section].append(value) sections = coverage.keys() sections.sort() print HEADER for section in sections: print section checks = list(set(coverage[section])) checks.sort() for check in checks: print " - %s" % check print