[tor-commits] [arm/master] Dropping the test module

atagar at torproject.org atagar at torproject.org
Mon Jan 14 05:28:43 UTC 2013


commit a600654c018ed4655cc78663f789353cd4944f39
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jan 13 20:00:39 2013 -0800

    Dropping the test module
    
    'Test' had always been the wrong word for this module. It was a demo module,
    for quickly running various utilities. As those utilities move to stem this
    module has both fallen out of date and become kinda pointless. Stem's
    unit/integ tests are better. :)
---
 src/__init__.py |    2 +-
 src/test.py     |  144 -------------------------------------------------------
 2 files changed, 1 insertions(+), 145 deletions(-)

diff --git a/src/__init__.py b/src/__init__.py
index ee848ac..461b0ce 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -2,5 +2,5 @@
 Scripts involved in validating user input, system state, and initializing arm.
 """
 
-__all__ = ["starter", "prereq", "version", "test"]
+__all__ = ["starter", "prereq", "version"]
 
diff --git a/src/test.py b/src/test.py
deleted file mode 100644
index 10eddb0..0000000
--- a/src/test.py
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Handler for arm tests and demos.
-"""
-
-import time
-from util import connections, torTools, uiTools
-
-MENU = """Arm Test Options:
-  1. Resolver Performance Test
-  2. Resolver Dump
-  3. Glyph Demo
-  4. Exit Policy Check
-  q. Quit
-
-Selection: """
-
-def printDivider():
-  print("\n" + "-" * 40 + "\n")
-
-conn = None
-while True:
-  userInput = raw_input(MENU)
-  
-  # initiate the stem connection if the test needs it
-  if userInput in ("1", "2", "4") and not conn:
-    conn = torTools.getConn()
-    conn.init()
-    
-    # prefetch pid so extra system calls don't effect the timing of tests
-    conn.getMyPid()
-  
-  if userInput == "q":
-    break # quit test script
-  elif userInput == "1":
-    systemResolvers = connections.getSystemResolvers()
-    printDivider()
-    
-    allConnectionResults = []
-    for resolver in systemResolvers:
-      startTime = time.time()
-      connectionResults = connections.getConnections(resolver, "tor", conn.getMyPid())
-      connectionResults.sort()
-      allConnectionResults.append(connectionResults)
-      
-      resolverLabel = "%-10s" % resolver
-      countLabel = "%4i results" % len(connectionResults)
-      timeLabel = "%0.4f seconds" % (time.time() - startTime)
-      print "%s %s     %s" % (resolverLabel, countLabel, timeLabel)
-    
-    allResolversMatch = True
-    firstResult = allConnectionResults.pop()
-    while allConnectionResults:
-      if allConnectionResults.pop() != firstResult:
-        allResolversMatch = False
-        break
-    
-    if allResolversMatch:
-      print("\nThe results of all the connection resolvers match")
-    else:
-      print("\nWarning: Connection resolver results differ")
-    
-    printDivider()
-  elif userInput == "2":
-    # use the given resolver to fetch tor's connections
-    while True:
-      # provide the selection options
-      printDivider()
-      print("Select a resolver:")
-      availableResolvers = list(connections.Resolver)
-      for i in range(len(availableResolvers)):
-        print("  %i. %s" % (i, availableResolvers[i]))
-      print("  q. Go back to the main menu")
-      
-      userSelection = raw_input("\nSelection: ")
-      if userSelection == "q":
-        printDivider()
-        break
-      
-      if userSelection.isdigit() and int(userSelection) in range(0, 7):
-        try:
-          resolver = list(connections.Resolver)[int(userSelection)]
-          startTime = time.time()
-          
-          print(connections.getResolverCommand(resolver, "tor", conn.getMyPid()))
-          connectionResults = connections.getConnections(resolver, "tor", conn.getMyPid())
-          connectionResults.sort()
-          
-          # prints results
-          printDivider()
-          for lIp, lPort, fIp, fPort in connectionResults:
-            print("  %s:%s -> %s:%s" % (lIp, lPort, fIp, fPort))
-          
-          print("\n  Runtime: %0.4f seconds" % (time.time() - startTime))
-        except (IOError, IndexError), exc:
-          print exc
-      else:
-        print("'%s' isn't a valid selection\n" % userSelection)
-  elif userInput == "3":
-    uiTools.demoGlyphs()
-    
-    # Switching to a curses context and back repeatedly seems to screw up the
-    # terminal. Just to be safe this ends the process after the demo.
-    break
-  elif userInput == "4":
-    # display the current exit policy and query if destinations are allowed by it
-    exitPolicy = conn.getExitPolicy()
-    print("Exit Policy: %s" % exitPolicy)
-    printDivider()
-    
-    while True:
-      # provide the selection options
-      userSelection = raw_input("\nCheck if destination is allowed (q to go back): ")
-      userSelection = userSelection.replace(" ", "").strip() # removes all whitespace
-      
-      isValidQuery, isExitAllowed = True, False
-      if userSelection == "q":
-        printDivider()
-        break
-      elif connections.isValidIpAddress(userSelection):
-        # just an ip address (use port 80)
-        isExitAllowed = exitPolicy.check(userSelection, 80)
-      elif userSelection.isdigit():
-        # just a port (use a common ip like 4.2.2.2)
-        isExitAllowed = exitPolicy.check("4.2.2.2", userSelection)
-      elif ":" in userSelection:
-        # ip/port combination
-        ipAddr, port = userSelection.split(":", 1)
-        
-        if connections.isValidIpAddress(ipAddr) and port.isdigit():
-          isExitAllowed = exitPolicy.check(ipAddr, port)
-        else: isValidQuery = False
-      else: isValidQuery = False # invalid input
-      
-      if isValidQuery:
-        resultStr = "is" if isExitAllowed else "is *not*"
-        print("Exiting %s allowed to that destination" % resultStr)
-      else:
-        print("'%s' isn't a valid destination (should be an ip, port, or ip:port)\n" % userSelection)
-    
-  else:
-    print("'%s' isn't a valid selection\n" % userInput)
-





More information about the tor-commits mailing list