Skip to content
Snippets Groups Projects
Commit 213b7c57 authored by Brian O'Connor's avatar Brian O'Connor
Browse files

cleaned up and commented test_popen.py

parent b9b1f2e7
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
"""TEST"""
"""
Test for popen.py and popenpoll.py
"""
import unittest
import pexpect
from collections import defaultdict
from mininet.log import setLogLevel
class testPopen( unittest.TestCase ):
"Test ping with single switch topology (common code)."
def pingTest( self, name ):
"Verify that there are no dropped packets for each host"
p = pexpect.spawn( 'python -m %s' % name )
opts = []
opts.append( "<(h\d+)>: PING " )
opts.append( "<(h\d+)>: (\d+) packets transmitted, (\d+) received" )
opts.append( pexpect.EOF )
opts = [ "<(h\d+)>: PING ",
"<(h\d+)>: (\d+) packets transmitted, (\d+) received",
pexpect.EOF ]
pings = {}
while True:
index = p.expect( opts )
......@@ -26,11 +25,13 @@ def pingTest( self, name ):
name = p.match.group(1)
transmitted = p.match.group(2)
received = p.match.group(3)
# verify no dropped packets
self.assertEqual( received, transmitted )
pings[ name ] += 1
else:
break
self.assertTrue( len(pings) > 0 )
# verify that each host has gotten results
for count in pings.values():
self.assertEqual( count, 1 )
......@@ -38,8 +39,7 @@ def testPopen( self ):
self.pingTest( 'mininet.examples.popen' )
def testPopenPoll( self ):
self.pingTest( 'mininet.examples.popenpoll')
self.pingTest( 'mininet.examples.popenpoll' )
if __name__ == '__main__':
setLogLevel( 'warning' )
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment