Skip to content
Snippets Groups Projects
Commit e6fe480a authored by Brian O'Connor's avatar Brian O'Connor
Browse files

cleaned up and commented test_limit.py

parent 91a06063
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/usr/bin/env python
"""TEST""" """
Test for limit.py
"""
import unittest import unittest
import pexpect import pexpect
from mininet.log import setLogLevel
class testLimit( unittest.TestCase ): class testLimit( unittest.TestCase ):
"Test ping with single switch topology (common code)."
def testLimit( self ): def testLimit( self ):
"Verify that CPU limits are within a 1% tolerance of limit for each scheduler"
p = pexpect.spawn( 'python -m mininet.examples.limit' )
opts = [ '\*\*\* Testing network ([\d\.]+) Mbps', opts = [ '\*\*\* Testing network ([\d\.]+) Mbps',
'\*\*\* Results: \[([\d\., ]+)\]', '\*\*\* Results: \[([\d\., ]+)\]',
pexpect.EOF ] pexpect.EOF ]
p = pexpect.spawn( 'python -m mininet.examples.limit' )
count = 0 count = 0
bw = 0 bw = 0
tolerance = 1 tolerance = 1
...@@ -24,15 +25,14 @@ def testLimit( self ): ...@@ -24,15 +25,14 @@ def testLimit( self ):
count += 1 count += 1
elif index == 1: elif index == 1:
results = p.match.group( 1 ) results = p.match.group( 1 )
for x in results.split(','): for x in results.split( ',' ):
result = float( x ) result = float( x )
self.assertTrue( result < bw + tolerance ) self.assertTrue( result < bw + tolerance )
self.assertTrue( result > bw - tolerance) self.assertTrue( result > bw - tolerance )
else: else:
break break
self.assertTrue( count > 0 ) self.assertTrue( count > 0 )
if __name__ == '__main__': if __name__ == '__main__':
setLogLevel( 'warning' )
unittest.main() unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment