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

[tor-commits] [stem/master] Skip tests that rely on netstat and lsof on Gentoo



commit ea83fb6bbd2c9849d9c6981c697965043b525aaf
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Dec 7 12:48:49 2014 -0800

    Skip tests that rely on netstat and lsof on Gentoo
    
    Some netstat and lsof commands are broken on Gentoo, probably due to restricted
    proc permissions. Skipping the tests on that platform...
    
      ======================================================================
      ERROR: test_pid_by_port_lsof
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/test/integ/util/system.py", line 332, in test_pid_by_port_lsof
          self.assertEquals(tor_pid, stem.util.system.pid_by_port(test.runner.CONTROL_PORT))
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/stem/util/system.py", line 536, in pid_by_port
          results = call(GET_PID_BY_PORT_LSOF, None)
        File "/usr/lib64/python2.7/site-packages/mock.py", line 964, in __call__
          return _mock_self._mock_call(*args, **kwargs)
        File "/usr/lib64/python2.7/site-packages/mock.py", line 1027, in _mock_call
          ret_val = effect(*args, **kwargs)
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/test/integ/util/system.py", line 37, in _filter_system_call
          return real_call_function(command)
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/stem/util/system.py", line 924, in call
          raise exc
      OSError: lsof -wnP -iTCP -sTCP:LISTEN returned exit status 1
    
      ======================================================================
      ERROR: test_pid_by_port_netstat
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/test/integ/util/system.py", line 274, in test_pid_by_port_netstat
          self.assertEquals(tor_pid, stem.util.system.pid_by_port(test.runner.CONTROL_PORT))
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/stem/util/system.py", line 471, in pid_by_port
          results = call(GET_PID_BY_PORT_NETSTAT, None)
        File "/usr/lib64/python2.7/site-packages/mock.py", line 964, in __call__
          return _mock_self._mock_call(*args, **kwargs)
        File "/usr/lib64/python2.7/site-packages/mock.py", line 1027, in _mock_call
          ret_val = effect(*args, **kwargs)
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/test/integ/util/system.py", line 37, in _filter_system_call
          return real_call_function(command)
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/stem/util/system.py", line 924, in call
          raise exc
      OSError: netstat -npltu returned exit status 255
    
      ======================================================================
      FAIL: test_pid_by_port
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/test/integ/util/system.py", line 244, in test_pid_by_port
          self.assertEquals(tor_pid, stem.util.system.pid_by_port(tor_port))
      AssertionError: 25297 != None
    
      ----------------------------------------------------------------------
---
 stem/util/system.py       |   11 +++++++++++
 test/integ/util/system.py |    7 +++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index da02843..5eedfda 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -16,6 +16,7 @@ best-effort, providing **None** if the lookup fails.
 
   is_windows - checks if we're running on windows
   is_mac - checks if we're running on a mac
+  is_gentoo - checks if we're running on gentoo
   is_bsd - checks if we're running on the bsd family of operating systems
 
   is_available - determines if a command is available on this system
@@ -141,6 +142,16 @@ def is_mac():
   return platform.system() == 'Darwin'
 
 
+def is_gentoo():
+  """
+  Checks if we're running on Gentoo.
+
+  :returns: **bool** to indicate if we're on Gentoo
+  """
+
+  return os.path.exists('/etc/gentoo-release')
+
+
 def is_bsd():
   """
   Checks if we are within the BSD family of operating systems. This presently
diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index c075a27..e5cb199 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -228,7 +228,7 @@ class TestSystem(unittest.TestCase):
     elif not _has_port():
       test.runner.skip(self, '(test instance has no port)')
       return
-    elif stem.util.system.is_mac():
+    elif stem.util.system.is_mac() or stem.util.system.is_gentoo():
       test.runner.skip(self, '(resolvers unavailable)')
       return
     elif not runner.is_ptraceable():
@@ -259,6 +259,9 @@ class TestSystem(unittest.TestCase):
     elif stem.util.system.is_bsd() or stem.util.system.is_windows():
       test.runner.skip(self, '(linux only)')
       return
+    elif stem.util.system.is_gentoo():
+      test.runner.skip(self, '(unavailable on gentoo)')
+      return
     elif not runner.is_ptraceable():
       test.runner.skip(self, '(DisableDebuggerAttachment is set)')
       return
@@ -314,7 +317,7 @@ class TestSystem(unittest.TestCase):
     elif not stem.util.system.is_available('lsof'):
       test.runner.skip(self, '(lsof unavailable)')
       return
-    elif stem.util.system.is_mac():
+    elif stem.util.system.is_mac() or stem.util.system.is_gentoo():
       test.runner.skip(self, '(resolvers unavailable)')
       return
     elif not runner.is_ptraceable():

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