Merge branch 'maint-0.4.8'
[tor.git] / src / test / test_cmdline.sh
blobded58af63d15febabc96d7a7b09f4cfb99b4fa51
1 #!/bin/sh
3 umask 077
4 set -e
6 # emulate realpath(), in case coreutils or equivalent is not installed.
7 abspath() {
8 f="$*"
9 if [ -d "$f" ]; then
10 dir="$f"
11 base=""
12 else
13 dir="$(dirname "$f")"
14 base="/$(basename "$f")"
16 dir="$(cd "$dir" && pwd)"
17 echo "$dir$base"
20 # find the tor binary
21 if [ $# -ge 1 ]; then
22 TOR_BINARY="${1}"
23 shift
24 else
25 TOR_BINARY="${TESTING_TOR_BINARY:-./src/app/tor}"
28 TOR_BINARY="$(abspath "$TOR_BINARY")"
30 echo "TOR BINARY IS ${TOR_BINARY}"
32 die() { echo "$1" >&2 ; exit 5; }
34 echo "A"
36 DATA_DIR=$(mktemp -d -t tor_cmdline_tests.XXXXXX)
37 trap 'rm -rf "$DATA_DIR"' 0
39 # 1. Test list-torrc-options.
40 OUT="${DATA_DIR}/output"
42 echo "B"
43 "${TOR_BINARY}" --list-torrc-options > "$OUT"
45 echo "C"
47 # regular options are given.
48 grep -i "SocksPort" "$OUT" >/dev/null || die "Did not find SocksPort"
51 echo "D"
53 # unlisted options are given, since they do not have the NOSET flag.
54 grep -i "__SocksPort" "$OUT" > /dev/null || die "Did not find __SocksPort"
56 echo "E"
58 # unsettable options are not given.
59 if grep -i "DisableIOCP" "$OUT" /dev/null; then
60 die "Found DisableIOCP"
62 if grep -i "HiddenServiceOptions" "$OUT" /dev/null ; then
63 die "Found HiddenServiceOptions"
65 echo "OK"