4 Test for intfOptions.py
8 from mininet.util import pexpect
11 class testIntfOptions( unittest.TestCase ):
13 def testIntfOptions( self ):
14 "verify that intf.config is correctly limiting traffic"
15 p = pexpect.spawn( 'python -m mininet.examples.intfoptions ' )
16 tolerance = .2 # plus or minus 20%
17 opts = [ "Results: \['([\d\.]+) .bits/sec",
18 "Results: \['10M', '([\d\.]+) .bits/sec",
19 "h(\d+)->h(\d+): (\d)/(\d),"
20 "rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
23 index = p.expect( opts, timeout=600 )
26 bw = float( p.match.group( 1 ) )
27 self.assertGreaterEqual( bw, BW * ( 1 - tolerance ) )
28 self.assertLessEqual( bw, BW * ( 1 + tolerance ) )
31 measuredBw = float( p.match.group( 1 ) )
32 loss = ( measuredBw / BW ) * 100
33 self.assertGreaterEqual( loss, 50 * ( 1 - tolerance ) )
34 self.assertLessEqual( loss, 50 * ( 1 + tolerance ) )
36 delay = float( p.match.group( 6 ) )
37 self.assertGreaterEqual( delay, 15 * ( 1 - tolerance ) )
38 self.assertLessEqual( delay, 15 * ( 1 + tolerance ) )
43 if __name__ == '__main__':