mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-27 01:41:40 +00:00
35 lines
921 B
Python
35 lines
921 B
Python
import os
|
|
import re
|
|
|
|
import helpers
|
|
import pqclean
|
|
|
|
|
|
def test_preprocessor():
|
|
for scheme in pqclean.Scheme.all_schemes():
|
|
for implementation in scheme.implementations:
|
|
if helpers.permit_test('preprocessor', implementation):
|
|
yield check_preprocessor, implementation
|
|
|
|
|
|
def check_preprocessor(implementation: pqclean.Implementation):
|
|
apipath = os.path.join(implementation.path(), 'api.h')
|
|
errors = []
|
|
p = re.compile(r'^\s*#include\s*"')
|
|
with open(apipath) as f:
|
|
for i, line in enumerate(f):
|
|
if p.match(line):
|
|
errors.append("\n at {}:{}".format(apipath, i+1))
|
|
if errors:
|
|
raise AssertionError(
|
|
"Prohibited external include in api.h" + "".join(errors)
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
import nose2
|
|
nose2.main()
|
|
except ImportError:
|
|
import nose
|
|
nose.runmodule()
|