1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00

Install test dependencies and build on OSX GCC

This commit is contained in:
Thom Wiggers 2019-01-22 15:21:49 +01:00
parent 4cac434f47
commit d66bef0284
No known key found for this signature in database
GPG Key ID: 001BB0A7CE26E363
4 changed files with 53 additions and 22 deletions

View File

@ -8,25 +8,54 @@ matrix:
compiler: gcc compiler: gcc
env: env:
- MAKETARGET="test-all tidy-all check-format" - MAKETARGET="test-all tidy-all check-format"
addons:
apt:
sources:
- deadsnakes
packages:
- valgrind
- python3.7
- os: linux - os: linux
compiler: clang compiler: clang
env: env:
- MAKETARGET=test-all - MAKETARGET=test-all
addons:
apt:
sources:
- deadsnakes
packages:
- valgrind
- python3.7
- os: osx - os: osx
osx_image: xcode10.1
compiler: clang compiler: clang
env: env:
- MAKETARGET=test-all - MAKETARGET=test-all
# This currently appears to be broken. addons:
# - os: osx homebrew:
# env: packages:
# - MATRIX_EVAL="brew install gcc && CC=gcc-8 && CXX=g++-8" - python@3.7
# - MAKETARGET=test-all - os: osx
osx_image: xcode10.1
compiler: gcc
addons:
homebrew:
packages:
- gcc@8
- python@3.7
env:
- MAKETARGET=test-all
before_install: before_install:
- eval "${MATRIX_EVAL}" - python3.7 --version
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- python3.7 get-pip.py --user
- python3.7 -mpip install -r requirements.txt
script: script:
- make ${MAKETARGET} - make ${MAKETARGET}
cache: pip
# vim: set ft=yaml ts=2 sw=2 tw=0 et : # vim: set ft=yaml ts=2 sw=2 tw=0 et :

View File

@ -149,22 +149,22 @@ run-valgrind-all:
.PHONY: run-testvectors .PHONY: run-testvectors
run-testvectors: test/check_testvectors.py | require_scheme run-testvectors: test/check_testvectors.py | require_scheme
python3 test/check_testvectors.py $(SCHEME) || exit 1; \ python3.7 test/check_testvectors.py $(SCHEME) || exit 1; \
.PHONY: run-symbol-namespace .PHONY: run-symbol-namespace
run-symbol-namespace: test/check_symbol_namespace.py | require_scheme run-symbol-namespace: test/check_symbol_namespace.py | require_scheme
python3 test/check_symbol_namespace.py $(SCHEME) || exit 1; \ python3.7 test/check_symbol_namespace.py $(SCHEME) || exit 1; \
.PHONY: run-testvectors-all .PHONY: run-testvectors-all
run-testvectors-all: test/check_testvectors.py run-testvectors-all: test/check_testvectors.py
@for scheme in $(ALL_SCHEMES); do \ @for scheme in $(ALL_SCHEMES); do \
python3 test/check_testvectors.py $$scheme || exit 1; \ python3.7 test/check_testvectors.py $$scheme || exit 1; \
done done
.PHONY: run-symbol-namespace-all .PHONY: run-symbol-namespace-all
run-symbol-namespace-all: run-symbol-namespace-all:
@for scheme in $(ALL_SCHEMES); do \ @for scheme in $(ALL_SCHEMES); do \
python3 test/check_symbol_namespace.py $$scheme || exit 1; \ python3.7 test/check_symbol_namespace.py $$scheme || exit 1; \
done done
.PHONY: run-functest-all .PHONY: run-functest-all

View File

@ -16,8 +16,8 @@ SCHEMESHORT = SCHEME.split('/')[1].upper()
namespace = f"PQCLEAN_{SCHEMESHORT}_".replace('-', '') namespace = f"PQCLEAN_{SCHEMESHORT}_".replace('-', '')
# TODO can we do this using object files instead, to preserve file origin? # TODO can we do this using object files instead, to preserve file origin?
sharedlib = f"bin/shared_{SCHEMEFULL}_clean.so" sharedlib = "bin/shared_{}_clean.so".format(SCHEMEFULL)
subprocess.run(["make", sharedlib, f"SCHEME={SCHEME}"]) subprocess.run(["make", sharedlib, "SCHEME={}".format(SCHEME)])
p = subprocess.run(["nm", "-D", sharedlib], capture_output=True) p = subprocess.run(["nm", "-D", sharedlib], capture_output=True)
symbols = p.stdout.decode('utf-8').strip().split("\n") symbols = p.stdout.decode('utf-8').strip().split("\n")
@ -31,7 +31,7 @@ for symbolstr in symbols:
if non_namespaced: if non_namespaced:
print("! Not all symbols were properly namespaced.", file=sys.stderr) print("! Not all symbols were properly namespaced.", file=sys.stderr)
print(f"! Missing namespace literal {namespace}", file=sys.stderr) print("! Missing namespace literal {}".format(namespace), file=sys.stderr)
for symbol in non_namespaced: for symbol in non_namespaced:
print(f"\t{symbol}", file=sys.stderr) print("\t{}".format(symbol), file=sys.stderr)
sys.exit(1) sys.exit(1)

View File

@ -17,24 +17,26 @@ SCHEME = sys.argv[1]
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768 SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
SCHEMESHORT = SCHEME.split('/')[1].upper() SCHEMESHORT = SCHEME.split('/')[1].upper()
def get_hash(scheme): def get_hash(scheme):
with open(f"{scheme}/META.yml", 'r') as stream: with open("{}/META.yml".format(scheme), 'r') as stream:
meta = yaml.load(stream) meta = yaml.load(stream)
return hex(meta['testvectors-sha3-256']).replace('0x', '') return hex(meta['testvectors-sha3-256']).replace('0x', '')
expectedTestvectorsHash = get_hash(SCHEME) expectedTestvectorsHash = get_hash(SCHEME)
subprocess.run(["make", "testvectors", f"SCHEME={SCHEME}"]) subprocess.run(["make", "testvectors", "SCHEME={}".format(SCHEME)])
implementations = [x for x in os.listdir('bin') if 'testvectors' in x and SCHEMEFULL in x] implementations = [
x for x in os.listdir('bin') if 'testvectors' in x and SCHEMEFULL in x]
for impl in implementations: for impl in implementations:
testvectors = subprocess.run([f"bin/{impl}"],stdout=subprocess.PIPE) testvectors = subprocess.run(["bin/{}".format(impl)],
stdout=subprocess.PIPE)
testvectorsHash = hashlib.sha3_256(testvectors.stdout).hexdigest() testvectorsHash = hashlib.sha3_256(testvectors.stdout).hexdigest()
if testvectorsHash.lower() != expectedTestvectorsHash.lower(): if testvectorsHash.lower() != expectedTestvectorsHash.lower():
print(f"testvectors of {SCHEME} should be {expectedTestvectorsHash}, but is {testvectorsHash}") print("testvectors of {} should be {}, but is {}"
.format(SCHEME, expectedTestvectorsHash, testvectorsHash))
sys.exit(1) sys.exit(1)
else: else:
print(f"testvectors of {SCHEME} matched expected hash") print("testvectors of {} matched expected hash".format(SCHEME))