mininet / mininet / test / runner.py @ ca5b0c56
History | View | Annotate | Download (873 Bytes)
1 |
#!/usr/bin/env python
|
---|---|
2 |
|
3 |
"""
|
4 |
Run all mininet core 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 |
from mininet.log import setLogLevel |
15 |
|
16 |
def runTests( testDir, verbosity=1 ): |
17 |
"discover and run all tests in testDir"
|
18 |
# ensure root and cleanup before starting tests
|
19 |
ensureRoot() |
20 |
cleanup() |
21 |
# discover all tests in testDir
|
22 |
testSuite = unittest.defaultTestLoader.discover( testDir ) |
23 |
# run tests
|
24 |
unittest.TextTestRunner( verbosity=verbosity ).run( testSuite ) |
25 |
|
26 |
if __name__ == '__main__': |
27 |
setLogLevel( 'warning' )
|
28 |
# get the directory containing example tests
|
29 |
testDir = os.path.dirname( os.path.realpath( __file__ ) ) |
30 |
verbosity = 2 if '-v' in sys.argv else 1 |
31 |
runTests( testDir, verbosity ) |