Revision 0fac568a examples/test/test_intfoptions.py

View differences:

examples/test/test_intfoptions.py
13 13
    def testIntfOptions( self ):
14 14
        "verify that intf.config is correctly limiting traffic"
15 15
        p = pexpect.spawn( 'python -m mininet.examples.intfoptions ' )
16
        tolerance = .8
16
        tolerance = .2  # plus or minus 20%
17 17
        opts = [ "Results: \['([\d\.]+) .bits/sec",
18 18
                 "Results: \['10M', '([\d\.]+) .bits/sec",
19
                 "h(\d+)->h(\d+): (\d)/(\d), rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
19
                 "h(\d+)->h(\d+): (\d)/(\d),"
20
                 "rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
20 21
                 pexpect.EOF ]
21 22
        while True:
22 23
            index = p.expect( opts, timeout=600 )
23 24
            if index == 0:
25
                BW = 5
24 26
                bw = float( p.match.group( 1 ) )
25
                self.assertGreaterEqual( bw, float( 5 * tolerance ) )
26
                self.assertLessEqual( bw, float( 5 + 5 * ( 1 - tolerance ) ) )
27
                self.assertGreaterEqual( bw, BW * ( 1 - tolerance ) )
28
                self.assertLessEqual( bw, BW * ( 1 + tolerance ) )
27 29
            elif index == 1:
28 30
                BW = 10
29 31
                measuredBw = float( p.match.group( 1 ) )
30 32
                loss = ( measuredBw / BW ) * 100
31
                self.assertGreaterEqual( loss, 50 * tolerance )
32
                self.assertLessEqual( loss,  50 + 50 * ( 1 - tolerance ) )
33
                self.assertGreaterEqual( loss, 50 * ( 1 - tolerance ) )
34
                self.assertLessEqual( loss,  50 * ( 1 + tolerance ) )
33 35
            elif index == 2:
34 36
                delay = float( p.match.group( 6 ) )
35
                self.assertGreaterEqual( delay, 15 * tolerance )
36
                self.assertLessEqual( delay,  15 + 15 * ( 1 - tolerance ) )
37
                self.assertGreaterEqual( delay, 15 * ( 1 - tolerance ) )
38
                self.assertLessEqual( delay,  15 * ( 1 + tolerance ) )
37 39
            else:
38 40
                break
39 41

  

Also available in: Unified diff