diff mbox series

[03/14] oeqa ssh.py: clarify timeout API and add more debug prints to run()

Message ID 20230120144450.2913935-4-mikko.rapeli@linaro.org
State New
Headers show
Series oeqa runtime tests when qemu hangs | expand

Commit Message

Mikko Rapeli Jan. 20, 2023, 2:44 p.m. UTC
Clarify timeout handling. Timeout calculation is from start of command
OR last output from ssh command. When the ssh command output is
captured, that resets the timeout timer. Timeout is effetively
an "inactive timeout".

Print process output to a new line to keep the output more
readable.

Then log the calls to dumper functions which also seem to be deadlocking
for ever when a qemu machine hangs.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 meta/lib/oeqa/core/target/ssh.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
index 11f4ec6de0..2aaa15ec0e 100644
--- a/meta/lib/oeqa/core/target/ssh.py
+++ b/meta/lib/oeqa/core/target/ssh.py
@@ -65,7 +65,7 @@  class OESSHTarget(OETarget):
         """
             Runs command in target using SSHProcess.
         """
-        self.logger.debug("[Running]$ %s" % " ".join(command))
+        self.logger.debug("[Running]$ '%s', timeout=%s, ignore_status=%s" % (" ".join(command), timeout, ignore_status))
 
         starttime = time.time()
         status, output = SSHCall(command, self.logger, timeout)
@@ -83,9 +83,10 @@  class OESSHTarget(OETarget):
             Runs command in target.
 
             command:    Command to run on target.
-            timeout:    <value>:    Kill command after <val> seconds.
-                        None:       Kill command default value seconds.
-                        0:          No timeout, runs until return.
+            timeout:    <value>:    Kill command after <val> seconds when there is no output.
+                        None:       Kill command with default value seconds when there is no output.
+                        0:          No activity timeout, runs until return. Can still fail with timeout
+                                    if ssh client returns failures or TCP socket times out.
         """
         targetCmd = 'export PATH=/usr/sbin:/sbin:/usr/bin:/bin; %s' % command
         sshCmd = self.ssh + [self.ip, targetCmd]
@@ -98,15 +99,19 @@  class OESSHTarget(OETarget):
             processTimeout = self.timeout
 
         status, output = self._run(sshCmd, processTimeout, ignore_status)
-        self.logger.debug('Command: %s\nStatus: %d Output:  %s\n' % (command, status, output))
+        # ssh reports errors with return value 255 but also commands can return that value
         if (status == 255) and (('No route to host') in output):
             if self.monitor_dumper:
+                self.logger.debug('Command failed, capturing QMP data: dump_monitor()')
                 self.monitor_dumper.dump_monitor()
         if status == 255:
             if self.target_dumper:
+                self.logger.debug('Command failed, capturing data from serial console: dump_target()')
                 self.target_dumper.dump_target()
             if self.monitor_dumper:
+                self.logger.debug('Command failed, capturing QMP data: dump_monitor()')
                 self.monitor_dumper.dump_monitor()
+        self.logger.debug('returning from run()')
         return (status, output)
 
     def copyTo(self, localSrc, remoteDst):