Newer
Older
Brian O'Connor
committed
#!/usr/bin/env python
Brian O'Connor
committed
import unittest
import pexpect
Brian O'Connor
committed
class testLimit( unittest.TestCase ):
@unittest.skipIf( '-quick' in sys.argv, 'long test' )
Brian O'Connor
committed
def testLimit( self ):
"Verify that CPU limits are within a 2% tolerance of limit for each scheduler"
p = pexpect.spawn( 'python -m mininet.examples.limit' )
Brian O'Connor
committed
opts = [ '\*\*\* Testing network ([\d\.]+) Mbps',
'\*\*\* Results: \[([\d\., ]+)\]',
pexpect.EOF ]
count = 0
bw = 0
Brian O'Connor
committed
while True:
index = p.expect( opts )
if index == 0:
bw = float( p.match.group( 1 ) )
count += 1
elif index == 1:
results = p.match.group( 1 )
Brian O'Connor
committed
result = float( x )
self.assertTrue( result < bw + tolerance )
self.assertTrue( result > bw - tolerance )
Brian O'Connor
committed
else:
break
self.assertTrue( count > 0 )
if __name__ == '__main__':
unittest.main()