Add sanitizers to functests
Esse commit está contido em:
pai
66f0ba9d95
commit
73197c6516
@ -22,6 +22,16 @@ all: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION) $(DEST_DIR)/testvectors_$(
|
||||
build-scheme:
|
||||
cd $(SCHEME_DIR) && $(MAKE)
|
||||
|
||||
.PHONY: clean-scheme
|
||||
clean-scheme:
|
||||
cd $(SCHEME_DIR) && $(MAKE) clean
|
||||
|
||||
.PHONY: functest
|
||||
functest: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
|
||||
|
||||
.PHONY: testvectors
|
||||
testvectors: $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
|
||||
|
||||
$(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/functest.c $(COMMON_FILES) $(COMMON_DIR)/randombytes.c $(COMMON_HEADERS)
|
||||
mkdir -p $(DEST_DIR)
|
||||
$(CC) $(CFLAGS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/functest.c $(COMMON_FILES) $(COMMON_DIR)/notrandombytes.c -o $@ -L$(SCHEME_DIR) -l$(SCHEME)_$(IMPLEMENTATION)
|
||||
|
@ -2,6 +2,7 @@
|
||||
# nmake /f Makefile.Microsoft_nmake
|
||||
|
||||
# override as desired
|
||||
# vim: set ts=4 sw=4 et:
|
||||
TYPE=kem
|
||||
SCHEME=kyber768
|
||||
SCHEME_UPPERCASE=KYBER768
|
||||
@ -25,6 +26,11 @@ build-scheme:
|
||||
nmake /f Makefile.Microsoft_nmake
|
||||
cd ..\..\..\test
|
||||
|
||||
clean-scheme:
|
||||
cd $(SCHEME_DIR)
|
||||
nmake /f Makefile.Microsoft_nmake clean
|
||||
cd ..\..\..\test
|
||||
|
||||
$(DEST_DIR)\functest_$(SCHEME)_$(IMPLEMENTATION).EXE: build-scheme $(COMMON_OBJECTS) $(COMMON_DIR)\randombytes.obj
|
||||
-MKDIR $(DEST_DIR)
|
||||
$(CC) /c crypto_$(TYPE)\functest.c $(CFLAGS) /I $(SCHEME_DIR) /DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE)
|
||||
|
@ -19,3 +19,21 @@ def run_subprocess(command, working_dir='.', expected_returncode=0):
|
||||
print(result.stdout.decode('utf-8'))
|
||||
assert(result.returncode == expected_returncode)
|
||||
return result.stdout.decode('utf-8')
|
||||
|
||||
|
||||
def make(*args, working_dir='.', **kwargs):
|
||||
"""
|
||||
Runs a make target in the specified working directory
|
||||
|
||||
Usage:
|
||||
make('clean', 'targetb', SCHEME='bla')
|
||||
"""
|
||||
make_command = 'make'
|
||||
return run_subprocess(
|
||||
[
|
||||
make_command,
|
||||
*args,
|
||||
*['{}={}'.format(k, v) for k, v in kwargs.items()],
|
||||
],
|
||||
working_dir=working_dir,
|
||||
)
|
||||
|
@ -4,6 +4,9 @@ and executed for every scheme/implementation.
|
||||
"""
|
||||
|
||||
import os
|
||||
import platform
|
||||
import unittest
|
||||
|
||||
import pqclean
|
||||
import helpers
|
||||
|
||||
@ -14,6 +17,12 @@ def test_functest():
|
||||
yield check_functest, scheme.name, implementation.name
|
||||
|
||||
|
||||
def test_functest_sanitizers():
|
||||
for scheme in pqclean.Scheme.all_schemes():
|
||||
for implementation in scheme.implementations:
|
||||
yield check_functest_sanitizers, scheme.name, implementation.name
|
||||
|
||||
|
||||
def check_functest(scheme_name, implementation_name):
|
||||
implementation = pqclean.Implementation.by_name(
|
||||
scheme_name, implementation_name)
|
||||
@ -30,6 +39,24 @@ def check_functest(scheme_name, implementation_name):
|
||||
)
|
||||
|
||||
|
||||
def check_functest_sanitizers(scheme_name, implementation_name):
|
||||
if platform.machine() not in ['i386', 'x86_64']:
|
||||
raise unittest.SkipTest()
|
||||
implementation = pqclean.Implementation.by_name(
|
||||
scheme_name, implementation_name)
|
||||
helpers.make('clean-scheme', 'functest',
|
||||
TYPE=implementation.scheme.type,
|
||||
SCHEME=scheme_name,
|
||||
IMPLEMENTATION=implementation_name,
|
||||
working_dir=os.path.join('..', 'test'),
|
||||
EXTRAFLAGS='-fsanitize=address,undefined')
|
||||
helpers.run_subprocess(
|
||||
['./functest_{}_{}'.format(scheme_name, implementation_name)],
|
||||
os.path.join('..', 'bin'),
|
||||
)
|
||||
return check_functest(scheme_name, implementation_name)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
import nose2
|
||||
|
Carregando…
Referência em uma nova issue
Block a user