From 2fbd02a0766278b8d2438f942f25dca16addf1e6 Mon Sep 17 00:00:00 2001 From: Joost Rijneveld Date: Mon, 18 Feb 2019 16:46:32 +0100 Subject: [PATCH] Test for symbolic links We disallow symbolic links to ensure implementations are standalone and more portable. --- test/test_no_symlinks.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/test_no_symlinks.py diff --git a/test/test_no_symlinks.py b/test/test_no_symlinks.py new file mode 100644 index 00000000..8309779b --- /dev/null +++ b/test/test_no_symlinks.py @@ -0,0 +1,30 @@ +""" +Checks that no implementation makes use of symbolic links. +""" + +import os +import pqclean +import sys + +def test_no_symlinks(): + for scheme in pqclean.Scheme.all_schemes(): + for implementation in scheme.implementations: + yield check_no_symlinks, scheme.name, implementation.name + + +def check_no_symlinks(scheme_name, implementation_name): + implementation = pqclean.Implementation.by_name( + scheme_name, implementation_name) + for file in os.listdir(implementation.path()): + fpath = os.path.join(implementation.path(), file) + if os.path.islink(fpath): + raise AssertionError("{} is a symbolic link!".format(fpath)) + + +if __name__ == '__main__': + try: + import nose2 + nose2.main() + except ImportError: + import nose + nose.runmodule()