Skip to content

Commit

Permalink
Merge pull request #802 from TasmiyaNalatwad/login_fix
Browse files Browse the repository at this point in the history
Patch helps to overcome login issue.
  • Loading branch information
abdhaleegit authored May 24, 2024
2 parents 6d3e7c8 + daf75b8 commit ff538b4
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions testcases/InstallUpstreamKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,18 @@ def is_url(path):
"grub2-mkconfig --output=/boot/grub2/grub.cfg")
log.debug("Rebooting after kernel install...")
self.console_thread.console_terminate()
self.prompt = self.cv_SYSTEM.util.build_prompt()
self.console_thread.console_terminate()
con.close()
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
self.cv_SYSTEM.goto_state(OpSystemState.OS)
for i in range(5):
raw_pty = self.wait_for(self.cv_SYSTEM.console.get_console, timeout=20)
time.sleep(10)
if raw_pty is not None:
raw_pty.sendline("uname -r")
break
raw_pty.sendline("reboot")
raw_pty.expect("login:", timeout=600)
raw_pty.close()
else:
self.console_thread.console_terminate()
cmdline = con.run_command("cat /proc/cmdline")[-1]
Expand Down Expand Up @@ -182,3 +191,24 @@ def is_url(path):
finally:
if self.console_thread.isAlive():
self.console_thread.console_terminate()

def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
args = args or []
kwargs = kwargs or {}

start_time = time.monotonic()
end_time = start_time + timeout

time.sleep(first)

while time.monotonic() < end_time:
if text:
LOG.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))

output = func(*args, **kwargs)
if output:
return output

time.sleep(step)

return None

0 comments on commit ff538b4

Please sign in to comment.