#!/bin/sh # This script assumes that it is run in a temporary directory where it can # create and delete subdirectories for files, logs, etc., but other users # cannot write (for instance, /tmp is unsuitable, but # the directory created by `mktemp -d /tmp/test.XXXXXXXXXX` is fine). # # During "make check" or "make installcheck" it runs in # ${top_builddir}/tests/twisted. # # During installed testing, the test environment must run it in a # suitable location. set -e MC_TEST_CURDIR="`pwd`" export MC_TEST_CURDIR if test "x$MC_TEST_UNINSTALLED" = x; then script_fullname=`readlink -e "@mctestsdir@/twisted/run-test.sh"` if [ `readlink -e "$0"` != "$script_fullname" ] ; then echo "Bail out! This script is meant to be installed at $script_fullname" exit 1 fi test_src="@mctestsdir@" test_build="@mctestsdir@" config_file="@mctestsdir@/twisted/tools/servicedir-installed/tmp-session-bus.conf" plugins="@mctestsdir@/twisted/plugins" PYTHONPATH="@mctestsdir@/twisted" export PYTHONPATH MC_TWISTED_PATH="@mctestsdir@/twisted" export MC_TWISTED_PATH else if test -z "$MC_ABS_TOP_SRCDIR"; then echo "Bail out! MC_ABS_TOP_SRCDIR must be set" exit 1 fi if test -z "$MC_ABS_TOP_BUILDDIR"; then echo "Bail out! MC_ABS_TOP_BUILDDIR must be set" exit 1 fi test_src="${MC_ABS_TOP_SRCDIR}/tests" test_build="${MC_ABS_TOP_BUILDDIR}/tests" config_file="${test_build}/twisted/tools/servicedir-uninstalled/tmp-session-bus.conf" plugins="${test_build}/twisted/.libs" PYTHONPATH="${test_src}/twisted:${test_build}/twisted" export PYTHONPATH MC_TWISTED_PATH="${test_src}/twisted" export MC_TWISTED_PATH fi MC_DEBUG=all export MC_DEBUG G_DEBUG=fatal-criticals export G_DEBUG GIO_EXTRA_MODULES="${plugins}" export GIO_EXTRA_MODULES MC_FILTER_PLUGIN_DIR="${plugins}" export MC_FILTER_PLUGIN_DIR XDG_CONFIG_DIRS="${test_src}/twisted" export XDG_CONFIG_DIRS MC_CLIENTS_DIR="${test_src}/twisted/telepathy/clients" export MC_CLIENTS_DIR MC_MANAGER_DIR="${test_src}/twisted/telepathy/managers" export MC_MANAGER_DIR if [ -n "$1" ] ; then list="$1" else list=$(cat "${test_build}"/twisted/mc-twisted-tests.list) fi n=0 for i in $list ; do n=$(( $n + 1 )) done echo "1..$n" i=0 n_failed=0 for t in $list ; do i=$(( $i + 1 )) echo "# Testing $i/$n: $t ..." tmp="${MC_TEST_CURDIR}/tmp-`echo $t | tr ./ __`" rm -fr "$tmp" mkdir "$tmp" MC_TEST_LOG_DIR="${tmp}" export MC_TEST_LOG_DIR MC_ACCOUNT_DIR="${tmp}/mc-account-dir" export MC_ACCOUNT_DIR XDG_CONFIG_HOME="${tmp}/config" export XDG_CONFIG_HOME XDG_DATA_HOME="${tmp}/localshare" export XDG_DATA_HOME XDG_DATA_DIRS="${tmp}/share:${test_src}/twisted" export XDG_DATA_DIRS XDG_CACHE_HOME="${tmp}/cache" export XDG_CACHE_HOME XDG_CACHE_DIR="${tmp}/cache" export XDG_CACHE_DIR CHECK_TWISTED_VERBOSE=1 export CHECK_TWISTED_VERBOSE e=0 sh "${test_src}/twisted/tools/with-session-bus.sh" \ ${MC_TEST_SLEEP} \ --also-for-system \ --config-file="${config_file}" \ -- \ @TEST_PYTHON@ -u "${test_src}/twisted/$t" \ > "$tmp"/test.log 2>&1 || e=$? case "$e" in (0) echo "ok $i - $t" if test -z "$MC_TEST_KEEP_TEMP"; then rm -fr "$tmp" fi ;; (77) echo "ok $i # SKIP $t" if test -z "$MC_TEST_KEEP_TEMP"; then rm -fr "$tmp" fi ;; (*) n_failed=$(( $n_failed + 1 )) echo "not ok $i - $t ($e)" ( cd $tmp && for x in *.log; do echo "# ===== log file: $x =====" sed 's/^/# /' "$x" done echo "# ===== end of log files for $t =====" ) ;; esac done if test $n_failed != 0; then echo "# Tests run: $n; tests failed: $n_failed" exit 1 else exit 0 fi