mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 23:48:58 +00:00
Add format tests to python tests
This commit is contained in:
parent
ed8e845f77
commit
facc293a21
9
Makefile
9
Makefile
@ -72,14 +72,6 @@ bin/shared_$(subst /,_,$(SCHEME))_clean.so: $(wildcard $(SCHEME)/clean/*.c) | re
|
|||||||
clean:
|
clean:
|
||||||
rm -rf bin
|
rm -rf bin
|
||||||
|
|
||||||
.PHONY: format
|
|
||||||
format:
|
|
||||||
astyle --project crypto_*/*/*/*.[ch] common/*.[ch]
|
|
||||||
|
|
||||||
.PHONY: check-format
|
|
||||||
check-format:
|
|
||||||
astyle --dry-run --project crypto_*/*/*/*.[ch] common/*.[ch] | grep Formatted && exit 1 || exit 0
|
|
||||||
|
|
||||||
.PHONY: tidy
|
.PHONY: tidy
|
||||||
tidy:
|
tidy:
|
||||||
$(MAKE) do-tidy
|
$(MAKE) do-tidy
|
||||||
@ -107,7 +99,6 @@ help:
|
|||||||
@echo "make run-valgrind SCHEME=scheme Run valgrind checks for SCHEME"
|
@echo "make run-valgrind SCHEME=scheme Run valgrind checks for SCHEME"
|
||||||
@echo "make run-valgrind-all Run valgrind checks all schemes"
|
@echo "make run-valgrind-all Run valgrind checks all schemes"
|
||||||
@echo "make clean Clean up the bin/ folder"
|
@echo "make clean Clean up the bin/ folder"
|
||||||
@echo "make format Automatically formats all the source code"
|
|
||||||
@echo "make tidy SCHEME=scheme Runs the clang-tidy linter against SCHEME"
|
@echo "make tidy SCHEME=scheme Runs the clang-tidy linter against SCHEME"
|
||||||
@echo "make apply-tidy SCHEME=scheme Tries to automatically fix the issues found by clang-tidy in SCHEME"
|
@echo "make apply-tidy SCHEME=scheme Tries to automatically fix the issues found by clang-tidy in SCHEME"
|
||||||
@echo "make tidy-all Runs the clang-tidy linter against all schemes"
|
@echo "make tidy-all Runs the clang-tidy linter against all schemes"
|
||||||
|
@ -92,6 +92,12 @@ class Implementation:
|
|||||||
return '{}{}_'.format(self.scheme.namespace_prefix(),
|
return '{}{}_'.format(self.scheme.namespace_prefix(),
|
||||||
self.name.upper()).replace('-', '')
|
self.name.upper()).replace('-', '')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "{} implementation of {}".format(self.name, self.scheme.name)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<Implementation({}, {})>".format(self.name, self.scheme.name)
|
||||||
|
|
||||||
|
|
||||||
class KEM(Scheme):
|
class KEM(Scheme):
|
||||||
|
|
||||||
|
30
test/test_format.py
Normal file
30
test/test_format.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import os
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
import pqclean
|
||||||
|
from helpers import run_subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def test_formatting():
|
||||||
|
for scheme in pqclean.Scheme.all_schemes():
|
||||||
|
for implementation in scheme.implementations:
|
||||||
|
yield check_format, implementation
|
||||||
|
|
||||||
|
|
||||||
|
def check_format(implementation: pqclean.Implementation):
|
||||||
|
cfiles = glob(os.path.join(implementation.path(), '*.c'))
|
||||||
|
hfiles = glob(os.path.join(implementation.path(), '*.h'))
|
||||||
|
run_subprocess(['astyle',
|
||||||
|
'--dry-run',
|
||||||
|
'--options=../.astylerc',
|
||||||
|
*cfiles,
|
||||||
|
*hfiles])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
import nose2
|
||||||
|
nose2.main()
|
||||||
|
except ImportError:
|
||||||
|
import nose
|
||||||
|
nose.runmodule()
|
Loading…
Reference in New Issue
Block a user