Enable TESTS={'mytest':test} in --custom files

This commit is contained in:
Bob Lantz
2016-05-11 19:30:18 -07:00
parent 475bb4d911
commit e6b0430a87
+17 -12
View File
@@ -88,11 +88,12 @@ LINKS = { 'default': Link,
'ovs': OVSLink } 'ovs': OVSLink }
# optional tests to run # Names of tests that are Mininet() methods
TESTS = [ 'cli', 'build', 'pingall', 'pingpair', 'iperf', 'all', 'iperfudp', TESTNAMES = [ 'cli', 'build', 'pingall', 'pingpair', 'iperf', 'all', 'iperfudp',
'none' ] 'none' ]
ALTSPELLING = { 'pingall': 'pingAll', # Map to alternate functions and/or spellings of Mininet() methods
TESTS = { 'pingall': 'pingAll',
'pingpair': 'pingPair', 'pingpair': 'pingPair',
'iperfudp': 'iperfUdp', 'iperfudp': 'iperfUdp',
'iperfUDP': 'iperfUdp' } 'iperfUDP': 'iperfUdp' }
@@ -158,7 +159,8 @@ class MininetRunner( object ):
def setCustom( self, name, value ): def setCustom( self, name, value ):
"Set custom parameters for MininetRunner." "Set custom parameters for MininetRunner."
if name in ( 'topos', 'switches', 'hosts', 'controllers', 'links' ): if name in ( 'topos', 'switches', 'hosts', 'controllers', 'links'
'testnames', 'tests' ):
# Update dictionaries # Update dictionaries
param = name.upper() param = name.upper()
globals()[ param ].update( value ) globals()[ param ].update( value )
@@ -208,10 +210,9 @@ class MininetRunner( object ):
type='string', type='string',
help='read custom classes or params from .py file(s)' help='read custom classes or params from .py file(s)'
) )
testList = TESTNAMES + TESTS.keys()
opts.add_option( '--test', type='choice', choices=TESTS, opts.add_option( '--test', default=[], action='append',
default=TESTS[ 0 ], dest='tests', help='|'.join( testList ) )
help='|'.join( TESTS ) )
opts.add_option( '--xterms', '-x', action='store_true', opts.add_option( '--xterms', '-x', action='store_true',
default=False, help='spawn xterms for each node' ) default=False, help='spawn xterms for each node' )
opts.add_option( '--ipbase', '-i', type='string', default='10.0.0.0/8', opts.add_option( '--ipbase', '-i', type='string', default='10.0.0.0/8',
@@ -358,12 +359,16 @@ class MininetRunner( object ):
if self.options.pre: if self.options.pre:
cli( mn, script=self.options.pre ) cli( mn, script=self.options.pre )
test = self.options.test
test = ALTSPELLING.get( test, test )
mn.start() mn.start()
if test == 'none': if not self.options.tests:
cli( mn )
for test in self.options.tests:
test = TESTS.get( test, test )
if callable( test ): # user added TESTMAP={'mytest': testfn}
test( mn )
elif test == 'none':
pass pass
elif test == 'all': elif test == 'all':
mn.waitConnected() mn.waitConnected()