summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-08-27 12:07:40 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-08-27 12:07:40 +0000
commit563041cd074876fc6e1539a470adfbfd93a378d3 (patch)
treeb8813d8732aef81659ebb33879bdfd2e50a4e362
parentb48c07516446f56cb62e00a37a157fbdb41ef280 (diff)
downloadlasso-563041cd074876fc6e1539a470adfbfd93a378d3.tar.gz
lasso-563041cd074876fc6e1539a470adfbfd93a378d3.tar.xz
lasso-563041cd074876fc6e1539a470adfbfd93a378d3.zip
Tests: add configuration file loading to integration test
* tests/integration/README: * tests/integration/saml2/__init__.py: If ~/.config/lasso_integration.conf exists, load it to find path to authentic and lcs. Add support for three environement variables: - LASSO_BUILDDIR, to specify an out of source build directory to test, - NO_SILENT, to allow authentic and lcs outputs, - VALGRIND, to check memory leaks using valgrind.
-rw-r--r--tests/integration/README16
-rw-r--r--tests/integration/saml2/__init__.py49
2 files changed, 52 insertions, 13 deletions
diff --git a/tests/integration/README b/tests/integration/README
index cbc9cc61..da72cfd7 100644
--- a/tests/integration/README
+++ b/tests/integration/README
@@ -6,10 +6,20 @@ Requirements:
- nose (apt-get install python-nose)
- Authentic & LCS from Subversion and CVS
+
+
Default configuration is to look for apps in their installation directories,
-but it is also possible to run tests without installing anything. Example
-of a config file is in tests/config.py.example (must be renamed to config.py to
-be effective).
+but it is also possible to run tests without installing anything. Example of a
+config file is in tests/config.py.example (must be renamed to config.py to be
+effective). You can also place a configuration file in
+~/.config/lasso_integration.conf, the format is "key = value" without any
+quoting.
Tests are run with nosetests from this directory.
+You can use the following environement variables to fine tune the execution of
+the tests:
+ - LASSO_BUILDDIR, to specify an out of source build directory to
+ test,
+ - NO_SILENT, to allow authentic and lcs outputs,
+ - VALGRIND, to check memory leaks using valgrind.
diff --git a/tests/integration/saml2/__init__.py b/tests/integration/saml2/__init__.py
index f4e7ab35..50fcba0e 100644
--- a/tests/integration/saml2/__init__.py
+++ b/tests/integration/saml2/__init__.py
@@ -5,12 +5,38 @@ import subprocess
import time
import twill
import urllib2
+import os.path
+import re
-AUTHENTIC_SRCDIR = '/usr/local/src/authentic'
-AUTHENTICCTL = '/usr/sbin/authenticctl.py'
-AUTHENTIC_DATA_DIR = '/usr/share/authentic/'
-LCSCTL = '/usr/sbin/lcsctl.py'
-LCS_DATADIR = '/usr/share/lcs/'
+CONFIG_FILE = os.path.expanduser('~/.config/lasso_integration.conf')
+CONFIG = dict()
+
+if os.path.exists(CONFIG_FILE):
+ lines = open(CONFIG_FILE).read().splitlines()
+ i = 1
+ for line in lines:
+ try:
+ m = re.match('(\w*) = (.*)', line)
+ CONFIG[m.groups()[0]] = m.groups()[1]
+ except:
+ print "Line", i, " of configuration file", CONFIG_FILE, "is invalid:", line
+ i +=1
+
+# Combine default and configuration file
+AUTHENTIC_SRCDIR = CONFIG.get('AUTHENTIC_SRCDIR') or '/usr/local/src/authentic'
+AUTHENTICCTL = CONFIG.get('AUTHENTICCTL') or '/usr/sbin/authenticctl.py'
+AUTHENTIC_DATA_DIR = CONFIG.get('AUTHENTIC_DATA_DIR') or '/usr/share/authentic/'
+LCSCTL = CONFIG.get('LCSCTL') or '/usr/sbin/lcsctl.py'
+LCS_DATADIR = CONFIG.get('LCS_DATADIR') or '/usr/share/lcs/'
+LASSO_BUILDDIR = os.environ.get('LASSO_BUILDDIR') or \
+ CONFIG.get('LASSO_BUILDDIR') or \
+ os.path.realpath(os.path.join(os.path.dirname(__FILE__), "..", "..", ".."))
+
+os.environ['LD_LIBRARY_PATH'] = os.path.join(LASSO_BUILDDIR, "lasso", ".libs") + ":" + \
+ os.environ.get('LD_LIBRARY_PATH', '')
+os.environ['PYTHONPATH'] = os.path.join(LASSO_BUILDDIR, "bindings", "python") + \
+ ":" + os.path.join(LASSO_BUILDDIR, "bindings", "python", ".libs") + ":" + \
+ os.environ.get('PYTHONPATH', '')
try:
from config import *
@@ -37,10 +63,11 @@ def setup():
print >> sys.stderr, 'Create it or edit tests/config.py to match your local installation'
sys.exit(1)
+ silent = os.environ.get('NO_SILENT') is None
twill.commands.reset_browser()
twill.set_output(file('/dev/null', 'w'))
base = []
- if os.path.exists('/usr/bin/valgrind'):
+ if os.environ.get('VALGRIND') is '1' and os.path.exists('/usr/bin/valgrind'):
base = ['./valgrind-wrapper.sh', 'python']
os.mkdir('/tmp/.tests')
@@ -48,15 +75,17 @@ def setup():
'--app-dir', '/tmp/.tests/authentictests',
'--data-dir', AUTHENTIC_DATADIR,
'--extra', os.path.join(AUTHENTIC_SRCDIR, 'extra', 'conformance'),
- '--port', '10001', '--http', '--silent']
- print authentic_command
+ '--port', '10001', '--http']
+ if silent:
+ authentic_command.append('--silent')
sp = subprocess.Popen(authentic_command)
pids.append(sp.pid)
lcs_command = base + [LCSCTL, 'start',
'--app-dir', '/tmp/.tests/lcstests',
'--data-dir', LCS_DATADIR,
- '--port', '10002', '--http', '--silent']
- print lcs_command
+ '--port', '10002', '--http']
+ if silent:
+ lcs_command.append('--silent')
sp = subprocess.Popen(lcs_command)
pids.append(sp.pid)