From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 69D9D8D37 for ; Wed, 30 Sep 2015 07:37:36 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 29 Sep 2015 22:37:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,611,1437462000"; d="scan'208";a="815893825" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 29 Sep 2015 22:37:34 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t8U5bWhX026346; Wed, 30 Sep 2015 13:37:32 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t8U5bUkY028617; Wed, 30 Sep 2015 13:37:32 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t8U5bUxA028613; Wed, 30 Sep 2015 13:37:30 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 30 Sep 2015 13:37:29 +0800 Message-Id: <1443591449-28581-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] framework: send command without expect specific string return X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Sep 2015 05:37:37 -0000 From: Marvin Liu 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 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