[tor-commits] [stem/master] Skipping integ that need ptrace when inaccessable

atagar at torproject.org atagar at torproject.org
Fri Jan 13 17:46:31 UTC 2012


commit 4a0e1a755e43802340020b663f6982536bd57ecf
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Jan 13 08:46:19 2012 -0800

    Skipping integ that need ptrace when inaccessable
    
    When the tor connection is inaccessable I'm skipping the system integ tests
    that need ptrace support, since we can't check if it's enabled or not.
---
 test/integ/util/system.py |   24 ++++++++++++++++--------
 test/runner.py            |    6 +++---
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index 70d73ae..e06c05b 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -135,7 +135,9 @@ class TestSystem(unittest.TestCase):
       self.skipTest("(multiple tor instances)")
     elif not stem.util.system.is_available("lsof"):
       self.skipTest("(lsof unavailable)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_accessible():
+      self.skipTest("(unable to check for DisableDebuggerAttachment)")
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     lsof_prefix = stem.util.system.GET_PID_BY_NAME_LSOF % ""
@@ -149,7 +151,7 @@ class TestSystem(unittest.TestCase):
     runner = test.runner.get_runner()
     if not self._has_port():
       self.skipTest("(test instance has no port)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     tor_pid, tor_port = runner.get_pid(), test.runner.CONTROL_PORT
@@ -168,7 +170,7 @@ class TestSystem(unittest.TestCase):
       self.skipTest("(netstat unavailable)")
     elif stem.util.system.is_bsd():
       self.skipTest("(linux only)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     netstat_cmd = stem.util.system.GET_PID_BY_PORT_NETSTAT
@@ -186,7 +188,7 @@ class TestSystem(unittest.TestCase):
       self.skipTest("(sockstat unavailable)")
     elif not stem.util.system.is_bsd():
       self.skipTest("(bsd only)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     sockstat_prefix = stem.util.system.GET_PID_BY_PORT_SOCKSTAT % ""
@@ -202,7 +204,7 @@ class TestSystem(unittest.TestCase):
       self.skipTest("(test instance has no port)")
     elif not stem.util.system.is_available("lsof"):
       self.skipTest("(lsof unavailable)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     lsof_cmd = stem.util.system.GET_PID_BY_PORT_LSOF
@@ -229,7 +231,9 @@ class TestSystem(unittest.TestCase):
     
     runner = test.runner.get_runner()
     
-    if runner.is_debugging_prevented():
+    if not runner.is_accessible():
+      self.skipTest("(unable to check for DisableDebuggerAttachment)")
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     self.assertEquals(runner.get_tor_cwd(), stem.util.system.get_cwd(runner.get_pid()))
@@ -243,7 +247,9 @@ class TestSystem(unittest.TestCase):
     runner = test.runner.get_runner()
     if not stem.util.system.is_available("pwdx"):
       self.skipTest("(pwdx unavailable)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_accessible():
+      self.skipTest("(unable to check for DisableDebuggerAttachment)")
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     # filter the call function to only allow this command
@@ -261,7 +267,9 @@ class TestSystem(unittest.TestCase):
     runner = test.runner.get_runner()
     if not stem.util.system.is_available("lsof"):
       self.skipTest("(lsof unavailable)")
-    elif runner.is_debugging_prevented():
+    elif not runner.is_accessible():
+      self.skipTest("(unable to check for DisableDebuggerAttachment)")
+    elif not runner.is_ptraceable():
       self.skipTest("(DisableDebuggerAttachment is set)")
     
     # filter the call function to only allow this command
diff --git a/test/runner.py b/test/runner.py
index 5841154..36c41ce 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -11,7 +11,7 @@ Runner - Runtime context for our integration tests.
   |- stop - stops our tor instance and cleans up any temporary files
   |- is_running - checks if our tor test instance is running
   |- is_accessible - checks if our tor instance can be connected to
-  |- is_debugging_prevented - checks if DisableDebuggerAttachment is set
+  |- is_ptraceable - checks if DisableDebuggerAttachment is set
   |- get_test_dir - testing directory path
   |- get_torrc_path - path to our tor instance's torrc
   |- get_torrc_contents - contents of our tor instance's torrc
@@ -273,7 +273,7 @@ class Runner:
     conn_opts = self.get_connection_options()
     return OPT_PORT in conn_opts or OPT_SOCKET in conn_opts
   
-  def is_debugging_prevented(self):
+  def is_ptraceable(self):
     """
     Checks if tor's 'DisableDebuggerAttachment' option is set. This feature has
     a lot of adverse side effects as per...
@@ -292,7 +292,7 @@ class Runner:
     getconf_response = control_socket.recv()
     control_socket.close()
     
-    return str(getconf_response) == "DisableDebuggerAttachment=1"
+    return str(getconf_response) != "DisableDebuggerAttachment=1"
   
   def get_test_dir(self):
     """





More information about the tor-commits mailing list