From: "Liu, Yong" <yong.liu@intel.com>
To: "Qiu, Michael" <michael.qiu@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH v2] framework/ssh: Add verify ability for command execution
Date: Sun, 15 Feb 2015 05:05:26 +0000 [thread overview]
Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10D7CCB2@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1422336153-13982-1-git-send-email-michael.qiu@intel.com>
Applied, thx.
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Michael Qiu
> Sent: Tuesday, January 27, 2015 1:23 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH v2] framework/ssh: Add verify ability for command
> execution
>
> ssh command exection never try to verify the failure or success,
>
> It should be very dangerous when execute command both in dut and
> tester machine without check the status, maybe unexpected error
> happens.
>
> This patch add this ability to verify the status.
>
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
> v2 --> v1
> add error log when return error code for that
> can be track in log.
>
> framework/ssh_connection.py | 4 ++--
> framework/ssh_pexpect.py | 14 +++++++++++++-
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index 4306162..d0b5e07 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -49,9 +49,9 @@ class SSHConnection(object):
> self.logger.config_execution(self.name)
> self.session.init_log(logger, self.name)
>
> - def send_expect(self, cmds, expected, timeout=15):
> + def send_expect(self, cmds, expected, timeout=15, verify=False):
> self.logger.info(cmds)
> - out = self.session.send_expect(cmds, expected, timeout)
> + out = self.session.send_expect(cmds, expected, timeout,
> verify=False)
> self.logger.debug(out)
> return out
>
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
> index 9c353e7..b7d3475 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -29,12 +29,24 @@ class SSHPexpect(object):
> self.logger.config_execution(name)
> self.logger.info("ssh %s@%s" % (self.username, self.host))
>
> - def send_expect(self, command, expected, timeout=15):
> + def send_expect_base(self, command, expected, timeout=15):
> self.session.PROMPT = expected
> self.__sendline(command)
> self.__prompt(command, timeout)
> return self.get_output_before()
>
> + def send_expect(self, command, expected, timeout=15, verify=False):
> + ret = self.send_expect_base(command, expected, timeout)
> + if verify:
> + ret_status = self.send_expect_base("echo $?", expected)
> + if not int(ret_status):
> + return ret
> + else:
> + self.logger.error("Command: %s failure!" % command)
> + return -1
> + else:
> + return ret
> +
> def __prompt(self, command, timeout):
> if not self.session.prompt(timeout):
> raise TimeoutException(command, self.get_output_all())
> --
> 1.9.3
next prev parent reply other threads:[~2015-02-15 5:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
2015-01-14 1:15 ` Liu, Yong
2015-01-25 1:07 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
2015-01-25 1:07 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
2015-01-14 1:18 ` Liu, Yong
2015-01-25 1:07 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
2015-01-14 1:24 ` Liu, Yong
2015-01-27 5:22 ` [dts] [PATCH v2] " Michael Qiu
2015-02-15 5:05 ` Liu, Yong [this message]
2015-01-13 13:42 ` [dts] [PATCH 5/6] framework: Fix ifname not found error Michael Qiu
2015-01-14 1:35 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
2015-01-14 1:35 ` Liu, Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86228AFD5BCD8E4EBFD2B90117B5E81E10D7CCB2@SHSMSX103.ccr.corp.intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
--cc=michael.qiu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).