4 Run all mininet.examples tests
6 -quick : skip tests that take more than ~30 seconds
12 from mininet.util import ensureRoot
13 from mininet.clean import cleanup
15 class MininetTestResult( unittest.TextTestResult ):
16 def addFailure( self, test, err ):
17 super( MininetTestResult, self ).addFailure( test, err )
19 def addError( self,test, err ):
20 super( MininetTestResult, self ).addError( test, err )
23 class MininetTestRunner( unittest.TextTestRunner ):
24 def _makeResult( self ):
25 return MininetTestResult( self.stream, self.descriptions, self.verbosity )
27 def runTests( testDir, verbosity=1 ):
28 "discover and run all tests in testDir"
29 # ensure root and cleanup before starting tests
32 # discover all tests in testDir
33 testSuite = unittest.defaultTestLoader.discover( testDir )
35 success = MininetTestRunner( verbosity=verbosity ).run( testSuite ).wasSuccessful()
36 sys.exit( 0 if success else 1 )
38 if __name__ == '__main__':
39 # get the directory containing example tests
40 testDir = os.path.dirname( os.path.realpath( __file__ ) )
41 verbosity = 2 if '-v' in sys.argv else 1
42 runTests( testDir, verbosity )