cleaned up and commented test_scratchnet.py
This commit is contained in:
@@ -1,29 +1,27 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""TEST"""
|
"""
|
||||||
|
Test for scratchnet.py
|
||||||
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import pexpect
|
import pexpect
|
||||||
from mininet.log import setLogLevel
|
|
||||||
|
|
||||||
class testScratchNet( unittest.TestCase ):
|
class testScratchNet( unittest.TestCase ):
|
||||||
"Test ping with single switch topology (common code)."
|
|
||||||
|
|
||||||
results = [ "1 packets transmitted, 1 received, 0% packet loss", pexpect.EOF ]
|
opts = [ "1 packets transmitted, 1 received, 0% packet loss", pexpect.EOF ]
|
||||||
|
|
||||||
def pingTest( self, name ):
|
def pingTest( self, name ):
|
||||||
|
"Verify that no ping packets were dropped"
|
||||||
p = pexpect.spawn( 'python -m %s' % name )
|
p = pexpect.spawn( 'python -m %s' % name )
|
||||||
index = p.expect( self.results )
|
index = p.expect( self.opts )
|
||||||
self.assertEqual( index, 0 )
|
self.assertEqual( index, 0 )
|
||||||
|
|
||||||
|
|
||||||
def testPingKernel( self ):
|
def testPingKernel( self ):
|
||||||
self.pingTest( 'mininet.examples.scratchnet' )
|
self.pingTest( 'mininet.examples.scratchnet' )
|
||||||
|
|
||||||
|
|
||||||
def testPingUser( self ):
|
def testPingUser( self ):
|
||||||
self.pingTest( 'mininet.examples.scratchnetuser' )
|
self.pingTest( 'mininet.examples.scratchnetuser' )
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'warning' )
|
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user