Reference implementations of PQC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

52 lines
1.2 KiB

  1. import os
  2. import unittest
  3. from glob import glob
  4. import pytest
  5. import helpers
  6. import pqclean
  7. additional_flags = []
  8. @pytest.mark.parametrize(
  9. 'implementation',
  10. pqclean.Scheme.all_implementations(),
  11. ids=str,
  12. )
  13. @helpers.skip_windows()
  14. @helpers.filtered_test
  15. def test_clang_tidy(implementation: pqclean.Implementation):
  16. helpers.ensure_available('clang-tidy')
  17. cfiles = implementation.cfiles()
  18. common_files = glob(os.path.join('..', 'common', '*.c'))
  19. (returncode, _) = helpers.run_subprocess(
  20. ['clang-tidy',
  21. '-quiet',
  22. '-header-filter=.*',
  23. *additional_flags,
  24. *cfiles,
  25. *common_files,
  26. '--',
  27. '-iquote', os.path.join('..', 'common'),
  28. '-iquote', implementation.path()],
  29. expected_returncode=None,
  30. )
  31. # Detect and gracefully avoid segfaults
  32. if returncode == -11:
  33. raise unittest.SkipTest("clang-tidy segfaulted")
  34. assert returncode == 0, "Clang-tidy returned %d" % returncode
  35. if __name__ == "__main__":
  36. import sys
  37. # allow a user to specify --fix-errors, to immediately fix errors
  38. if len(sys.argv) >= 2 and sys.argv[1] == '-fix-errors':
  39. additional_flags = ['-fix-errors']
  40. del sys.argv[1]
  41. pytest.main(sys.argv)