2019-02-28 13:05:55 +00:00
|
|
|
"""
|
|
|
|
Runs the test files under valgrind to detect memory problems
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import unittest
|
|
|
|
|
2019-07-29 09:38:25 +01:00
|
|
|
import pytest
|
2019-02-28 13:05:55 +00:00
|
|
|
|
2019-07-29 09:38:25 +01:00
|
|
|
import helpers
|
|
|
|
import pqclean
|
2019-02-28 13:05:55 +00:00
|
|
|
|
|
|
|
|
2019-07-29 09:38:25 +01:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'implementation,test_dir,impl_path, init, destr',
|
|
|
|
[(impl, *helpers.isolate_test_files(impl.path(), 'test_functest_'))
|
|
|
|
for impl in pqclean.Scheme.all_implementations()],
|
|
|
|
ids=[str(impl) for impl in pqclean.Scheme.all_implementations()],
|
|
|
|
)
|
2019-04-17 10:17:46 +01:00
|
|
|
@helpers.slow_test
|
2019-04-18 09:00:08 +01:00
|
|
|
@helpers.filtered_test
|
2019-07-29 09:38:25 +01:00
|
|
|
def test_valgrind(implementation: pqclean.Implementation, impl_path, test_dir,
|
|
|
|
init, destr):
|
2019-02-28 13:05:55 +00:00
|
|
|
if (platform.machine() not in ('i386', 'x86_64') or
|
|
|
|
platform.system() != 'Linux'):
|
|
|
|
raise unittest.SkipTest()
|
2019-07-29 09:38:25 +01:00
|
|
|
init()
|
|
|
|
|
|
|
|
dest_dir = os.path.join(test_dir, 'bin')
|
2019-02-28 13:05:55 +00:00
|
|
|
|
|
|
|
helpers.make(TYPE=implementation.scheme.type,
|
|
|
|
SCHEME=implementation.scheme.name,
|
2019-07-29 09:38:25 +01:00
|
|
|
SCHEME_DIR=os.path.abspath(impl_path),
|
2019-02-28 13:05:55 +00:00
|
|
|
IMPLEMENTATION=implementation.name,
|
2019-07-29 09:38:25 +01:00
|
|
|
DEST_DIR=dest_dir,
|
2019-07-29 14:25:41 +01:00
|
|
|
NTESTS=1,
|
2019-07-29 09:38:25 +01:00
|
|
|
working_dir=os.path.join(test_dir, 'test'))
|
2019-02-28 13:05:55 +00:00
|
|
|
functest_name = './functest_{}_{}'.format(implementation.scheme.name,
|
|
|
|
implementation.name)
|
2019-07-29 09:38:25 +01:00
|
|
|
helpers.run_subprocess(['valgrind', functest_name], dest_dir)
|
|
|
|
destr()
|
2019-02-28 13:05:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-07-29 09:38:25 +01:00
|
|
|
import sys
|
|
|
|
pytest.main(sys.argv)
|