diff --git a/examples/test/test_controlnet.py b/examples/test/test_controlnet.py index ba22740..7e7ce9a 100755 --- a/examples/test/test_controlnet.py +++ b/examples/test/test_controlnet.py @@ -7,13 +7,15 @@ Test for controlnet.py import unittest from mininet.util import pexpect +from sys import stdout + class testControlNet( unittest.TestCase ): prompt = 'mininet>' def testPingall( self ): "Simple pingall test that verifies 0% packet drop in data network" - p = pexpect.spawn( 'python -m mininet.examples.controlnet' ) + p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout) p.expect( self.prompt ) p.sendline( 'pingall' ) p.expect ( '(\d+)% dropped' ) @@ -26,9 +28,9 @@ class testControlNet( unittest.TestCase ): def testFailover( self ): "Kill controllers and verify that switch, s1, fails over properly" count = 1 - p = pexpect.spawn( 'python -m mininet.examples.controlnet' ) + p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout ) p.expect( self.prompt ) - lp = pexpect.spawn( 'tail -f /tmp/s1-ofp.log' ) + lp = pexpect.spawn( 'tail -f /tmp/s1-ofp.log', logfile=stdout ) lp.expect( 'tcp:\d+\.\d+\.\d+\.(\d+):\d+: connected' ) ip = int( lp.match.group( 1 ) ) self.assertEqual( count, ip ) diff --git a/mininet/test/test_walkthrough.py b/mininet/test/test_walkthrough.py index b3b83fb..f418d2d 100755 --- a/mininet/test/test_walkthrough.py +++ b/mininet/test/test_walkthrough.py @@ -12,7 +12,7 @@ import re from mininet.util import quietRun, pexpect from mininet.clean import cleanup from distutils.version import StrictVersion -from time import sleep +from sys import stdout def tsharkVersion(): @@ -168,14 +168,16 @@ class testWalkthrough( unittest.TestCase ): httpserver = 'SimpleHTTPServer' else: httpserver = 'http.server' - p = pexpect.spawn( 'mn -w' ) + p = pexpect.spawn( 'mn -w', logfile=stdout ) + p.expect( self.prompt ) + p.sendline( 'h1 python -m %s 80 >& /dev/null &' % httpserver ) p.expect( self.prompt ) - p.sendline( 'h1 python -m %s 80 &' % httpserver ) # The walkthrough doesn't specify a delay here, and # we also don't read the output (also a possible problem), - # but for now let's wait a couple of seconds to make + # but for now let's wait a number of seconds to make # it less likely to fail due to the race condition. - sleep( 2 ) + p.sendline( 'px from mininet.util import waitListening;' + 'waitListening(h1, port=80, timeout=30)' ) p.expect( self.prompt ) p.sendline( ' h2 wget -O - h1' ) p.expect( '200 OK' )