diff --git a/examples/test/test_popen.py b/examples/test/test_popen.py index f9b8ab3edcabc219a66b67691b4ba027c05fe18e..c7f83f01ed31dab0af49ec32b1c1ab36dcaa00bd 100755 --- a/examples/test/test_popen.py +++ b/examples/test/test_popen.py @@ -1,21 +1,20 @@ #!/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()