[V1] framework/ssh_pexpect: add output buffered information when execute command exception

Message ID 1637042878-239212-1-git-send-email-junx.dong@intel.com (mailing list archive)
State Superseded
Headers
Series [V1] framework/ssh_pexpect: add output buffered information when execute command exception |

Checks

Context Check Description
ci/Intel-dts-suite-test fail Testing issues

Commit Message

Jun Dong Nov. 16, 2021, 6:07 a.m. UTC
  From: "Dong, JunX" <junx.dong@intel.com>

Signed-off-by: Dong, JunX <junx.dong@intel.com>
---
 framework/ssh_pexpect.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Patch

diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 783f989..a9331d5 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -87,7 +87,7 @@  class SSHPexpect:
         return before
 
     def send_expect(self, command, expected, timeout=15, verify=False):
-
+        buffered_info = self.get_session_before(timeout=0)
         try:
             ret = self.send_expect_base(command, expected, timeout)
             if verify:
@@ -96,11 +96,13 @@  class SSHPexpect:
                     return ret
                 else:
                     self.logger.error("Command: %s failure!" % command)
+                    self.logger.error('Buffered info: ' + buffered_info)
                     self.logger.error(ret)
                     return int(ret_status)
             else:
                 return ret
         except Exception as e:
+            self.logger.error('Buffered info: ' + buffered_info)
             print(RED("Exception happened in [%s] and output is [%s]" % (command, self.get_output_before())))
             raise(e)