Statistics
| Branch: | Tag: | Revision:

mininet / examples / test / test_treeping64.py @ c5da46f1

History | View | Annotate | Download (844 Bytes)

1 a46fae06 Brian O'Connor
#!/usr/bin/env python
2
3 3577a698 Brian O'Connor
"""
4
Test for treeping64.py
5
"""
6 a46fae06 Brian O'Connor
7
import unittest
8
import pexpect
9 c5da46f1 Brian O'Connor
import sys
10 a46fae06 Brian O'Connor
11
class testTreePing64( unittest.TestCase ):
12
13
    prompt = 'mininet>'
14
15 c5da46f1 Brian O'Connor
    @unittest.skipIf( '-quick' in sys.argv, 'long test' )
16 a46fae06 Brian O'Connor
    def testTreePing64( self ):
17 3577a698 Brian O'Connor
        "Run the example and verify ping results"
18 a46fae06 Brian O'Connor
        p = pexpect.spawn( 'python -m mininet.examples.treeping64' )
19
        p.expect( 'Tree network ping results:', timeout=6000 )
20
        count = 0
21
        while True:
22
            index = p.expect( [ '(\d+)% packet loss', pexpect.EOF ] )
23
            if index == 0:
24
                percent = int( p.match.group( 1 ) ) if p.match else -1
25
                self.assertEqual( percent, 0 )
26
                count += 1
27
            else:
28
                break
29
        self.assertTrue( count > 0 )
30
31
if __name__ == '__main__':
32
    unittest.main()