mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-17 00:05:38 -04:00
* Increase stack size when using musl libc on Alpine This is probably not the best way to do it in long run, but I'm not sure how to detect libc version at compile time. * Fix free-check bug on Alpine * Extra symbols in shared library on Alpine * Activate Alpine builds * Only increase stack size if musl is present on Alpine This is not the most generic way to do it but hopefully will suffice * Temporarily enable Alpine builds * Simplify link option on Alpine
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
# SPDX-License-Identifier: MIT
|
|
|
|
import helpers
|
|
import pytest
|
|
import sys
|
|
|
|
# Check if liboqs contains any non-namespaced global symbols
|
|
# See https://github.com/open-quantum-safe/liboqs/wiki/Coding-conventions for function naming conventions
|
|
|
|
@helpers.filtered_test
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not needed on Windows")
|
|
def test_namespace(use_liboqs_so):
|
|
if use_liboqs_so:
|
|
if sys.platform == "darwin":
|
|
out = helpers.run_subprocess(
|
|
['nm', '-g', 'build/lib/liboqs.dylib']
|
|
)
|
|
else:
|
|
out = helpers.run_subprocess(
|
|
['nm', '-D', 'build/lib/liboqs.so']
|
|
)
|
|
else:
|
|
out = helpers.run_subprocess(
|
|
['nm', '-g', 'build/lib/liboqs.a']
|
|
)
|
|
|
|
lines = out.strip().split("\n")
|
|
symbols = []
|
|
for line in lines:
|
|
if ' T ' in line or ' D ' in line or ' S ' in line:
|
|
symbols.append(line)
|
|
|
|
# ideally this would be just ['oqs', 'pqclean']
|
|
namespaces = ['oqs', 'pqclean', 'keccak', 'pqcrystals', 'aligned_alloc', 'aligned_free', 'init', 'fini']
|
|
non_namespaced = []
|
|
|
|
for symbolstr in symbols:
|
|
*_, symtype, symbol = symbolstr.split()
|
|
if symtype in 'TR':
|
|
is_namespaced = False
|
|
for namespace in namespaces:
|
|
if symbol.lower().startswith(namespace) or symbol.lower().startswith('_' + namespace):
|
|
is_namespaced = True
|
|
if not(is_namespaced):
|
|
non_namespaced.append(symbol)
|
|
|
|
if len(non_namespaced) > 0:
|
|
for symbol in non_namespaced:
|
|
print("Non-namespaced symbol: {}".format(symbol))
|
|
|
|
assert(len(non_namespaced) == 0)
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
pytest.main(sys.argv)
|
|
|