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

[tor-commits] [stem/master] Check for new event types, signals, or features



commit ddfeb6bd5892dc8e40e0c67bd5b4dd6751899c1e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Mar 22 17:36:35 2015 -0700

    Check for new event types, signals, or features
    
    Taking advantage of our new register_new_capability() util to note when tor
    supports new events, signals, or features that we don't.
    
    Interesting. It's already telling us about stuff...
    
      Your version of Tor has capabilities stem presently isn't taking advantage of.
      If you're running the latest version of stem then please file a ticket on:
    
        https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs
    
      New capabilities are:
    
        [Event] CONN_BW
        [Event] CELL_STATS
        [Event] TB_EMPTY
        [Event] CIRC_BW
        [Event] TRANSPORT_LAUNCHED
---
 run_tests.py                                  |    1 -
 test/integ/control/controller.py              |   26 ++++++++++++++++++++++++-
 test/integ/descriptor/extrainfo_descriptor.py |    2 +-
 test/integ/descriptor/microdescriptor.py      |    2 +-
 test/integ/descriptor/networkstatus.py        |    8 ++++----
 test/integ/descriptor/server_descriptor.py    |    2 +-
 6 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 4e8a8fd..824b16c 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -65,7 +65,6 @@ If you're running the latest version of stem then please file a ticket on:
   https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs
 
 New capabilities are:
-
 """
 
 PYFLAKES_TASK = Task(
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index fb08e0f..7ce3fdc 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -33,6 +33,7 @@ from test.runner import (
   require_controller,
   require_version,
   require_online,
+  only_run_once,
 )
 
 # Router status entry for a relay with a nickname other than 'Unnamed'. This is
@@ -50,6 +51,29 @@ def random_fingerprint():
 
 
 class TestController(unittest.TestCase):
+  @only_run_once
+  @require_controller
+  def test_missing_capabilities(self):
+    """
+    Check to see if tor supports any events, signals, or features that we
+    don't.
+    """
+
+    with test.runner.get_runner().get_tor_controller() as controller:
+      for event in controller.get_info('events/names').split():
+        if event not in EventType:
+          register_new_capability('Event', event)
+
+      for signal in controller.get_info('signal/names').split():
+        if signal not in Signal:
+          register_new_capability('Signal', signal)
+
+      # new features should simply be added to enable_feature()'s docs
+
+      for feature in controller.get_info('features/names').split():
+        if feature not in ('EXTENDED_EVENTS', 'VERBOSE_NAMES'):
+          register_new_capability('Feature', feature)
+
   def test_from_port(self):
     """
     Basic sanity check for the from_port constructor.
@@ -1087,7 +1111,7 @@ class TestController(unittest.TestCase):
         self.assertTrue(desc.nickname is not None)
 
         for line in desc.get_unrecognized_lines():
-          register_new_capability('Consensus line', line)
+          register_new_capability('Consensus Line', line)
 
         count += 1
         if count > 10:
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index 0c37afa..740ac59 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -30,7 +30,7 @@ class TestExtraInfoDescriptor(unittest.TestCase):
     with open(descriptor_path, 'rb') as descriptor_file:
       for desc in stem.descriptor.parse_file(descriptor_file, 'extra-info 1.0', validate = True):
         for line in desc.get_unrecognized_lines():
-          register_new_capability('Extra-info descriptor line', line)
+          register_new_capability('Extra-info Line', line)
 
         if desc.dir_v2_responses_unknown:
           self.fail('Unrecognized statuses on dirreq-v2-resp lines: %s' % desc.dir_v2_responses_unknown)
diff --git a/test/integ/descriptor/microdescriptor.py b/test/integ/descriptor/microdescriptor.py
index 26d04ef..fad7ef8 100644
--- a/test/integ/descriptor/microdescriptor.py
+++ b/test/integ/descriptor/microdescriptor.py
@@ -30,4 +30,4 @@ class TestMicrodescriptor(unittest.TestCase):
     with open(descriptor_path, 'rb') as descriptor_file:
       for desc in stem.descriptor.parse_file(descriptor_file, 'microdescriptor 1.0', validate = True):
         for line in desc.get_unrecognized_lines():
-          register_new_capability('Microdescriptor line', line)
+          register_new_capability('Microdescriptor Line', line)
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index 215188a..e02f178 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -42,11 +42,11 @@ class TestNetworkStatus(unittest.TestCase):
 
         for flag in router.flags:
           if flag not in stem.Flag and flag not in reported_flags:
-            register_new_capability('Relay flag', flag)
+            register_new_capability('Flag', flag)
             reported_flags.append(flag)
 
         for line in router.get_unrecognized_lines():
-          register_new_capability('Consensus line', line)
+          register_new_capability('Consensus Line', line)
 
     # Sanity test that there's at least a hundred relays. If that's not the
     # case then this probably isn't a real, complete tor consensus.
@@ -76,10 +76,10 @@ class TestNetworkStatus(unittest.TestCase):
 
         for flag in router.flags:
           if flag not in stem.Flag:
-            register_new_capability('Relay flag (microdescriptor consensus)', flag)
+            register_new_capability('Flag (microdescriptor)', flag)
             reported_flags.append(flag)
 
         for line in router.get_unrecognized_lines():
-          register_new_capability('Microdescriptor consensus line', line)
+          register_new_capability('Microdescriptor Consensus Line', line)
 
     self.assertTrue(count > 100)
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index 7afff60..86e4942 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -37,4 +37,4 @@ class TestServerDescriptor(unittest.TestCase):
         self.assertEqual(None, desc.socks_port)
 
         for line in desc.get_unrecognized_lines():
-          register_new_capability('Server descriptor line', line)
+          register_new_capability('Server Descriptor Line', line)



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