diff options
author | Taylor R Campbell <campbell+tor@mumble.net> | 2018-11-22 00:53:57 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-17 10:32:28 -0500 |
commit | ed71e1e89cef5aee719f8b240dcd5d1f1f240f06 (patch) | |
tree | 33b62ce66128635e6b38c1a9aa1e1edfb7b85051 /src/test | |
parent | 94a79981580d6260597f799bc1a163c8e6f07acd (diff) | |
download | tor-ed71e1e89cef5aee719f8b240dcd5d1f1f240f06.tar.gz tor-ed71e1e89cef5aee719f8b240dcd5d1f1f240f06.zip |
Create a temporary directory for tor's DataDirectory in test_rebind.
Fixes #28562.
While here, put the argument count test and usage message _before_ we
attempt to read from sys.argv.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_rebind.py | 10 | ||||
-rwxr-xr-x | src/test/test_rebind.sh | 15 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/test/test_rebind.py b/src/test/test_rebind.py index 2215b42253..6f759b717e 100644 --- a/src/test/test_rebind.py +++ b/src/test/test_rebind.py @@ -73,12 +73,19 @@ socks_port = pick_random_port() assert control_port != 0 assert socks_port != 0 +if len(sys.argv) < 3: + fail('Usage: %s <path-to-tor> <data-dir>' % sys.argv[0]) + if not os.path.exists(sys.argv[1]): fail('ERROR: cannot find tor at %s' % sys.argv[1]) +if not os.path.exists(sys.argv[2]): + fail('ERROR: cannot find datadir at %s' % sys.argv[2]) tor_path = sys.argv[1] +data_dir = sys.argv[2] tor_process = subprocess.Popen([tor_path, + '-DataDirectory', data_dir, '-ControlPort', '127.0.0.1:{}'.format(control_port), '-SOCKSPort', '127.0.0.1:{}'.format(socks_port), '-Log', 'debug stdout', @@ -90,9 +97,6 @@ tor_process = subprocess.Popen([tor_path, if tor_process == None: fail('ERROR: running tor failed') -if len(sys.argv) < 2: - fail('Usage: %s <path-to-tor>' % sys.argv[0]) - wait_for_log('Opened Control listener on') try_connecting_to_socksport() diff --git a/src/test/test_rebind.sh b/src/test/test_rebind.sh index 76eb9f2e4d..498072de35 100755 --- a/src/test/test_rebind.sh +++ b/src/test/test_rebind.sh @@ -14,6 +14,19 @@ fi exitcode=0 -"${PYTHON:-python}" "${abs_top_srcdir:-.}/src/test/test_rebind.py" "${TESTING_TOR_BINARY}" || exitcode=1 +tmpdir= +clean () { test -n "$tmpdir" && test -d "$tmpdir" && rm -rf "$tmpdir" || :; } +trap clean EXIT HUP INT TERM + +tmpdir="`mktemp -d -t tor_rebind_test.XXXXXX`" +if [ -z "$tmpdir" ]; then + echo >&2 mktemp failed + exit 2 +elif [ ! -d "$tmpdir" ]; then + echo >&2 mktemp failed to make a directory + exit 3 +fi + +"${PYTHON:-python}" "${abs_top_srcdir:-.}/src/test/test_rebind.py" "${TESTING_TOR_BINARY}" "$tmpdir" || exitcode=1 exit ${exitcode} |