From 3a09c5c75038efe0e0c55b73dd234731fbc2c061 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 6 Dec 2008 15:25:46 +0000 Subject: Update coverage tool for new system. --- doc/pkcs11-coverage.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'doc/pkcs11-coverage.py') diff --git a/doc/pkcs11-coverage.py b/doc/pkcs11-coverage.py index 13d7b6c..55d831c 100644 --- a/doc/pkcs11-coverage.py +++ b/doc/pkcs11-coverage.py @@ -13,7 +13,7 @@ We're anxious to complete this, if you have patches please do contribute. """ # Matches a comment like /** comment */ -PATTERN = re.compile("""P11T_([A-Z_]+)\("(.+?)"""") +PATTERN = re.compile(r'\bP11T_([A-Z_]+)\("(.+?)"') os.chdir("../src") @@ -23,26 +23,27 @@ files = [ name for name in os.listdir(".") if name[-2:] == ".c" ] coverage = { } for file in files: - data = open(file).read() + lines = open(file).readlines() section = "" - # Find all the matching comments in this file - matches = PATTERN.findall(data) - for match in matches: + for line in lines: - # Strip all the comment stuff out start and of the match - match = match.strip(" /*\t\n\r") + match = PATTERN.search(line) if not match: continue - if match[0] == '-' and section: - coverage[section].append(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) - section = match - if section not in coverage: - coverage[section] = [] sections = coverage.keys() sections.sort() @@ -51,6 +52,9 @@ print HEADER for section in sections: print section - for match in coverage[section]: - print match + checks = list(set(coverage[section])) + checks.sort() + for check in checks: + print " - %s" % check print + -- cgit v1.2.3