Statistics
| Branch: | Tag: | Revision:

mininet / examples / test / test_emptynet.py @ 49fc496c

History | View | Annotate | Download (836 Bytes)

1
#!/usr/bin/env python
2

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

    
7
import unittest
8
import pexpect
9

    
10
class testEmptyNet( unittest.TestCase ):
11

    
12
    prompt = 'mininet>'
13

    
14
    def testEmptyNet( self ):
15
        "Run simple CLI tests: pingall (verify 0% drop) and iperf (sanity)"
16
        p = pexpect.spawn( 'python -m mininet.examples.emptynet' )
17
        p.expect( self.prompt )
18
        # pingall test
19
        p.sendline( 'pingall' )
20
        p.expect ( '(\d+)% dropped' )
21
        percent = int( p.match.group( 1 ) ) if p.match else -1
22
        self.assertEqual( percent, 0 ) 
23
        p.expect( self.prompt )
24
        # iperf test
25
        p.sendline( 'iperf' )
26
        p.expect( "Results: \['[\d.]+ .bits/sec', '[\d.]+ .bits/sec'\]" )
27
        p.expect( self.prompt )
28
        p.sendline( 'exit' )
29
        p.wait()
30

    
31
if __name__ == '__main__':
32
    unittest.main()