Add environment to sanitizers on ARM
This commit is contained in:
parent
59792522ae
commit
1180de5d30
@ -1,11 +1,17 @@
|
|||||||
|
import os
|
||||||
import subprocess
|
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
|
Helper function to run a shell command and report success/failure
|
||||||
depending on the exit status of the shell command.
|
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,
|
# Note we need to capture stdout/stderr from the subprocess,
|
||||||
# then print it, which nose/unittest will then capture and
|
# then print it, which nose/unittest will then capture and
|
||||||
# buffer appropriately
|
# buffer appropriately
|
||||||
@ -13,7 +19,8 @@ def run_subprocess(command, working_dir='.', expected_returncode=0):
|
|||||||
command,
|
command,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
cwd=working_dir
|
cwd=working_dir,
|
||||||
|
env=env,
|
||||||
)
|
)
|
||||||
print(working_dir + " > " + " ".join(command))
|
print(working_dir + " > " + " ".join(command))
|
||||||
print(result.stdout.decode('utf-8'))
|
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')
|
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
|
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()],
|
*['{}={}'.format(k, v) for k, v in kwargs.items()],
|
||||||
],
|
],
|
||||||
working_dir=working_dir,
|
working_dir=working_dir,
|
||||||
|
env=env,
|
||||||
)
|
)
|
||||||
|
@ -40,21 +40,33 @@ def check_functest(scheme_name, implementation_name):
|
|||||||
|
|
||||||
|
|
||||||
def check_functest_sanitizers(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()
|
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(
|
implementation = pqclean.Implementation.by_name(
|
||||||
scheme_name, implementation_name)
|
scheme_name, implementation_name)
|
||||||
helpers.make('clean-scheme', 'functest',
|
helpers.make('clean-scheme', 'functest',
|
||||||
TYPE=implementation.scheme.type,
|
TYPE=implementation.scheme.type,
|
||||||
SCHEME=scheme_name,
|
SCHEME=scheme_name,
|
||||||
IMPLEMENTATION=implementation_name,
|
IMPLEMENTATION=implementation_name,
|
||||||
|
EXTRAFLAGS='-fsanitize=address,undefined',
|
||||||
working_dir=os.path.join('..', 'test'),
|
working_dir=os.path.join('..', 'test'),
|
||||||
EXTRAFLAGS='-fsanitize=address,undefined')
|
env=env)
|
||||||
helpers.run_subprocess(
|
helpers.run_subprocess(
|
||||||
['./functest_{}_{}'.format(scheme_name, implementation_name)],
|
['./functest_{}_{}'.format(scheme_name, implementation_name)],
|
||||||
os.path.join('..', 'bin'),
|
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__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user