2019-04-09 16:14:34 +01:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2019-04-10 22:03:02 +01:00
|
|
|
import helpers
|
2019-04-09 16:14:34 +01:00
|
|
|
import pqclean
|
|
|
|
|
|
|
|
|
2019-04-18 09:00:08 +01:00
|
|
|
def test_api_h():
|
2019-04-09 16:14:34 +01:00
|
|
|
for scheme in pqclean.Scheme.all_schemes():
|
|
|
|
for implementation in scheme.implementations:
|
2019-04-18 09:00:08 +01:00
|
|
|
yield check_api_h, implementation
|
2019-04-09 16:14:34 +01:00
|
|
|
|
|
|
|
|
2019-04-18 09:00:08 +01:00
|
|
|
@helpers.filtered_test
|
|
|
|
def check_api_h(implementation: pqclean.Implementation):
|
2019-04-09 16:14:34 +01:00
|
|
|
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)
|
|
|
|
)
|
|
|
|
|
2019-04-18 09:00:08 +01:00
|
|
|
|
2019-04-09 16:14:34 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
import nose2
|
|
|
|
nose2.main()
|
|
|
|
except ImportError:
|
|
|
|
import nose
|
|
|
|
nose.runmodule()
|