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.
 
 
 

92 line
2.8 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 pqclean
  9. import helpers
  10. def test_functest():
  11. for scheme in pqclean.Scheme.all_schemes():
  12. for implementation in scheme.implementations:
  13. yield check_functest, implementation
  14. def test_functest_sanitizers():
  15. for scheme in pqclean.Scheme.all_schemes():
  16. for implementation in scheme.implementations:
  17. yield check_functest_sanitizers, implementation
  18. @helpers.filtered_test
  19. def check_functest(implementation):
  20. helpers.make('functest',
  21. TYPE=implementation.scheme.type,
  22. SCHEME=implementation.scheme.name,
  23. IMPLEMENTATION=implementation.name,
  24. working_dir=os.path.join('..', 'test'))
  25. helpers.run_subprocess(
  26. [os.path.join('..', 'bin', 'functest_{}_{}{}'.format(
  27. implementation.scheme.name,
  28. implementation.name,
  29. '.exe' if os.name == 'nt' else ''
  30. ))],
  31. os.path.join('..', 'bin'),
  32. )
  33. @helpers.filtered_test
  34. @helpers.skip_windows()
  35. @helpers.slow_test
  36. def check_functest_sanitizers(implementation):
  37. env = None
  38. if platform.machine() == 'ppc' and os.environ.get('CC', 'gcc') == 'clang':
  39. raise unittest.SkipTest("Clang does not support ASAN on ppc")
  40. elif platform.machine() in ['armv7l', 'aarch64']:
  41. env = {'ASAN_OPTIONS': 'detect_leaks=0'}
  42. elif platform.system() == 'Darwin':
  43. raise unittest.SkipTest('valgrind is not reliable on OSX')
  44. else:
  45. print("Supported platform: {}".format(platform.machine()))
  46. helpers.make('clean-scheme', 'functest',
  47. TYPE=implementation.scheme.type,
  48. SCHEME=implementation.scheme.name,
  49. IMPLEMENTATION=implementation.name,
  50. EXTRAFLAGS='-g -fsanitize=address,undefined',
  51. working_dir=os.path.join('..', 'test'),
  52. env=env)
  53. try:
  54. helpers.run_subprocess(
  55. [os.path.join('..', 'bin', 'functest_{}_{}{}'.format(
  56. implementation.scheme.name,
  57. implementation.name,
  58. '.exe' if os.name == 'nt' else ''
  59. ))],
  60. os.path.join('..', 'bin'),
  61. env=env,
  62. )
  63. except AssertionError as e:
  64. raise e
  65. finally:
  66. # Remove files with ASAN library compiled in
  67. helpers.make('clean-scheme',
  68. TYPE=implementation.scheme.type,
  69. SCHEME=implementation.scheme.name,
  70. IMPLEMENTATION=implementation.name,
  71. working_dir=os.path.join('..', 'test'))
  72. if __name__ == '__main__':
  73. try:
  74. import nose2
  75. nose2.main()
  76. except ImportError:
  77. import nose
  78. nose.runmodule()