Revision e6e1260b
examples/test/test_multiping.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/env python |
2 | 2 |
|
3 |
"""TEST""" |
|
3 |
""" |
|
4 |
Test for multiping.py |
|
5 |
""" |
|
4 | 6 |
|
5 | 7 |
import unittest |
6 | 8 |
import pexpect |
7 | 9 |
from collections import defaultdict |
8 |
from mininet.log import setLogLevel |
|
9 | 10 |
|
10 | 11 |
class testMultiPing( unittest.TestCase ): |
11 |
"Test ping with single switch topology (common code)." |
|
12 | 12 |
|
13 | 13 |
def testMultiPing( self ): |
14 |
"""Verify that each target is pinged at least once, and |
|
15 |
that pings to 'real' targets are successful and unknown targets fail""" |
|
14 | 16 |
p = pexpect.spawn( 'python -m mininet.examples.multiping' ) |
15 |
opts = [] |
|
16 |
opts.append( "Host (h\d+) \(([\d.]+)\) will be pinging ips: ([\d. ]+)" ) |
|
17 |
opts.append( "(h\d+): ([\d.]+) -> ([\d.]+) \d packets transmitted, (\d) received" ) |
|
18 |
opts.append( pexpect.EOF ) |
|
17 |
opts = [ "Host (h\d+) \(([\d.]+)\) will be pinging ips: ([\d\. ]+)", |
|
18 |
"(h\d+): ([\d.]+) -> ([\d.]+) \d packets transmitted, (\d) received", |
|
19 |
pexpect.EOF ] |
|
19 | 20 |
pings = defaultdict( list ) |
20 | 21 |
while True: |
21 | 22 |
index = p.expect( opts ) |
... | ... | |
39 | 40 |
pass |
40 | 41 |
else: |
41 | 42 |
break |
42 |
self.assertTrue( len(pings) > 0 )
|
|
43 |
self.assertTrue( len( pings ) > 0 )
|
|
43 | 44 |
for t in pings.values(): |
44 | 45 |
self.assertEqual( len( t ), 0 ) |
45 | 46 |
|
46 | 47 |
if __name__ == '__main__': |
47 |
setLogLevel( 'warning' ) |
|
48 | 48 |
unittest.main() |
Also available in: Unified diff