Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

92 Zeilen
2.9 KiB

  1. """
  2. Checks that the functional test program (functest) can be successfully built
  3. and executed for every scheme/implementation.
  4. """
  5. import os
  6. import platform
  7. import unittest
  8. import pytest
  9. import helpers
  10. import pqclean
  11. @pytest.mark.parametrize(
  12. 'implementation,test_dir,impl_path, init, destr',
  13. [(impl, *helpers.isolate_test_files(impl.path(), 'test_functest_'))
  14. for impl in pqclean.Scheme.all_supported_implementations()],
  15. ids=[str(impl) for impl in pqclean.Scheme.all_supported_implementations()],
  16. )
  17. @helpers.filtered_test
  18. def test_functest(implementation, impl_path, test_dir,
  19. init, destr):
  20. init()
  21. dest_dir = os.path.join(test_dir, 'bin')
  22. helpers.make('functest',
  23. TYPE=implementation.scheme.type,
  24. SCHEME=implementation.scheme.name,
  25. IMPLEMENTATION=implementation.name,
  26. SCHEME_DIR=impl_path,
  27. DEST_DIR=dest_dir,
  28. working_dir=os.path.join(test_dir, 'test'))
  29. helpers.run_subprocess(
  30. [os.path.join(dest_dir, 'functest_{}_{}{}'.format(
  31. implementation.scheme.name,
  32. implementation.name,
  33. '.exe' if os.name == 'nt' else ''
  34. ))],
  35. )
  36. destr()
  37. @pytest.mark.parametrize(
  38. 'implementation,test_dir,impl_path, init, destr',
  39. [(impl,
  40. *helpers.isolate_test_files(impl.path(), 'test_functest_sanitizers_'))
  41. for impl in pqclean.Scheme.all_supported_implementations()],
  42. ids=[str(impl) for impl in pqclean.Scheme.all_supported_implementations()],
  43. )
  44. @helpers.skip_windows()
  45. @helpers.filtered_test
  46. @helpers.slow_test
  47. def test_functest_sanitizers(implementation, impl_path, test_dir,
  48. init, destr):
  49. dest_dir = os.path.join(test_dir, 'bin')
  50. env = None
  51. if platform.machine() == 'ppc' and os.environ.get('CC', 'gcc') == 'clang':
  52. raise unittest.SkipTest("Clang does not support ASAN on ppc")
  53. elif platform.machine() in ['armv7l', 'aarch64']:
  54. env = {'ASAN_OPTIONS': 'detect_leaks=0'}
  55. elif platform.system() == 'Darwin':
  56. raise unittest.SkipTest('ASAN is not reliable on OSX')
  57. else:
  58. print("Supported platform: {}".format(platform.machine()))
  59. init()
  60. helpers.make('clean-scheme', 'functest',
  61. TYPE=implementation.scheme.type,
  62. SCHEME=implementation.scheme.name,
  63. IMPLEMENTATION=implementation.name,
  64. EXTRAFLAGS='-g -fsanitize=address,undefined',
  65. SCHEME_DIR=impl_path,
  66. DEST_DIR=dest_dir,
  67. working_dir=os.path.join(test_dir, 'test'),
  68. env=env)
  69. helpers.run_subprocess(
  70. [os.path.join(dest_dir, 'functest_{}_{}{}'.format(
  71. implementation.scheme.name,
  72. implementation.name,
  73. '.exe' if os.name == 'nt' else ''
  74. ))],
  75. env=env,
  76. )
  77. destr()
  78. if __name__ == '__main__':
  79. import sys
  80. pytest.main(sys.argv)