1#!/bin/bash
2#
3# This runs the available unit-tests with all different supported
4# python versions.
5#
6# To run this this must be 'cd'ed to the tests directory.
7#
8
9ENABLE_UNSUPPORTED=0
10
11function usage()
12{
13    printf "Usage: %s: [-u]\n" $0
14    printf "   -u: run test with unsupported python versions also\n"
15}
16
17function run_one_test()
18{
19    PYTHON=$1
20    PYTHON_EXECUTABLE=`echo $PYTHON | tr -d "-"`
21    echo "+++ Running tests with $PYTHON"
22    export LD_LIBRARY_PATH=./regression/installed/$PYTHON/lib
23    ./regression/installed/$PYTHON/bin/$PYTHON_EXECUTABLE \
24	utests/run_all_tests.py
25    echo "--- Finished tests with $PYTHON"
26}
27
28function run_all_tests()
29{
30    for PYTHON in $@;
31    do
32	run_one_test $PYTHON
33    done
34}
35
36while getopts u name
37do
38    case $name in
39	h)  usage; exit 0;;
40	u)  ENABLE_UNSUPPORTED=1;;
41	?)  usage; exit 2;;
42    esac
43done
44
45# Build the different python versions
46(cd regression && make -j4 runtime-environment)
47
48# Supported: when an unit test fails this should be seen as an error
49PYTHON_SUPPORTED="python-2.4 python-2.5 python-2.6"
50# Unsupported: failure should be seen as a hint
51PYTHON_UNSUPPORTED="python-3.1"
52
53export PYTHONPATH=`echo $PWD/../python/build/lib.*`:$PWD
54
55set -e
56run_all_tests $PYTHON_SUPPORTED
57
58if test $ENABLE_UNSUPPORTED -eq 1
59then
60    run_all_tests $PYTHON_UNSUPPORTED
61fi
62