summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-04-30 14:58:24 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-04-30 14:58:24 +0000
commita4e03e7626c281410cc396fb1202132e216ed358 (patch)
tree105b4679d1d4f716c641e48795a27e8a0a8aace1 /tests
parent7e4a554d61314eca12247b419080e7a09f5b3309 (diff)
downloadlasso-a4e03e7626c281410cc396fb1202132e216ed358.tar.gz
lasso-a4e03e7626c281410cc396fb1202132e216ed358.tar.xz
lasso-a4e03e7626c281410cc396fb1202132e216ed358.zip
Add valgrind support to integration tests
* tests/integration/saml2/__init__.py: if /usr/bin/valgrind exist, use script valgrind-wrapper.sh to launch tests, it stores log files in {authentic,lcs}_$ISODATE_pid$PID.log.
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/saml2/__init__.py37
-rwxr-xr-xtests/integration/valgrind-wrapper.sh10
2 files changed, 41 insertions, 6 deletions
diff --git a/tests/integration/saml2/__init__.py b/tests/integration/saml2/__init__.py
index b3baf04d..6b3123c4 100644
--- a/tests/integration/saml2/__init__.py
+++ b/tests/integration/saml2/__init__.py
@@ -4,6 +4,7 @@ import signal
import subprocess
import time
import twill
+import urllib2
AUTHENTIC_SRCDIR = '/usr/local/src/authentic'
AUTHENTICCTL = '/usr/sbin/authenticctl.py'
@@ -18,6 +19,18 @@ except ImportError:
pids = []
+def waitforport(port, start):
+ while True:
+ if time.time() - start > 90:
+ raise Exception('Servers did not start in 90 seconds!!')
+ time.sleep(5)
+ try:
+ urllib2.urlopen('http://localhost:%s' % port)
+ except urllib2.URLError:
+ continue
+ else:
+ break
+
def setup():
if not os.path.exists(AUTHENTIC_SRCDIR):
print >> sys.stderr, 'Authentic source dir (%s) does not exist' % AUTHENTIC_SRCDIR
@@ -26,27 +39,39 @@ def setup():
twill.commands.reset_browser()
twill.set_output(file('/dev/null', 'w'))
+ base = []
+ if os.path.exists('/usr/bin/valgrind'):
+ base = ['./valgrind-wrapper.sh', 'python']
+ os.environ['PYTHONPATH'] = '../../bindings/python:../../bindings/python/.libs'
os.mkdir('/tmp/.tests')
- sp = subprocess.Popen([AUTHENTICCTL, 'start',
+ authentic_command = base + [AUTHENTICCTL, 'start',
'--app-dir', '/tmp/.tests/authentictests',
'--data-dir', AUTHENTIC_DATADIR,
'--extra', os.path.join(AUTHENTIC_SRCDIR, 'extra', 'conformance'),
- '--port', '10001', '--http', '--silent'])
+ '--port', '10001', '--http', '--silent']
+ print authentic_command
+ sp = subprocess.Popen(authentic_command)
pids.append(sp.pid)
- sp = subprocess.Popen([LCSCTL, 'start',
+ lcs_command = base + [LCSCTL, 'start',
'--app-dir', '/tmp/.tests/lcstests',
'--data-dir', LCS_DATADIR,
- '--port', '10002', '--http', '--silent'])
+ '--port', '10002', '--http', '--silent']
+ print lcs_command
+ sp = subprocess.Popen(lcs_command)
pids.append(sp.pid)
- time.sleep(5) # let process bind ports
+ # Wait for the daemons to load themselves
+ starttime = time.time()
+ waitforport(10001, starttime)
+ waitforport(10002, starttime)
def teardown():
for pid in pids:
try:
- os.kill(pid, signal.SIGTERM)
+ # valgrind seems to prefer SIGINT to SIGTERM
+ os.kill(pid, signal.SIGINT)
except OSError:
print >> sys.stderr, 'failed to kill pid %s' % pid
os.system('rm -rf /tmp/.tests/')
diff --git a/tests/integration/valgrind-wrapper.sh b/tests/integration/valgrind-wrapper.sh
new file mode 100755
index 00000000..df2f8cd4
--- /dev/null
+++ b/tests/integration/valgrind-wrapper.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+DATE=`date +%FT%TZ`
+if [ $1 == 'python' ]; then
+ NAME=`basename $2`
+else
+ NAME=$1
+fi
+env MALLOC_CHECK_=2 G_SLICE=always-malloc PYTHONPATH=/home/bdauvergne/wd/lasso/git/bindings/python:/home/bdauvergne/wd/lasso/git/bindings/python/.libs LD_LIBRARY_PATH=/home/bdauvergne/wd/lasso/git/lasso/.libs valgrind --show-reachable=yes --suppressions=../valgrind/lasso.supp --suppressions=../valgrind/glib.supp --suppressions=../valgrind/openssl.supp --suppressions=/usr/lib/valgrind/python.supp --leak-check=full --log-file="${NAME}_${DATE}_pid-$$.log" --track-origins=yes "$@"
+
+