From 9c701658661101916deb22304ad4b1da2a7ceaa4 Mon Sep 17 00:00:00 2001 From: René Meusel Date: Tue, 10 Mar 2020 10:42:14 +0100 Subject: set 'LD_LIBRARY_PATH=' in `make check` on Linux --- src/scripts/check.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/scripts/check.py b/src/scripts/check.py index 801688b5f..702541a2c 100644 --- a/src/scripts/check.py +++ b/src/scripts/check.py @@ -18,6 +18,10 @@ import platform def is_macos(): return platform.system() == "Darwin" +def is_linux(): + return platform.system() == "Linux" + + def run_and_check(cmd_line, env=None, cwd=None): logging.info("Starting %s", ' '.join(cmd_line)) @@ -33,6 +37,20 @@ def run_and_check(cmd_line, env=None, cwd=None): sys.exit(1) +def get_environment(shared_lib): + if not shared_lib: + return None + + env = os.environ.copy() + + if is_macos(): + env["DYLD_LIBRARY_PATH"] = os.path.abspath(".") + elif is_linux(): + env["LD_LIBRARY_PATH"] = os.path.abspath(".") + + return env + + def parse_options(args): parser = optparse.OptionParser() parser.add_option('--test-exe', default='botan-test', metavar='BINARY', @@ -62,11 +80,7 @@ def main(args=None): if shared_lib and not os.path.isfile(shared_lib): raise Exception("Shared library %s not found" % shared_lib) - env = os.environ.copy() - if shared_lib and is_macos(): - env["DYLD_LIBRARY_PATH"] = "." - - run_and_check([ test_exe ], env) + run_and_check([ test_exe ], get_environment(shared_lib)) return 0 -- cgit v1.2.3