[tor-commits] [stem/master] Integ target for running with ptrace

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


commit 19491fb8a411a5737ca438b9dc943a13f8eb44b8
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Jan 13 09:15:49 2012 -0800

    Integ target for running with ptrace
    
    Integraion target that runs with 'DisableDebuggerAttachment 0'. This allows us
    to exercise use cases that require ptrace with newer tor versions. If
    'DisableDebuggerAttachment' isn't supported then we skip the target.
---
 run_tests.py                          |   13 ++++++++++++-
 stem/version.py                       |    1 +
 test/integ/connection/protocolinfo.py |    2 ++
 test/runner.py                        |    4 +++-
 test/testrc.sample                    |    5 ++++-
 5 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index f458a80..64bde44 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -62,7 +62,7 @@ INTEG_TESTS = (
 )
 
 # Integration tests above the basic suite.
-TARGETS = stem.util.enum.Enum(*[(v, v) for v in ("ONLINE", "RELATIVE", "CONN_NONE", "CONN_OPEN", "CONN_PASSWORD", "CONN_COOKIE", "CONN_MULTIPLE", "CONN_SOCKET", "CONN_SCOOKIE", "CONN_ALL")])
+TARGETS = stem.util.enum.Enum(*[(v, v) for v in ("ONLINE", "RELATIVE", "CONN_NONE", "CONN_OPEN", "CONN_PASSWORD", "CONN_COOKIE", "CONN_MULTIPLE", "CONN_SOCKET", "CONN_SCOOKIE", "CONN_PTRACE", "CONN_ALL")])
 
 TARGET_ATTR = {
   TARGETS.ONLINE: ("test.integ.target.online", "Includes tests that require network activity."),
@@ -74,6 +74,7 @@ TARGET_ATTR = {
   TARGETS.CONN_MULTIPLE: ("test.integ.target.connection.multiple", "Configuration with both password and cookie authentication."),
   TARGETS.CONN_SOCKET: ("test.integ.target.connection.socket", "Configuration with a control socket."),
   TARGETS.CONN_SCOOKIE: ("test.integ.target.connection.scookie", "Configuration with a control socket and authentication cookie."),
+  TARGETS.CONN_PTRACE: ("test.integ.target.connection.ptrace", "Configuration with an open control port and 'DisableDebuggerAttachment 0'"),
   TARGETS.CONN_ALL: ("test.integ.target.connection.all", "Runs integration tests for all connection configurations."),
 }
 
@@ -256,6 +257,7 @@ if __name__ == '__main__':
         "multiple": test.runner.TorConnection.MULTIPLE,
         "socket": test.runner.TorConnection.SOCKET,
         "scookie": test.runner.TorConnection.SCOOKIE,
+        "ptrace": test.runner.TorConnection.PTRACE,
       }
       
       for type_key in conn_type_mappings:
@@ -267,6 +269,15 @@ if __name__ == '__main__':
       connection_types = [test.runner.TorConnection.OPEN]
     
     for connection_type in connection_types:
+      if connection_type == test.runner.TorConnection.PTRACE:
+        our_version = stem.version.get_system_tor_version(tor_cmd)
+        req_version = stem.version.Requirement.DISABLE_DEBUGGER_ATTACHMENT
+        
+        if our_version < req_version:
+          print term.format("Unable to run CONN_PTRACE target: DisableDebuggerAttachment was added in %s" % req_version, term.Color.RED, term.Attr.BOLD)
+          print
+          continue
+      
       try:
         integ_runner.start(tor_cmd, connection_type = connection_type)
         
diff --git a/stem/version.py b/stem/version.py
index 0b57301..e5b9997 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -143,5 +143,6 @@ class Version:
 Requirement = stem.util.enum.Enum(
   ("GETINFO_CONFIG_TEXT", Version("0.2.2.7-alpha")),
   ("CONTROL_SOCKET", Version("0.2.0.30")),
+  ("DISABLE_DEBUGGER_ATTACHMENT", Version("0.2.3.9")),
 )
 
diff --git a/test/integ/connection/protocolinfo.py b/test/integ/connection/protocolinfo.py
index 6f036c8..0214534 100644
--- a/test/integ/connection/protocolinfo.py
+++ b/test/integ/connection/protocolinfo.py
@@ -161,6 +161,8 @@ class TestProtocolInfo(unittest.TestCase):
       auth_methods = (stem.connection.AuthMethod.NONE,)
     elif connection_type == test.runner.TorConnection.SCOOKIE:
       auth_methods = (stem.connection.AuthMethod.COOKIE,)
+    elif connection_type == test.runner.TorConnection.PTRACE:
+      auth_methods = (stem.connection.AuthMethod.NONE,)
     else:
       self.fail("Unrecognized connection type: %s" % connection_type)
     
diff --git a/test/runner.py b/test/runner.py
index 36c41ce..4d163bf 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -50,7 +50,7 @@ DEFAULT_CONFIG = {
 # Methods for connecting to tor. General integration tests only run with the
 # DEFAULT_TOR_CONNECTION, but expanded integ tests will run with all of them.
 
-TorConnection = stem.util.enum.Enum("NONE", "OPEN", "PASSWORD", "COOKIE", "MULTIPLE", "SOCKET", "SCOOKIE")
+TorConnection = stem.util.enum.Enum("NONE", "OPEN", "PASSWORD", "COOKIE", "MULTIPLE", "SOCKET", "SCOOKIE", "PTRACE")
 DEFAULT_TOR_CONNECTION = TorConnection.OPEN
 
 STATUS_ATTR = (term.Color.BLUE, term.Attr.BOLD)
@@ -78,6 +78,7 @@ OPT_PORT = "ControlPort %i" % CONTROL_PORT
 OPT_COOKIE = "CookieAuthentication 1"
 OPT_PASSWORD = "HashedControlPassword 16:8C423A41EF4A542C6078985270AE28A4E04D056FB63F9F201505DB8E06"
 OPT_SOCKET = "ControlSocket %s" % CONTROL_SOCKET_PATH
+OPT_PTRACE = "DisableDebuggerAttachment 0"
 
 # mapping of TorConnection to their options
 
@@ -89,6 +90,7 @@ CONNECTION_OPTS = {
   TorConnection.MULTIPLE: [OPT_PORT, OPT_PASSWORD, OPT_COOKIE],
   TorConnection.SOCKET: [OPT_SOCKET],
   TorConnection.SCOOKIE: [OPT_SOCKET, OPT_COOKIE],
+  TorConnection.PTRACE: [OPT_PORT, OPT_PTRACE],
 }
 
 def get_runner():
diff --git a/test/testrc.sample b/test/testrc.sample
index f0b917d..d5a9326 100644
--- a/test/testrc.sample
+++ b/test/testrc.sample
@@ -23,8 +23,10 @@
 # test.integ.target.connection.open
 # test.integ.target.connection.password
 # test.integ.target.connection.cookie
-# test.integ.target.connection.muiltipe
+# test.integ.target.connection.multiple
 # test.integ.target.connection.socket
+# test.integ.target.connection.scookie
+# test.integ.target.connection.ptrace
 # test.integ.target.connection.all
 #   Runs the integration test suite for all of the given connection and
 #   authentication configurations. If the 'all' option is set then the other
@@ -41,5 +43,6 @@ test.integ.target.connection.cookie false
 test.integ.target.connection.muiltipe false
 test.integ.target.connection.socket false
 test.integ.target.connection.scookie false
+test.integ.target.connection.ptrace false
 test.integ.target.connection.all false
 



More information about the tor-commits mailing list