Skip to content

Commit ff538b4

Browse files
authored
Merge pull request #802 from TasmiyaNalatwad/login_fix
Patch helps to overcome login issue.
2 parents 6d3e7c8 + daf75b8 commit ff538b4

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

testcases/InstallUpstreamKernel.py

+32-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,18 @@ def is_url(path):
132132
"grub2-mkconfig --output=/boot/grub2/grub.cfg")
133133
log.debug("Rebooting after kernel install...")
134134
self.console_thread.console_terminate()
135+
self.prompt = self.cv_SYSTEM.util.build_prompt()
136+
self.console_thread.console_terminate()
135137
con.close()
136-
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
137-
self.cv_SYSTEM.goto_state(OpSystemState.OS)
138+
for i in range(5):
139+
raw_pty = self.wait_for(self.cv_SYSTEM.console.get_console, timeout=20)
140+
time.sleep(10)
141+
if raw_pty is not None:
142+
raw_pty.sendline("uname -r")
143+
break
144+
raw_pty.sendline("reboot")
145+
raw_pty.expect("login:", timeout=600)
146+
raw_pty.close()
138147
else:
139148
self.console_thread.console_terminate()
140149
cmdline = con.run_command("cat /proc/cmdline")[-1]
@@ -182,3 +191,24 @@ def is_url(path):
182191
finally:
183192
if self.console_thread.isAlive():
184193
self.console_thread.console_terminate()
194+
195+
def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
196+
args = args or []
197+
kwargs = kwargs or {}
198+
199+
start_time = time.monotonic()
200+
end_time = start_time + timeout
201+
202+
time.sleep(first)
203+
204+
while time.monotonic() < end_time:
205+
if text:
206+
LOG.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))
207+
208+
output = func(*args, **kwargs)
209+
if output:
210+
return output
211+
212+
time.sleep(step)
213+
214+
return None

0 commit comments

Comments
 (0)