Skip to content

Commit 3276e3f

Browse files
committed
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 mininet#651
1 parent e40d9b8 commit 3276e3f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

mininet/test/test_walkthrough.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,13 @@ def testHostCommands( self ):
126126
p.sendline( "s1 ps -a | egrep -v 'ps|grep'" )
127127
p.expect( self.prompt )
128128
s1Output = p.before
129-
# strip command from ps output
130-
h1Output = h1Output.split( '\n', 1 )[ 1 ]
131-
s1Output = s1Output.split( '\n', 1 )[ 1 ]
132-
self.assertEqual( h1Output, s1Output, 'h1 and s1 "ps" output differs')
129+
# strip command from ps output and compute diffs
130+
h1Output = h1Output.split( '\n' )[ 1: ]
131+
s1Output = s1Output.split( '\n' )[ 1: ]
132+
diffs = set( h1Output ).difference( set( s1Output ) )
133+
# allow up to two diffs to account for daemons, etc.
134+
self.assertTrue( len( diffs ) <= 2,
135+
'h1 and s1 "ps" output differ too much: %s' % diffs )
133136
p.sendline( 'exit' )
134137
p.wait()
135138

0 commit comments

Comments
 (0)