From e3ab3fc23921642d0479cfc0394e8ad14977edcc Mon Sep 17 00:00:00 2001 From: cody burkard Date: Thu, 2 Oct 2014 09:53:26 -0700 Subject: [PATCH 1/2] fix a few small issues with walkthrough tests --- mininet/test/test_walkthrough.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mininet/test/test_walkthrough.py b/mininet/test/test_walkthrough.py index 2c2d6b0..6793252 100755 --- a/mininet/test/test_walkthrough.py +++ b/mininet/test/test_walkthrough.py @@ -9,6 +9,7 @@ TODO: missing xterm test import unittest import pexpect import os +import re from mininet.util import quietRun class testWalkthrough( unittest.TestCase ): @@ -25,7 +26,10 @@ class testWalkthrough( unittest.TestCase ): def testWireshark( self ): "Use tshark to test the of dissector" tshark = pexpect.spawn( 'tshark -i lo -R of' ) - tshark.expect( 'Capturing on lo' ) + if ubuntuVersion() == '12.04': + tshark.expect( 'Capturing on lo' ) + else: + tshark.expect( "Capturing on 'Loopback'" ) mn = pexpect.spawn( 'mn --test pingall' ) mn.expect( '0% dropped' ) tshark.expect( 'OFP 74 Hello' ) @@ -101,11 +105,11 @@ class testWalkthrough( unittest.TestCase ): break self.assertEqual( ifcount, 3, 'Missing interfaces on s1') # h1 ps - p.sendline( 'h1 ps -a' ) + p.sendline( "h1 ps -a | egrep -v 'ps|grep'" ) p.expect( self.prompt ) h1Output = p.before # s1 ps - p.sendline( 's1 ps -a' ) + p.sendline( "s1 ps -a | egrep -v 'ps|grep'" ) p.expect( self.prompt ) s1Output = p.before # strip command from ps output @@ -208,7 +212,7 @@ class testWalkthrough( unittest.TestCase ): p = pexpect.spawn( 'mn -v debug --test none' ) p.expect( pexpect.EOF ) lines = p.before.split( '\n' ) - self.assertTrue( len( lines ) > 100, "Debug output is too short" ) + self.assertTrue( len( lines ) > 70, "Debug output is too short" ) def testCustomTopo( self ): "Start Mininet using a custom topo, then run pingall" @@ -327,5 +331,11 @@ class testWalkthrough( unittest.TestCase ): pox.sendintr() pox.wait() +def ubuntuVersion(): + releaseStr = quietRun( 'cat /etc/lsb-release' ) + versionStr = re.findall( 'DISTRIB_RELEASE=\d+.\d+', releaseStr )[ 0 ] + version = versionStr.split( '=' )[ 1 ] + return version + if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() From 61c144b9f6c67d9f9e20cf4c6d5daa992bc092e9 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Tue, 7 Oct 2014 16:08:57 -0700 Subject: [PATCH 2/2] Minor fixes to wireshark test --- mininet/test/test_walkthrough.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mininet/test/test_walkthrough.py b/mininet/test/test_walkthrough.py index 6793252..802e14a 100755 --- a/mininet/test/test_walkthrough.py +++ b/mininet/test/test_walkthrough.py @@ -26,13 +26,10 @@ class testWalkthrough( unittest.TestCase ): def testWireshark( self ): "Use tshark to test the of dissector" tshark = pexpect.spawn( 'tshark -i lo -R of' ) - if ubuntuVersion() == '12.04': - tshark.expect( 'Capturing on lo' ) - else: - tshark.expect( "Capturing on 'Loopback'" ) + tshark.expect( [ 'Capturing on lo', "Capturing on 'Loopback'" ] ) mn = pexpect.spawn( 'mn --test pingall' ) mn.expect( '0% dropped' ) - tshark.expect( 'OFP 74 Hello' ) + tshark.expect( [ '74 Hello', '74 of_hello' ] ) tshark.sendintr() def testBasic( self ): @@ -68,7 +65,7 @@ class testWalkthrough( unittest.TestCase ): node = p.match.group( 1 ) actual.append( node ) p.expect( '\n' ) - self.assertEqual( actual.sort(), nodes.sort(), '"nodes" and "dump" differ' ) + self.assertEqual( actual.sort(), nodes.sort(), '"nodes" and "dump" differ' ) p.expect( self.prompt ) p.sendline( 'exit' ) p.wait() @@ -331,11 +328,6 @@ class testWalkthrough( unittest.TestCase ): pox.sendintr() pox.wait() -def ubuntuVersion(): - releaseStr = quietRun( 'cat /etc/lsb-release' ) - versionStr = re.findall( 'DISTRIB_RELEASE=\d+.\d+', releaseStr )[ 0 ] - version = versionStr.split( '=' )[ 1 ] - return version if __name__ == '__main__': unittest.main()