From 2283bb01e679478d325ffba4e6183a8110dcedbf Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 12 Jul 2018 07:16:27 +0000 Subject: [PATCH] Python3 compat and add timeout for connect --- examples/test/test_baresshd.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/test/test_baresshd.py b/examples/test/test_baresshd.py index 3d5df93..7888e74 100755 --- a/examples/test/test_baresshd.py +++ b/examples/test/test_baresshd.py @@ -5,8 +5,9 @@ Tests for baresshd.py """ import unittest -import pexpect +from mininet.util import pexpect from mininet.clean import cleanup, sh +from sys import stdout class testBareSSHD( unittest.TestCase ): @@ -14,7 +15,9 @@ class testBareSSHD( unittest.TestCase ): def connected( self ): "Log into ssh server, check banner, then exit" - p = pexpect.spawn( 'ssh 10.0.0.1 -o StrictHostKeyChecking=no -i /tmp/ssh/test_rsa exit' ) + p = pexpect.spawn( 'ssh 10.0.0.1 -o ConnectTimeout=1 ' + '-o StrictHostKeyChecking=no ' + '-i /tmp/ssh/test_rsa exit' ) while True: index = p.expect( self.opts ) if index == 0: @@ -22,6 +25,7 @@ class testBareSSHD( unittest.TestCase ): else: return False + def setUp( self ): # verify that sshd is not running self.assertFalse( self.connected() )