2019-07-29 09:38:25 +01:00
|
|
|
import pytest
|
2019-04-09 15:45:41 +01:00
|
|
|
|
2019-07-29 09:38:25 +01:00
|
|
|
import helpers
|
|
|
|
import pqclean
|
2019-04-09 15:45:41 +01:00
|
|
|
|
|
|
|
|
2019-07-29 09:38:25 +01:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'implementation',
|
|
|
|
pqclean.Scheme.all_implementations(),
|
|
|
|
ids=str,
|
|
|
|
)
|
2019-04-18 09:00:08 +01:00
|
|
|
@helpers.filtered_test
|
2019-07-29 09:38:25 +01:00
|
|
|
def test_preprocessor(implementation: pqclean.Implementation):
|
2019-04-09 15:45:41 +01:00
|
|
|
cfiles = implementation.cfiles()
|
|
|
|
hfiles = implementation.hfiles()
|
|
|
|
errors = []
|
|
|
|
for file in hfiles + cfiles:
|
|
|
|
with open(file) as f:
|
|
|
|
for i, line in enumerate(f):
|
|
|
|
line = line.strip()
|
|
|
|
if file in hfiles and i == 0 and line.startswith('#ifndef'):
|
|
|
|
continue
|
|
|
|
if line.startswith('#if'):
|
|
|
|
errors.append("\n at {}:{}".format(file, i+1))
|
|
|
|
if errors:
|
|
|
|
raise AssertionError(
|
|
|
|
"Prohibited use of preprocessor conditional" + "".join(errors)
|
|
|
|
)
|
|
|
|
|
2019-04-17 10:17:46 +01:00
|
|
|
|
2019-07-29 09:38:25 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys
|
|
|
|
pytest.main(sys.argv)
|