1010
1111from jumpstarter .client .adapters import PexpectAdapter
1212from jumpstarter .testing .pytest import JumpstarterTest
13- from jumpstarter .testing .utils import wait_and_login
1413
1514log = logging .getLogger (__file__ )
1615
@@ -44,7 +43,7 @@ def shell(self, client, console):
4443 client .dutlink .power .off ()
4544 time .sleep (1 )
4645 client .dutlink .power .on ()
47- yield wait_and_login (console , "root" , "changeme" , "@rpitest:~#" )
46+ yield _wait_and_login (console , "root" , "changeme" , "@rpitest:~#" )
4847 _power_off (client , console )
4948
5049 def test_setup_device (self , client , console ):
@@ -61,7 +60,7 @@ def test_setup_device(self, client, console):
6160 client .dutlink .power .on ()
6261 console .logfile_read = sys .stdout .buffer
6362 # first boot on raspbian will take some time, we wait for the login
64- wait_and_login (console , "root" , "changeme" , "@rpitest:~#" )
63+ _wait_and_login (console , "root" , "changeme" , "@rpitest:~#" )
6564 # then power off the device
6665 _power_off (client , console )
6766
@@ -121,3 +120,13 @@ def _power_off(client, console):
121120 log .error ("Timeout waiting for power down, continuing with hard power off" )
122121 finally :
123122 client .dutlink .power .off ()
123+
124+ def _wait_and_login (pexpect_console , username , password , prompt , timeout = 240 ):
125+ log .info ("Waiting for login prompt" )
126+ pexpect_console .expect ("login:" , timeout = timeout )
127+ pexpect_console .sendline (username )
128+ pexpect_console .expect ("Password:" )
129+ pexpect_console .sendline (password )
130+ pexpect_console .expect (prompt , timeout = 60 )
131+ log .info ("Logged in" )
132+ return pexpect_console
0 commit comments