8 from mininet.util import pexpect
10 class testMultiPoll( unittest.TestCase ):
12 def testMultiPoll( self ):
13 "Verify that we receive one ping per second per host"
14 p = pexpect.spawn( 'python -m mininet.examples.multipoll' )
15 opts = [ "\*\*\* (h\d) :" ,
16 "(h\d+): \d+ bytes from",
17 "Monitoring output for (\d+) seconds",
19 pings, seconds = {}, -1
21 index = p.expect( opts )
23 name = p.match.group( 1 )
26 name = p.match.group( 1 )
29 seconds = int( p.match.group( 1 ) )
32 self.assertTrue( len( pings ) > 0 )
33 # make sure we have received at least one ping per second
34 for count in pings.values():
35 self.assertTrue( count >= seconds,
36 '%d pings < %d seconds' % ( count, seconds ) )
38 if __name__ == '__main__':