Merge branch 'maint-0.4.5' into release-0.4.5
[tor.git] / src / test / test_rebind.sh
blob879008c1c12d3eeccb93ed3ad8a5df7890ea44a8
1 #!/bin/sh
3 umask 077
4 set -e
5 set -x
7 # emulate realpath(), in case coreutils or equivalent is not installed.
8 abspath() {
9 f="$*"
10 if [ -d "$f" ]; then
11 dir="$f"
12 base=""
13 else
14 dir="$(dirname "$f")"
15 base="/$(basename "$f")"
17 dir="$(cd "$dir" && pwd)"
18 echo "$dir$base"
21 UNAME_OS=$(uname -s | cut -d_ -f1)
22 if test "$UNAME_OS" = 'CYGWIN' || \
23 test "$UNAME_OS" = 'MSYS' || \
24 test "$UNAME_OS" = 'MINGW'; then
25 if test "$APPVEYOR" = 'True'; then
26 echo "This test is disabled on Windows CI, as it requires firewall exemptions. Skipping." >&2
27 exit 77
31 # find the tor binary
32 if [ $# -ge 1 ]; then
33 TOR_BINARY="${1}"
34 shift
35 else
36 TOR_BINARY="${TESTING_TOR_BINARY:-./src/app/tor}"
39 TOR_BINARY="$(abspath "$TOR_BINARY")"
41 echo "TOR BINARY IS ${TOR_BINARY}"
43 if "${TOR_BINARY}" --list-modules | grep -q "relay: no"; then
44 echo "This test requires the relay module. Skipping." >&2
45 exit 77
48 tmpdir=
49 clean () {
50 if [ -n "$tmpdir" ] && [ -d "$tmpdir" ]; then
51 rm -rf "$tmpdir"
55 trap clean EXIT HUP INT TERM
57 tmpdir="$(mktemp -d -t tor_rebind_test.XXXXXX)"
58 if [ -z "$tmpdir" ]; then
59 echo >&2 mktemp failed
60 exit 2
61 elif [ ! -d "$tmpdir" ]; then
62 echo >&2 mktemp failed to make a directory
63 exit 3
66 "${PYTHON:-python}" "${abs_top_srcdir:-.}/src/test/test_rebind.py" "${TOR_BINARY}" "$tmpdir"
68 exit $?