[tor-commits] [stem/master] Provide more information when connection test fails

atagar at torproject.org atagar at torproject.org
Thu Jul 27 16:48:45 UTC 2017


commit f3067bbcdf08f2064f70611f47a613354f1f8e9d
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Jul 27 09:49:40 2017 -0700

    Provide more information when connection test fails
    
    Nope, with that last issue sorted out still not enough to really know why
    sockstat is failing. Maybe alternate output format? Lets see.
---
 stem/util/connection.py       | 4 ++++
 test/integ/util/connection.py | 8 ++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/stem/util/connection.py b/stem/util/connection.py
index 0925461e..91608538 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -28,9 +28,13 @@ Connection and networking based utility functions.
   Method for resolving a process' connections.
 
   .. versionadded:: 1.1.0
+
   .. versionchanged:: 1.4.0
      Added **NETSTAT_WINDOWS**.
 
+  .. versionchanged:: 1.6.0
+     Added **BSD_FSTAT**.
+
   ====================  ===========
   Resolver              Description
   ====================  ===========
diff --git a/test/integ/util/connection.py b/test/integ/util/connection.py
index 563cfbeb..6792dafb 100644
--- a/test/integ/util/connection.py
+++ b/test/integ/util/connection.py
@@ -5,10 +5,11 @@ that we're running.
 
 import unittest
 
+import stem.util.system
 import test.require
 import test.runner
 
-from stem.util.connection import Resolver, get_connections, system_resolvers
+from stem.util.connection import RESOLVER_COMMAND, Resolver, get_connections, system_resolvers
 
 
 class TestConnection(unittest.TestCase):
@@ -30,7 +31,10 @@ class TestConnection(unittest.TestCase):
         if conn.local_address == '127.0.0.1' and conn.local_port == test.runner.CONTROL_PORT:
           return
 
-      self.fail('Unable to find localhost connection with %s:\n%s' % (resolver, '\n'.join(map(str, connections))))
+      resolver_command = RESOLVER_COMMAND[resolver].format(pid = runner.get_pid())
+      resolver_output = stem.util.system.call(resolver_command)
+
+      self.fail('Unable to find our controller connection with %s (%s). Connections found were...\n\n%s\n\nCommand output was...\n\n%s' % (resolver, , resolver_command, '\n'.join(map(str, connections)), resolver_output))
 
   def test_connections_by_proc(self):
     self.check_resolver(Resolver.PROC)



More information about the tor-commits mailing list