X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Ftests.py;h=7a7b1681f16d395e4188384782d218bcff41b31d;hb=61de77fc7eae1f844944bd692d13bf27a1fda6fe;hp=6dfd8c44507a75be0e6bb57c80fb2d744a0336be;hpb=965e6299f409e6eacf3490a11f8161ea643ac2f8;p=cascardo%2Fipsilon.git diff --git a/tests/tests.py b/tests/tests.py index 6dfd8c4..7a7b168 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,21 +1,6 @@ #!/usr/bin/python # -# Copyright (C) 2014 Simo Sorce -# -# see file 'COPYING' for use and warranty information -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING import argparse import inspect @@ -23,7 +8,9 @@ from ipsilon.util import plugin import os import sys import subprocess +import time import traceback +from helpers.common import WRAP_HOSTNAME # pylint: disable=relative-import logger = None @@ -62,12 +49,27 @@ def try_wrappers(base, wrappers): else: raise ValueError('Socket Wrappers not available') + pkgcfg = subprocess.Popen(['pkg-config', '--exists', 'nss_wrapper']) + pkgcfg.wait() + if pkgcfg.returncode != 0: + if wrappers == 'auto': + return {} + else: + raise ValueError('Nss Wrappers not available') + wrapdir = os.path.join(base, 'wrapdir') os.mkdir(wrapdir) - wenv = {'LD_PRELOAD': 'libsocket_wrapper.so', + hosts_file = os.path.join(base, 'hosts') + with open(hosts_file, 'w+') as f: + f.write('127.0.0.9 %s\n' % WRAP_HOSTNAME) + + wenv = {'LD_PRELOAD': 'libsocket_wrapper.so libnss_wrapper.so', 'SOCKET_WRAPPER_DIR': wrapdir, - 'SOCKET_WRAPPER_DEFAULT_IFACE': '9'} + 'SOCKET_WRAPPER_DEFAULT_IFACE': '9', + 'SOCKET_WRAPPER_DEBUGLEVEL': '1', + 'NSS_WRAPPER_HOSTNAME': WRAP_HOSTNAME, + 'NSS_WRAPPER_HOSTS': hosts_file} return wenv @@ -89,6 +91,7 @@ if __name__ == '__main__': env = try_wrappers(test.testdir, args['wrappers']) env['PYTHONPATH'] = test.rootdir + env['TESTDIR'] = test.testdir try: test.setup_servers(env) @@ -103,4 +106,6 @@ if __name__ == '__main__': finally: test.wait() + # Wait until all of the sockets are closed by the OS + time.sleep(0.5) print "FINISHED"