From e893fc9da411164573d3825f3276665cbb6cec47 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Mon, 29 Aug 2016 23:57:17 -0700 Subject: [PATCH] Try specifying timeout in pexpect.spawn() + adjust error msg Unfortunately pexpect() seems to be timing out with a 30 second timeout rather than the 600 seconds we are passing in. How could this even be working normally? It is puzzling. We are going to try specifying the timeout in the spawn() call. Also if the test fails, we use %e format for readability. --- examples/test/test_cpu.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/test/test_cpu.py b/examples/test/test_cpu.py index c8b9e58..c7a6266 100755 --- a/examples/test/test_cpu.py +++ b/examples/test/test_cpu.py @@ -25,13 +25,13 @@ class testCPU( unittest.TestCase ): @unittest.skipIf( '-quick' in sys.argv, 'long test' ) def testCPU( self ): "Verify that CPU utilization is monotonically decreasing for each scheduler" - p = pexpect.spawn( 'python -m mininet.examples.cpu' ) + p = pexpect.spawn( 'python -m mininet.examples.cpu', timeout=300 ) # matches each line from results( shown above ) opts = [ '([a-z]+)\t([\d\.]+)%\t([\d\.e\+]+)', pexpect.EOF ] scheds = [] while True: - index = p.expect( opts, timeout=600 ) + index = p.expect( opts ) if index == 0: sched = p.match.group( 1 ) cpu = float( p.match.group( 2 ) ) @@ -40,7 +40,7 @@ class testCPU( unittest.TestCase ): scheds.append( sched ) else: self.assertTrue( bw < previous_bw, - "%f should be less than %f\n" % + "%e should be less than %e\n" % ( bw, previous_bw ) ) previous_bw = bw else: