summaryrefslogtreecommitdiff
path: root/doc/pkcs11-coverage.py
blob: 55d831ca0b5f8e5c9fb840a48bf431650695b567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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