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.
This commit is contained in:
1 parent
b2e1907c3a
commit
e893fc9da4
1 file changed
+3
-3
@@ -25,13 +25,13 @@ class testCPU( unittest.TestCase ):
|
|||||||
@unittest.skipIf( '-quick' in sys.argv, 'long test' )
|
@unittest.skipIf( '-quick' in sys.argv, 'long test' )
|
||||||
def testCPU( self ):
|
def testCPU( self ):
|
||||||
"Verify that CPU utilization is monotonically decreasing for each scheduler"
|
"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 )
|
# matches each line from results( shown above )
|
||||||
opts = [ '([a-z]+)\t([\d\.]+)%\t([\d\.e\+]+)',
|
opts = [ '([a-z]+)\t([\d\.]+)%\t([\d\.e\+]+)',
|
||||||
pexpect.EOF ]
|
pexpect.EOF ]
|
||||||
scheds = []
|
scheds = []
|
||||||
while True:
|
while True:
|
||||||
index = p.expect( opts, timeout=600 )
|
index = p.expect( opts )
|
||||||
if index == 0:
|
if index == 0:
|
||||||
sched = p.match.group( 1 )
|
sched = p.match.group( 1 )
|
||||||
cpu = float( p.match.group( 2 ) )
|
cpu = float( p.match.group( 2 ) )
|
||||||
@@ -40,7 +40,7 @@ class testCPU( unittest.TestCase ):
|
|||||||
scheds.append( sched )
|
scheds.append( sched )
|
||||||
else:
|
else:
|
||||||
self.assertTrue( bw < previous_bw,
|
self.assertTrue( bw < previous_bw,
|
||||||
"%f should be less than %f\n" %
|
"%e should be less than %e\n" %
|
||||||
( bw, previous_bw ) )
|
( bw, previous_bw ) )
|
||||||
previous_bw = bw
|
previous_bw = bw
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user