commit 56aac96d6213f28a6b597c640affc7a5a963bf75 Author: Damian Johnson atagar@torproject.org Date: Mon Oct 29 19:26:42 2012 -0700
Conficting DataDirectory for process tests
The process module's integ tests start and stop tor instances. However, if you're already running tor then the DataDirectory of these instances will conflict with what you're already running...
Oct 29 19:18:11.532 [notice] Tor v0.2.1.30. This is experimental software. Do not rely on it for strong anonymity. (Running on Linux i686) Oct 29 19:18:11.540 [warn] ControlPort is open, but no authentication method has been configured. This means that any program on your computer can reconfigure your Tor. That's bad! You should upgrade your Tor controller as soon as possible. Oct 29 19:18:11.541 [notice] Initialized libevent version 1.4.13-stable using method epoll. Good. Oct 29 19:18:11.542 [notice] Opening Socks listener on 127.0.0.1:2777 Oct 29 19:18:11.543 [notice] Opening Control listener on 127.0.0.1:2778 Oct 29 19:18:11.543 [warn] It looks like another Tor process is running with the same data directory. Waiting 5 seconds to see if it goes away. Oct 29 19:18:16.546 [err] No, it's still there. Exiting.
Issue spotted by gsathya on... https://trac.torproject.org/7251 --- test/integ/process.py | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/test/integ/process.py b/test/integ/process.py index 5396756..127eb40 100644 --- a/test/integ/process.py +++ b/test/integ/process.py @@ -4,6 +4,7 @@ Tests the stem.process functions with various use cases.
import os import time +import shutil import signal import unittest
@@ -13,7 +14,15 @@ import stem.process import test.runner import stem.util.system
+DATA_DIRECTORY = '/tmp/stem_integ' + class TestProcess(unittest.TestCase): + def setUp(self): + os.makedirs(DATA_DIRECTORY) + + def tearDown(self): + shutil.rmtree(DATA_DIRECTORY, ignore_errors = True) + def test_launch_tor_with_config(self): """ Exercises launch_tor_with_config. @@ -31,7 +40,11 @@ class TestProcess(unittest.TestCase): runner = test.runner.get_runner() tor_process = stem.process.launch_tor_with_config( tor_cmd = runner.get_tor_command(), - config = {'SocksPort': '2777', 'ControlPort': '2778'}, + config = { + 'SocksPort': '2777', + 'ControlPort': '2778', + 'DataDirectory': DATA_DIRECTORY, + }, completion_percent = 5 )
@@ -71,7 +84,8 @@ class TestProcess(unittest.TestCase):
runner = test.runner.get_runner() start_time = time.time() - self.assertRaises(OSError, stem.process.launch_tor_with_config, {'SocksPort': '2777'}, runner.get_tor_command(), 100, None, 2) + config = {'SocksPort': '2777', 'DataDirectory': DATA_DIRECTORY} + self.assertRaises(OSError, stem.process.launch_tor_with_config, config, runner.get_tor_command(), 100, None, 2) runtime = time.time() - start_time
if not (runtime > 2 and runtime < 3):