Add environment to sanitizers on ARM

This commit is contained in:
Thom Wiggers 2019-02-27 12:58:00 +01:00
förälder 59792522ae
incheckning 1180de5d30
Ingen känd nyckel hittad för denna signaturen i databasen
GPG-nyckel ID: 001BB0A7CE26E363
2 ändrade filer med 26 tillägg och 6 borttagningar

Visa fil

@ -1,11 +1,17 @@
import os
import subprocess
def run_subprocess(command, working_dir='.', expected_returncode=0):
def run_subprocess(command, working_dir='.', env=None, expected_returncode=0):
"""
Helper function to run a shell command and report success/failure
depending on the exit status of the shell command.
"""
if env is not None:
env_ = os.environ.copy()
env_.update(env)
env = env_
# Note we need to capture stdout/stderr from the subprocess,
# then print it, which nose/unittest will then capture and
# buffer appropriately
@ -13,7 +19,8 @@ def run_subprocess(command, working_dir='.', expected_returncode=0):
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=working_dir
cwd=working_dir,
env=env,
)
print(working_dir + " > " + " ".join(command))
print(result.stdout.decode('utf-8'))
@ -21,7 +28,7 @@ def run_subprocess(command, working_dir='.', expected_returncode=0):
return result.stdout.decode('utf-8')
def make(*args, working_dir='.', **kwargs):
def make(*args, working_dir='.', env=None, **kwargs):
"""
Runs a make target in the specified working directory
@ -36,4 +43,5 @@ def make(*args, working_dir='.', **kwargs):
*['{}={}'.format(k, v) for k, v in kwargs.items()],
],
working_dir=working_dir,
env=env,
)

Visa fil

@ -40,21 +40,33 @@ def check_functest(scheme_name, implementation_name):
def check_functest_sanitizers(scheme_name, implementation_name):
if platform.machine() not in ['i386', 'x86_64']:
env = None
if platform.machine() == 'powerpc':
raise unittest.SkipTest()
elif platform.machine() in ['arm32', 'aarch64']:
env = {'ASAN_OPTIONS': 'detect_leaks=0'}
else:
print("Supported platform: {}".format(platform.machine))
implementation = pqclean.Implementation.by_name(
scheme_name, implementation_name)
helpers.make('clean-scheme', 'functest',
TYPE=implementation.scheme.type,
SCHEME=scheme_name,
IMPLEMENTATION=implementation_name,
EXTRAFLAGS='-fsanitize=address,undefined',
working_dir=os.path.join('..', 'test'),
EXTRAFLAGS='-fsanitize=address,undefined')
env=env)
helpers.run_subprocess(
['./functest_{}_{}'.format(scheme_name, implementation_name)],
os.path.join('..', 'bin'),
env=env,
)
return check_functest(scheme_name, implementation_name)
# Remove files with ASAN library compiled in
helpers.make('clean-scheme',
TYPE=implementation.scheme.type,
SCHEME=scheme_name,
IMPLEMENTATION=implementation_name,
working_dir=os.path.join('..', 'test'))
if __name__ == '__main__':