File: test_simpleperf.py

package info (click to toggle)
mininet 2.3.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,588 kB
  • sloc: python: 11,181; ansic: 1,332; sh: 967; makefile: 87
file content (34 lines) | stat: -rwxr-xr-x 1,000 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python

"""
Test for simpleperf.py
"""

import unittest
from mininet.util import pexpect
import sys
from mininet.log import setLogLevel

from mininet.examples.simpleperf import SingleSwitchTopo

class testSimplePerf( unittest.TestCase ):

    @unittest.skipIf( '-quick' in sys.argv, 'long test' )
    def testE2E( self ):
        "Run the example and verify iperf results"
        # 10 Mb/s, plus or minus 20% tolerance
        BW = 10
        TOLERANCE = .2
        p = pexpect.spawn( 'python -m mininet.examples.simpleperf testmode' )
        # check iperf results
        p.expect( "Results: \['10M', '([\d\.]+) .bits/sec", timeout=480 )
        measuredBw = float( p.match.group( 1 ) )
        lowerBound = BW * ( 1 - TOLERANCE )
        upperBound = BW + ( 1 + TOLERANCE )
        self.assertGreaterEqual( measuredBw, lowerBound )
        self.assertLessEqual( measuredBw, upperBound )
        p.wait()

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