From 3276e3fef51ddfffa2fa29386acdbd78b46720fb Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Mon, 22 Aug 2016 15:59:49 -0700 Subject: [PATCH] Allow some diffs in h1 ps vs. h2 ps Presumably daemons, race conditions, or ephemeral processes can cause the ps output to vary slightly. We allow up to two differing lines to account for this. Fixes #651 --- mininet/test/test_walkthrough.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mininet/test/test_walkthrough.py b/mininet/test/test_walkthrough.py index 628ceb8..2e57c64 100755 --- a/mininet/test/test_walkthrough.py +++ b/mininet/test/test_walkthrough.py @@ -126,10 +126,13 @@ class testWalkthrough( unittest.TestCase ): p.sendline( "s1 ps -a | egrep -v 'ps|grep'" ) p.expect( self.prompt ) s1Output = p.before - # strip command from ps output - h1Output = h1Output.split( '\n', 1 )[ 1 ] - s1Output = s1Output.split( '\n', 1 )[ 1 ] - self.assertEqual( h1Output, s1Output, 'h1 and s1 "ps" output differs') + # strip command from ps output and compute diffs + h1Output = h1Output.split( '\n' )[ 1: ] + s1Output = s1Output.split( '\n' )[ 1: ] + diffs = set( h1Output ).difference( set( s1Output ) ) + # allow up to two diffs to account for daemons, etc. + self.assertTrue( len( diffs ) <= 2, + 'h1 and s1 "ps" output differ too much: %s' % diffs ) p.sendline( 'exit' ) p.wait()