test_cmdline.sh (1259B)
1 #!/bin/sh 2 3 umask 077 4 set -e 5 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")" 15 fi 16 dir="$(cd "$dir" && pwd)" 17 echo "$dir$base" 18 } 19 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}" 26 fi 27 28 TOR_BINARY="$(abspath "$TOR_BINARY")" 29 30 echo "TOR BINARY IS ${TOR_BINARY}" 31 32 die() { echo "$1" >&2 ; exit 5; } 33 34 echo "A" 35 36 DATA_DIR=$(mktemp -d -t tor_cmdline_tests.XXXXXX) 37 trap 'rm -rf "$DATA_DIR"' 0 38 39 # 1. Test list-torrc-options. 40 OUT="${DATA_DIR}/output" 41 42 echo "B" 43 "${TOR_BINARY}" --list-torrc-options > "$OUT" 44 45 echo "C" 46 47 # regular options are given. 48 grep -i "SocksPort" "$OUT" >/dev/null || die "Did not find SocksPort" 49 50 51 echo "D" 52 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" 55 56 echo "E" 57 58 # unsettable options are not given. 59 if grep -i "DisableIOCP" "$OUT" /dev/null; then 60 die "Found DisableIOCP" 61 fi 62 if grep -i "HiddenServiceOptions" "$OUT" /dev/null ; then 63 die "Found HiddenServiceOptions" 64 fi 65 echo "OK"