Browse Source

Install test dependencies and build on OSX GCC

master
Thom Wiggers 5 years ago
parent
commit
d66bef0284
No known key found for this signature in database GPG Key ID: 1BB0A7CE26E363
4 changed files with 53 additions and 22 deletions
  1. +35
    -6
      .travis.yml
  2. +4
    -4
      Makefile
  3. +4
    -4
      test/check_symbol_namespace.py
  4. +10
    -8
      test/check_testvectors.py

+ 35
- 6
.travis.yml View File

@@ -8,25 +8,54 @@ matrix:
compiler: gcc
env:
- MAKETARGET="test-all tidy-all check-format"
addons:
apt:
sources:
- deadsnakes
packages:
- valgrind
- python3.7
- os: linux
compiler: clang
env:
- MAKETARGET=test-all
addons:
apt:
sources:
- deadsnakes
packages:
- valgrind
- python3.7
- os: osx
osx_image: xcode10.1
compiler: clang
env:
- MAKETARGET=test-all
# This currently appears to be broken.
# - os: osx
# env:
# - MATRIX_EVAL="brew install gcc && CC=gcc-8 && CXX=g++-8"
# - MAKETARGET=test-all
addons:
homebrew:
packages:
- python@3.7
- os: osx
osx_image: xcode10.1
compiler: gcc
addons:
homebrew:
packages:
- gcc@8
- python@3.7
env:
- MAKETARGET=test-all

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:
- make ${MAKETARGET}


cache: pip

# vim: set ft=yaml ts=2 sw=2 tw=0 et :

+ 4
- 4
Makefile View File

@@ -149,22 +149,22 @@ run-valgrind-all:

.PHONY: run-testvectors
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
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
run-testvectors-all: test/check_testvectors.py
@for scheme in $(ALL_SCHEMES); do \
python3 test/check_testvectors.py $$scheme || exit 1; \
python3.7 test/check_testvectors.py $$scheme || exit 1; \
done

.PHONY: run-symbol-namespace-all
run-symbol-namespace-all:
@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

.PHONY: run-functest-all


+ 4
- 4
test/check_symbol_namespace.py View File

@@ -16,8 +16,8 @@ SCHEMESHORT = SCHEME.split('/')[1].upper()
namespace = f"PQCLEAN_{SCHEMESHORT}_".replace('-', '')

# TODO can we do this using object files instead, to preserve file origin?
sharedlib = f"bin/shared_{SCHEMEFULL}_clean.so"
subprocess.run(["make", sharedlib, f"SCHEME={SCHEME}"])
sharedlib = "bin/shared_{}_clean.so".format(SCHEMEFULL)
subprocess.run(["make", sharedlib, "SCHEME={}".format(SCHEME)])
p = subprocess.run(["nm", "-D", sharedlib], capture_output=True)

symbols = p.stdout.decode('utf-8').strip().split("\n")
@@ -31,7 +31,7 @@ for symbolstr in symbols:

if non_namespaced:
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:
print(f"\t{symbol}", file=sys.stderr)
print("\t{}".format(symbol), file=sys.stderr)
sys.exit(1)

+ 10
- 8
test/check_testvectors.py View File

@@ -17,24 +17,26 @@ SCHEME = sys.argv[1]
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
SCHEMESHORT = SCHEME.split('/')[1].upper()


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)
return hex(meta['testvectors-sha3-256']).replace('0x', '')


expectedTestvectorsHash = get_hash(SCHEME)

subprocess.run(["make", "testvectors", f"SCHEME={SCHEME}"])
implementations = [x for x in os.listdir('bin') if 'testvectors' in x and SCHEMEFULL in x]
subprocess.run(["make", "testvectors", "SCHEME={}".format(SCHEME)])
implementations = [
x for x in os.listdir('bin') if 'testvectors' in x and SCHEMEFULL in x]

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()
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)
else:
print(f"testvectors of {SCHEME} matched expected hash")


print("testvectors of {} matched expected hash".format(SCHEME))

Loading…
Cancel
Save