4 Test for linearbandwidth.py
8 from mininet.util import pexpect
11 class testLinearBandwidth( unittest.TestCase ):
13 @unittest.skipIf( '-quick' in sys.argv, 'long test' )
14 def testLinearBandwidth( self ):
15 "Verify that bandwidth is monotonically decreasing as # of hops increases"
16 p = pexpect.spawn( 'python -m mininet.examples.linearbandwidth' )
18 opts = [ '\*\*\* Linear network results',
19 '(\d+)\s+([\d\.]+) (.bits)',
22 index = p.expect( opts, timeout=600 )
26 n = int( p.match.group( 1 ) )
27 bw = float( p.match.group( 2 ) )
28 unit = p.match.group( 3 )
31 elif unit[ 0 ] == 'M':
33 elif unit[ 0 ] == 'G':
35 # check that we have a previous result to compare to
37 info = ( 'bw: %.2e bits/s across %d switches, '
38 'previous: %.2e bits/s across %d switches' %
39 ( bw, n, previous_bw, previous_n ) )
40 self.assertTrue( bw < previous_bw, info )
41 previous_bw, previous_n = bw, n
45 # verify that we received results from at least one switch
46 self.assertTrue( count > 0 )
48 if __name__ == '__main__':