Statistics
| Branch: | Tag: | Revision:

mininet / examples / test / runner.py @ 10fdd01d

History | View | Annotate | Download (812 Bytes)

1
#!/usr/bin/env python
2

    
3
"""
4
Run all mininet.examples tests
5
 -v : verbose output
6
 -quick : skip tests that take more than ~30 seconds
7
"""
8

    
9
import unittest
10
import os
11
import sys
12
from mininet.util import ensureRoot
13
from mininet.clean import cleanup
14

    
15
def runTests( testDir, verbosity=1 ):
16
    "discover and run all tests in testDir"
17
    # ensure root and cleanup before starting tests
18
    ensureRoot()
19
    cleanup()
20
    # discover all tests in testDir
21
    testSuite = unittest.defaultTestLoader.discover( testDir )
22
    # run tests
23
    unittest.TextTestRunner( verbosity=verbosity ).run( testSuite )
24

    
25
if __name__ == '__main__':
26
    # get the directory containing example tests
27
    testDir = os.path.dirname( os.path.realpath( __file__ ) )
28
    verbosity = 2 if '-v' in sys.argv else 1
29
    runTests( testDir, verbosity )