test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Liu, Yong" <yong.liu@intel.com>
To: "Qiu, Michael" <michael.qiu@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution
Date: Wed, 14 Jan 2015 01:24:10 +0000	[thread overview]
Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10D4C260@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1421156540-25810-5-git-send-email-michael.qiu@intel.com>

Thanks for this idea. DTS can check return status as it default behavior. And when command return error, the output is still valuable.
My suggestion is that function send_expect should return both output message and command executed return value.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 4/6] 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>
> ---
>  framework/ssh_connection.py |  4 ++--
>  framework/ssh_pexpect.py    | 13 ++++++++++++-
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index 4306162..1ff79b9 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..2fad899 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -29,12 +29,23 @@ 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:
> +                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

  reply	other threads:[~2015-01-14  1:27 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 [this message]
2015-01-27  5:22   ` [dts] [PATCH v2] " Michael Qiu
2015-02-15  5:05     ` Liu, Yong
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=86228AFD5BCD8E4EBFD2B90117B5E81E10D4C260@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).