8 from mininet.util import pexpect
10 from mininet.log import setLogLevel
12 from mininet.examples.simpleperf import SingleSwitchTopo
14 class testSimplePerf( unittest.TestCase ):
16 @unittest.skipIf( '-quick' in sys.argv, 'long test' )
18 "Run the example and verify iperf results"
19 # 10 Mb/s, plus or minus 20% tolerance
22 p = pexpect.spawn( 'python -m mininet.examples.simpleperf testmode' )
24 p.expect( "Results: \['10M', '([\d\.]+) .bits/sec", timeout=480 )
25 measuredBw = float( p.match.group( 1 ) )
26 lowerBound = BW * ( 1 - TOLERANCE )
27 upperBound = BW + ( 1 + TOLERANCE )
28 self.assertGreaterEqual( measuredBw, lowerBound )
29 self.assertLessEqual( measuredBw, upperBound )
32 if __name__ == '__main__':
33 setLogLevel( 'warning' )