pqc/test/test_linter.py

51 lines
1.2 KiB
Python
Raw Normal View History

import os
2019-07-30 09:21:11 +01:00
import platform
import unittest
from glob import glob
import pytest
import helpers
import pqclean
additional_flags = [] #['-fix-errors']
2019-04-06 12:57:35 +01:00
@pytest.mark.parametrize(
'implementation',
pqclean.Scheme.all_supported_implementations(),
ids=str,
)
2019-04-17 01:59:37 +01:00
@helpers.skip_windows()
@helpers.filtered_test
def test_clang_tidy(implementation: pqclean.Implementation):
2020-03-31 13:03:02 +01:00
if platform.machine() in ['armv7l']:
# armv7l: slow, not more useful than i386
raise unittest.SkipTest()
helpers.ensure_available('clang-tidy')
cfiles = implementation.cfiles()
common_files = glob(os.path.join('..', 'common', '*.c'))
(returncode, _) = helpers.run_subprocess(
['clang-tidy',
'-quiet',
'-header-filter=.*',
*additional_flags,
*cfiles,
*common_files,
'--',
'-iquote', os.path.join('..', 'common'),
'-iquote', implementation.path()],
expected_returncode=None,
)
# Detect and gracefully avoid segfaults
if returncode == -11:
raise unittest.SkipTest("clang-tidy segfaulted")
assert returncode == 0, "Clang-tidy returned %d" % returncode
if __name__ == "__main__":
import sys
pytest.main(sys.argv)