mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 15:39:07 +00:00
Test for prohibited includes in api.h
This commit is contained in:
parent
27366d6559
commit
9e5fd74823
1
.github/pull_request_template.md
vendored
1
.github/pull_request_template.md
vendored
@ -7,7 +7,6 @@
|
|||||||
<!-- These checkboxes serve for the maintainers of PQClean to verify your submission. Please do not check them yourself. -->
|
<!-- These checkboxes serve for the maintainers of PQClean to verify your submission. Please do not check them yourself. -->
|
||||||
|
|
||||||
* [ ] `#if`/`#ifdef`s only for header encapsulation
|
* [ ] `#if`/`#ifdef`s only for header encapsulation
|
||||||
* [ ] `api.h` does not include other files
|
|
||||||
* [ ] No stringification macros
|
* [ ] No stringification macros
|
||||||
* [ ] Output-parameter pointers in functions are on the left
|
* [ ] Output-parameter pointers in functions are on the left
|
||||||
* [ ] Negative return values on failure of API functions (within restrictions of FO transform).
|
* [ ] Negative return values on failure of API functions (within restrictions of FO transform).
|
||||||
|
@ -34,6 +34,7 @@ _The checking of items on this list is still being developed. Checked items shou
|
|||||||
* [x] Code is valid C99
|
* [x] Code is valid C99
|
||||||
* [x] Passes functional tests
|
* [x] Passes functional tests
|
||||||
* [x] API functions do not write outside provided buffers
|
* [x] API functions do not write outside provided buffers
|
||||||
|
* [x] `api.h` cannot include external files
|
||||||
* [x] Compiles with `-Wall -Wextra -Wpedantic -Werror` with `gcc` and `clang`
|
* [x] Compiles with `-Wall -Wextra -Wpedantic -Werror` with `gcc` and `clang`
|
||||||
* [x] Consistent test vectors across runs
|
* [x] Consistent test vectors across runs
|
||||||
* [x] Consistent test vectors on big-endian and little-endian machines
|
* [x] Consistent test vectors on big-endian and little-endian machines
|
||||||
|
32
test/test_api_h.py
Normal file
32
test/test_api_h.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
import pqclean
|
||||||
|
|
||||||
|
|
||||||
|
def test_preprocessor():
|
||||||
|
for scheme in pqclean.Scheme.all_schemes():
|
||||||
|
for implementation in scheme.implementations:
|
||||||
|
yield check_preprocessor, implementation
|
||||||
|
|
||||||
|
|
||||||
|
def check_preprocessor(implementation: pqclean.Implementation):
|
||||||
|
apipath = os.path.join(implementation.path(), 'api.h')
|
||||||
|
errors = []
|
||||||
|
p = re.compile(r'^\s*#include\s*"')
|
||||||
|
with open(apipath) as f:
|
||||||
|
for i, line in enumerate(f):
|
||||||
|
if p.match(line):
|
||||||
|
errors.append("\n at {}:{}".format(apipath, i+1))
|
||||||
|
if errors:
|
||||||
|
raise AssertionError(
|
||||||
|
"Prohibited external include in api.h" + "".join(errors)
|
||||||
|
)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
import nose2
|
||||||
|
nose2.main()
|
||||||
|
except ImportError:
|
||||||
|
import nose
|
||||||
|
nose.runmodule()
|
Loading…
Reference in New Issue
Block a user