diff options
author | Taylor R Campbell <campbell+tor@mumble.net> | 2018-11-22 00:53:57 +0000 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-11-23 12:51:39 -0500 |
commit | 997a8b0ca7a4f4eafa2cd09582c4bcc0507e2fa6 (patch) | |
tree | 8fa6285a3a97104149ff1407a3ce5f52a26a5eee /src/test/test_rebind.py | |
parent | 3741f9e524a2d3bd7239ca865d6169fd1e3dddb5 (diff) | |
download | tor-997a8b0ca7a4f4eafa2cd09582c4bcc0507e2fa6.tar.gz tor-997a8b0ca7a4f4eafa2cd09582c4bcc0507e2fa6.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/test_rebind.py')
-rw-r--r-- | src/test/test_rebind.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/test/test_rebind.py b/src/test/test_rebind.py index c63341a681..2f366b2716 100644 --- a/src/test/test_rebind.py +++ b/src/test/test_rebind.py @@ -67,12 +67,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), '-FetchServerDescriptors', '0'], @@ -82,9 +89,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() |