Allow multiple sources for duplicate consistency checks; break into multiple unit test to improve output
This commit is contained in:
parent
e9427afeb2
commit
395f14a2f6
@ -1,7 +1,8 @@
|
|||||||
source:
|
consistency_checks:
|
||||||
|
- source:
|
||||||
scheme: frodokem640shake
|
scheme: frodokem640shake
|
||||||
implementation: clean
|
implementation: clean
|
||||||
files:
|
files:
|
||||||
- common.h
|
- common.h
|
||||||
- kem.c
|
- kem.c
|
||||||
- matrix_shake.c
|
- matrix_shake.c
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
source:
|
consistency_checks:
|
||||||
|
- source:
|
||||||
scheme: frodokem640shake
|
scheme: frodokem640shake
|
||||||
implementation: clean
|
implementation: clean
|
||||||
files:
|
files:
|
||||||
- common.h
|
- common.h
|
||||||
- params.h
|
- params.h
|
||||||
- kem.c
|
- kem.c
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
source:
|
consistency_checks:
|
||||||
|
- source:
|
||||||
scheme: frodokem640shake
|
scheme: frodokem640shake
|
||||||
implementation: clean
|
implementation: clean
|
||||||
files:
|
files:
|
||||||
- common.h
|
- common.h
|
||||||
- kem.c
|
- kem.c
|
||||||
- matrix_shake.c
|
- matrix_shake.c
|
||||||
|
@ -9,22 +9,23 @@ import unittest
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
def test_duplicate_consistency():
|
def test_duplicate_consistency():
|
||||||
|
helpers.skip_windows()
|
||||||
for scheme in pqclean.Scheme.all_schemes():
|
for scheme in pqclean.Scheme.all_schemes():
|
||||||
for implementation in scheme.implementations:
|
for implementation in scheme.implementations:
|
||||||
if os.path.isfile(os.path.join('duplicate_consistency', '{}_{}.yml'.format(scheme.name, implementation.name))):
|
if os.path.isfile(os.path.join('duplicate_consistency', '{}_{}.yml'.format(scheme.name, implementation.name))):
|
||||||
yield check_duplicate_consistency, implementation
|
metafile = os.path.join('duplicate_consistency', '{}_{}.yml'.format(implementation.scheme.name, implementation.name))
|
||||||
|
with open(metafile, encoding='utf-8') as f:
|
||||||
|
metadata = yaml.load(f.read())
|
||||||
|
for group in metadata['consistency_checks']:
|
||||||
|
source = pqclean.Implementation.by_name(group['source']['scheme'], group['source']['implementation'])
|
||||||
|
for file in group['files']:
|
||||||
|
yield check_duplicate_consistency, implementation, source, file
|
||||||
|
|
||||||
def file_get_contents(filename):
|
def file_get_contents(filename):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
def check_duplicate_consistency(implementation):
|
def check_duplicate_consistency(implementation, source, file):
|
||||||
helpers.skip_windows()
|
|
||||||
metafile = os.path.join('duplicate_consistency', '{}_{}.yml'.format(implementation.scheme.name, implementation.name))
|
|
||||||
with open(metafile, encoding='utf-8') as f:
|
|
||||||
metadata = yaml.load(f.read())
|
|
||||||
source = pqclean.Implementation.by_name(metadata['source']['scheme'], metadata['source']['implementation'])
|
|
||||||
for file in metadata['files']:
|
|
||||||
transformed_src = helpers.run_subprocess(
|
transformed_src = helpers.run_subprocess(
|
||||||
['sed', '-e', 's/{}/{}/g'.format(source.namespace_prefix(), implementation.namespace_prefix()), os.path.join(source.path(), file)]
|
['sed', '-e', 's/{}/{}/g'.format(source.namespace_prefix(), implementation.namespace_prefix()), os.path.join(source.path(), file)]
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user