Statistics
| Branch: | Tag: | Revision:

mininet / examples / test / test_simpleperf.py @ 5365831d

History | View | Annotate | Download (976 Bytes)

1
#!/usr/bin/env python
2

    
3
"""
4
Test for simpleperf.py
5
"""
6

    
7
import unittest
8
import pexpect
9
import sys
10
from mininet.log import setLogLevel
11

    
12
from mininet.examples.simpleperf import SingleSwitchTopo
13

    
14
class testSimplePerf( unittest.TestCase ):
15

    
16
    @unittest.skipIf( '-quick' in sys.argv, 'long test' )
17
    def testE2E( self ):
18
        "Run the example and verify iperf results"
19
        # 10 Mb/s, plus or minus 20% tolerance
20
        BW = 10
21
        TOLERANCE = .2 
22
        p = pexpect.spawn( 'python -m mininet.examples.simpleperf testmode' )
23
        # check iperf results
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 )
30
        p.wait()
31

    
32
if __name__ == '__main__':
33
    setLogLevel( 'warning' )
34
    unittest.main()