[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Making integ account for DisableDebuggerAttachment



commit 27e84652f1bd97747a1360f7632783923cf762b2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Jan 12 09:51:40 2012 -0800

    Making integ account for DisableDebuggerAttachment
    
    Stem's system integration tests failed with tor's new version because
    DisableDebuggerAttachment prevents cwd and port lookups. Skipping those tests
    when that option is set.
---
 test/integ/util/system.py |   35 ++++++++++++++++++++++++++++++-----
 test/runner.py            |   21 +++++++++++++++++++++
 2 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index 4f78099..70d73ae 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -130,10 +130,13 @@ class TestSystem(unittest.TestCase):
     Tests the get_pid_by_name function with a lsof response.
     """
     
+    runner = test.runner.get_runner()
     if self.is_extra_tor_running:
       self.skipTest("(multiple tor instances)")
     elif not stem.util.system.is_available("lsof"):
       self.skipTest("(lsof unavailable)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
     lsof_prefix = stem.util.system.GET_PID_BY_NAME_LSOF % ""
     self._run_pid_test(lsof_prefix, stem.util.system.get_pid_by_name, "tor")
@@ -143,10 +146,13 @@ class TestSystem(unittest.TestCase):
     Checks general usage of the stem.util.system.get_pid_by_port function.
     """
     
+    runner = test.runner.get_runner()
     if not self._has_port():
       self.skipTest("(test instance has no port)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
-    tor_pid, tor_port = test.runner.get_runner().get_pid(), test.runner.CONTROL_PORT
+    tor_pid, tor_port = runner.get_pid(), test.runner.CONTROL_PORT
     self.assertEquals(tor_pid, stem.util.system.get_pid_by_port(tor_port))
     self.assertEquals(None, stem.util.system.get_pid_by_port(99999))
   
@@ -155,11 +161,15 @@ class TestSystem(unittest.TestCase):
     Tests the get_pid_by_port function with a netstat response.
     """
     
+    runner = test.runner.get_runner()
     if not self._has_port():
       self.skipTest("(test instance has no port)")
     elif not stem.util.system.is_available("netstat"):
       self.skipTest("(netstat unavailable)")
-    elif stem.util.system.is_bsd(): self.skipTest("(linux only)")
+    elif stem.util.system.is_bsd():
+      self.skipTest("(linux only)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
     netstat_cmd = stem.util.system.GET_PID_BY_PORT_NETSTAT
     self._run_pid_test(netstat_cmd, stem.util.system.get_pid_by_port, test.runner.CONTROL_PORT)
@@ -169,11 +179,15 @@ class TestSystem(unittest.TestCase):
     Tests the get_pid_by_port function with a sockstat response.
     """
     
+    runner = test.runner.get_runner()
     if not self._has_port():
       self.skipTest("(test instance has no port)")
     elif not stem.util.system.is_available("sockstat"):
       self.skipTest("(sockstat unavailable)")
-    elif not stem.util.system.is_bsd(): self.skipTest("(bsd only)")
+    elif not stem.util.system.is_bsd():
+      self.skipTest("(bsd only)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
     sockstat_prefix = stem.util.system.GET_PID_BY_PORT_SOCKSTAT % ""
     self._run_pid_test(sockstat_prefix, stem.util.system.get_pid_by_port, test.runner.CONTROL_PORT)
@@ -183,10 +197,13 @@ class TestSystem(unittest.TestCase):
     Tests the get_pid_by_port function with a lsof response.
     """
     
+    runner = test.runner.get_runner()
     if not self._has_port():
       self.skipTest("(test instance has no port)")
     elif not stem.util.system.is_available("lsof"):
       self.skipTest("(lsof unavailable)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
     lsof_cmd = stem.util.system.GET_PID_BY_PORT_LSOF
     self._run_pid_test(lsof_cmd, stem.util.system.get_pid_by_port, test.runner.CONTROL_PORT)
@@ -211,6 +228,10 @@ class TestSystem(unittest.TestCase):
     """
     
     runner = test.runner.get_runner()
+    
+    if runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
+    
     self.assertEquals(runner.get_tor_cwd(), stem.util.system.get_cwd(runner.get_pid()))
     self.assertEquals(None, stem.util.system.get_cwd(99999))
   
@@ -219,14 +240,16 @@ class TestSystem(unittest.TestCase):
     Tests the get_pid_by_cwd function with a pwdx response.
     """
     
+    runner = test.runner.get_runner()
     if not stem.util.system.is_available("pwdx"):
       self.skipTest("(pwdx unavailable)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
     # filter the call function to only allow this command
     pwdx_prefix = stem.util.system.GET_CWD_PWDX % ""
     stem.util.system.CALL_MOCKING = lambda cmd: cmd.startswith(pwdx_prefix)
     
-    runner = test.runner.get_runner()
     runner_pid, tor_cwd = runner.get_pid(), runner.get_tor_cwd()
     self.assertEquals(tor_cwd, stem.util.system.get_cwd(runner_pid))
   
@@ -235,14 +258,16 @@ class TestSystem(unittest.TestCase):
     Tests the get_pid_by_cwd function with a lsof response.
     """
     
+    runner = test.runner.get_runner()
     if not stem.util.system.is_available("lsof"):
       self.skipTest("(lsof unavailable)")
+    elif runner.is_debugging_prevented():
+      self.skipTest("(DisableDebuggerAttachment is set)")
     
     # filter the call function to only allow this command
     lsof_prefix = "lsof -a -p "
     stem.util.system.CALL_MOCKING = lambda cmd: cmd.startswith(lsof_prefix)
     
-    runner = test.runner.get_runner()
     runner_pid, tor_cwd = runner.get_pid(), runner.get_tor_cwd()
     self.assertEquals(tor_cwd, stem.util.system.get_cwd(runner_pid))
   
diff --git a/test/runner.py b/test/runner.py
index cfe6dbb..ea2a60c 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -254,6 +254,27 @@ class Runner:
     
     return is_running
   
+  def is_debugging_prevented(self):
+    """
+    Checks if tor's 'DisableDebuggerAttachment' option is set. This feature has
+    a lot of adverse side effects as per...
+    https://trac.torproject.org/projects/tor/ticket/3313
+    
+    Returns:
+      True if debugger attachment is disallowd, False otherwise, and None if
+      tor can't be checked
+    """
+    
+    # TODO: replace higher level GETCONF query when we have a controller class
+    control_socket = self.get_tor_socket()
+    if control_socket == None: return None
+    
+    control_socket.send("GETCONF DisableDebuggerAttachment")
+    getconf_response = control_socket.recv()
+    control_socket.close()
+    
+    return str(getconf_response) == "DisableDebuggerAttachment=1"
+  
   def get_test_dir(self):
     """
     Provides the absolute path for our testing directory.

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits