adding first draft of tests for all examples, they need comments and clean up, some could be made more rebust

This commit is contained in:
Brian O'Connor
2013-09-11 14:45:46 -07:00
parent 5a646a0d20
commit a46fae0687
20 changed files with 914 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python
"""TEST"""
import unittest
import pexpect
from mininet.log import setLogLevel
class testMultiTest( unittest.TestCase ):
"Test ping with single switch topology (common code)."
prompt = 'mininet>'
def testMultiTest( self ):
p = pexpect.spawn( 'python -m mininet.examples.multitest' )
p.expect( '(\d+)% dropped' )
dropped = int( p.match.group(1) )
self.assertEqual( dropped, 0 )
ifCount = 0
while True:
index = p.expect( [ 'h\d-eth0', self.prompt ] )
if index == 0:
ifCount += 1
elif index == 1:
p.sendline( 'exit' )
break
p.wait()
self.assertEqual( ifCount, 4 )
if __name__ == '__main__':
setLogLevel( 'warning' )
unittest.main()