[tor-commits] [tor/master] Add some failing unittests for the function length metric.

nickm at torproject.org nickm at torproject.org
Wed Mar 13 13:30:09 UTC 2019


commit a7684fcb57b3d28285b437f20d5eff6ce079cab5
Author: George Kadianakis <desnacked at riseup.net>
Date:   Wed Feb 27 15:14:29 2019 +0200

    Add some failing unittests for the function length metric.
---
 scripts/maint/practracker/practracker_tests.py | 46 ++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/scripts/maint/practracker/practracker_tests.py b/scripts/maint/practracker/practracker_tests.py
new file mode 100755
index 000000000..f3d225207
--- /dev/null
+++ b/scripts/maint/practracker/practracker_tests.py
@@ -0,0 +1,46 @@
+"""Some simple tests for practracker metrics"""
+
+import unittest
+
+import StringIO
+
+import metrics
+
+function_file = """static void
+fun(directory_request_t *req, const char *resource)
+{
+  time_t if_modified_since = 0;
+  uint8_t or_diff_from[DIGEST256_LEN];
+}
+
+static void
+fun(directory_request_t *req,
+      const char *resource)
+{
+  time_t if_modified_since = 0;
+  uint8_t or_diff_from[DIGEST256_LEN];
+}
+
+MOCK_IMPL(void,
+fun,(
+       uint8_t dir_purpose,
+       uint8_t router_purpose,
+       const char *resource,
+       int pds_flags,
+       download_want_authority_t want_authority))
+{
+  const routerstatus_t *rs = NULL;
+  const or_options_t *options = get_options();
+}
+"""
+
+class TestFunctionLength(unittest.TestCase):
+    def test_function_length(self):
+        funcs = StringIO.StringIO(function_file)
+        # All functions should have length 2
+        for name, lines in metrics.function_lines(funcs):
+            self.assertEqual(name, "fun")
+            self.assertEqual(lines, 2)
+
+if __name__ == '__main__':
+    unittest.main()





More information about the tor-commits mailing list