1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-23 07:59:01 +00:00
pqcrypto/test/test_api_h.py

34 lines
732 B
Python
Raw Normal View History

2019-04-09 16:14:34 +01:00
import os
import re
import pytest
import helpers
2019-04-09 16:14:34 +01:00
import pqclean
pattern = re.compile(r'^\s*#include\s*"')
2019-04-09 16:14:34 +01:00
@pytest.mark.parametrize(
'implementation',
pqclean.Scheme.all_implementations(),
ids=str,
)
@helpers.filtered_test
def test_api_h(implementation: pqclean.Implementation):
2019-04-09 16:14:34 +01:00
apipath = os.path.join(implementation.path(), 'api.h')
errors = []
with open(apipath) as f:
for i, line in enumerate(f):
if pattern.match(line):
2019-04-09 16:14:34 +01:00
errors.append("\n at {}:{}".format(apipath, i+1))
if errors:
raise AssertionError(
"Prohibited external include in api.h" + "".join(errors)
)
if __name__ == '__main__':
import sys
pytest.main(sys.argv)