[tor-commits] [stem/master] Integ test for when spawning a tor process fails

atagar at torproject.org atagar at torproject.org
Mon Feb 9 04:30:53 UTC 2015


commit e006b5660eab77679939f6cbe329a71dbc3bed34
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Feb 1 13:23:37 2015 -0800

    Integ test for when spawning a tor process fails
    
    Spotted that we're missing a test for this while looking into an issue where we
    possibly leave lingering tor processes...
    
      https://trac.torproject.org/projects/tor/ticket/14419
---
 test/integ/process.py |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/test/integ/process.py b/test/integ/process.py
index bd080b6..163fd2b 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -67,6 +67,32 @@ class TestProcess(unittest.TestCase):
       tor_process.kill()
       tor_process.wait()
 
+  def test_with_invalid_config(self):
+    """
+    Spawn a tor process with a configuration that should make it dead on arrival.
+    """
+
+    if test.runner.only_run_once(self, 'test_with_invalid_config'):
+      return
+
+    # Set the same SocksPort and ControlPort, this should fail with...
+    #
+    #   [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
+    #   [err] Reading config failed--see warnings above.
+
+    try:
+      stem.process.launch_tor_with_config(
+        tor_cmd = test.runner.get_runner().get_tor_command(),
+        config = {
+          'SocksPort': '2777',
+          'ControlPort': '2777',
+          'DataDirectory': self.data_directory,
+        },
+      )
+      self.fail("We should abort when there's an identical SocksPort and ControlPort")
+    except OSError as exc:
+      self.assertEqual('Process terminated: Failed to bind one of the listener ports.', str(exc))
+
   def test_launch_tor_with_timeout(self):
     """
     Runs launch_tor where it times out before completing.





More information about the tor-commits mailing list