From c16b88d914e3f0fedb1f26ff215b3672fceb0a2c Mon Sep 17 00:00:00 2001 From: Edouard Tisserant Date: Fri, 12 May 2017 02:23:01 +0200 Subject: [PATCH] Sync test : added test command line parameter to specify library search path for each instance, in order to test sync in between netpgp and gpg --- test/mp_sync_test.py | 14 +++++++++----- test/multipEp.py | 27 +++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/test/mp_sync_test.py b/test/mp_sync_test.py index 45a18c1..7a57f29 100644 --- a/test/mp_sync_test.py +++ b/test/mp_sync_test.py @@ -1,11 +1,15 @@ """ tests for keysync scenario -Launch it with something like : -LC_ALL=en_US.UTF-8 \ -DYLD_LIBRARY_PATH=/Users/ed/lib/ \ -PYTHONPATH=`pwd`/../build/lib.macosx-10.11-x86_64-3.4 \ -python3.4 mp_sync_test.py +* Launch it with latest built pEp Python Adapter (no install): +PYTHONPATH=`pwd`/build/lib.macosx-10.12-x86_64-3.4 \ +python3.4 test/mp_sync_test.py + +* With shared libs search path different for GroupA1 : +DYLD_LIBRARY_PATH=$HOME/lib_gpg \ +PYTHONPATH=`pwd`/build/lib.macosx-10.12-x86_64-3.4 \ +python3.4 test/mp_sync_test.py \ +libs_GroupA1=$HOME/lib_netpgp """ diff --git a/test/multipEp.py b/test/multipEp.py index 4356f46..10c4775 100644 --- a/test/multipEp.py +++ b/test/multipEp.py @@ -325,6 +325,7 @@ def pEp_instance_main(iname, tmpdirname, *args): # run with a dispensable $HOME to get fresh DB and PGP keyrings print("Instance " + iname + " runs into " + tmpdirname) os.environ['HOME'] = tmpdirname + pEp_instance_run(iname, *args) print(iname + " exiting") @@ -348,18 +349,40 @@ def start_debug(iname, proc): def start_instance(iname, tmpdir=None, instance_addresses = []): global handshakes_seen, test_config, msgs_folders + given_libs = None + for a in sys.argv: + if a.startswith("libs_"+iname+"="): + given_libs = a.split("=")[1] + break + if tmpdir is None: tmpdir = tempfile.TemporaryDirectory() + if given_libs is not None: + os.symlink(given_libs, os.path.join(tmpdir.name, "libs")) + + if sys.platform.startswith('darwin'): + ld_env_name = 'DYLD_LIBRARY_PATH' + else: + ld_env_name = 'LD_LIBRARY_PATH' + + orig_ld_env_val = None + if given_libs is not None: + orig_ld_env_val = os.environ.pop(ld_env_name, None) + os.environ[ld_env_name] = os.path.join(tmpdir.name, "libs") - tmpdirname = tmpdir.name conn, child_conn = ctx.Pipe() proc = ctx.Process( target=pEp_instance_main, - args=(iname, tmpdirname, instance_addresses, + args=(iname, tmpdir.name, instance_addresses, child_conn, msgs_folders, handshakes_seen, test_config)) proc.start() + if orig_ld_env_val is not None: + os.environ[ld_env_name] = orig_ld_env_val + elif given_libs is not None: + os.environ.pop(ld_env_name) + debug = False if "debug_"+iname in sys.argv : debug = True