test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] framework: send command without expect specific string return
@ 2015-09-30  5:37 Yong Liu
  0 siblings, 0 replies; only message in thread
From: Yong Liu @ 2015-09-30  5:37 UTC (permalink / raw)
  To: dts

From: Marvin Liu <yong.liu@intel.com>

Implement new function which only send command and not expect certain string.
Function send_command will return all output in session between timeout.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/crb.py b/framework/crb.py
index 5434531..fcbd7d9 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -69,6 +69,16 @@ class Crb(object):
 
         return self.session.send_expect(cmds, expected, timeout, verify)
 
+    def send_command(self, cmds, timeout=TIMEOUT, alt_session=False):
+        """
+        Send commands to crb and return string before timeout.
+        """
+
+        if alt_session:
+            return self.alt_session.session.send_command(cmds, timeout)
+
+        return self.session.send_command(cmds, timeout)
+
     def get_session_output(self, timeout=TIMEOUT):
         """
         Get session output message before timeout
diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index 63b8785..9f1aee1 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -61,6 +61,12 @@ class SSHConnection(object):
         self.logger.debug(out)
         return out
 
+    def send_command(self, cmds, timeout=1):
+        self.logger.info(cmds)
+        out = self.session.send_command(cmds)
+        self.logger.debug(out)
+        return out
+
     def get_session_before(self, timeout=15):
         out = self.session.get_session_before(timeout)
         self.logger.debug(out)
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 2951cf3..046692f 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -46,7 +46,7 @@ class SSHPexpect(object):
 
     def send_expect_base(self, command, expected, timeout):
         ignore_keyintr()
-        self.__flush() # clear buffer
+        self.clean_session()
         self.session.PROMPT = expected
         self.__sendline(command)
         self.__prompt(command, timeout)
@@ -68,6 +68,16 @@ class SSHPexpect(object):
         else:
             return ret
 
+    def send_command(self, command, timeout=1):
+        ignore_keyintr()
+        self.clean_session()
+        self.__sendline(command)
+        aware_keyintr()
+        return self.get_session_before(timeout)
+
+    def clean_session(self):
+        self.get_session_before(timeout=0.01)
+
     def get_session_before(self, timeout=15):
         """
         Get all output before timeout
-- 
1.9.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-09-30  5:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30  5:37 [dts] [PATCH] framework: send command without expect specific string return Yong Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).