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.
 
 
 
 

47 lines
1.3 KiB

  1. """
  2. Runs the test files under valgrind to detect memory problems
  3. """
  4. import os
  5. import platform
  6. import unittest
  7. import pytest
  8. import helpers
  9. import pqclean
  10. @pytest.mark.parametrize(
  11. 'implementation,test_dir,impl_path, init, destr',
  12. [(impl, *helpers.isolate_test_files(impl.path(), 'test_functest_'))
  13. for impl in pqclean.Scheme.all_implementations()],
  14. ids=[str(impl) for impl in pqclean.Scheme.all_implementations()],
  15. )
  16. @helpers.slow_test
  17. @helpers.filtered_test
  18. def test_valgrind(implementation: pqclean.Implementation, impl_path, test_dir,
  19. init, destr):
  20. if (platform.machine() not in ('i386', 'x86_64') or
  21. platform.system() != 'Linux'):
  22. raise unittest.SkipTest()
  23. init()
  24. dest_dir = os.path.join(test_dir, 'bin')
  25. helpers.make(TYPE=implementation.scheme.type,
  26. SCHEME=implementation.scheme.name,
  27. SCHEME_DIR=os.path.abspath(impl_path),
  28. IMPLEMENTATION=implementation.name,
  29. DEST_DIR=dest_dir,
  30. working_dir=os.path.join(test_dir, 'test'))
  31. functest_name = './functest_{}_{}'.format(implementation.scheme.name,
  32. implementation.name)
  33. helpers.run_subprocess(['valgrind', functest_name], dest_dir)
  34. destr()
  35. if __name__ == '__main__':
  36. import sys
  37. pytest.main(sys.argv)