test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Tu, LijuanX A" <lijuanx.a.tu@intel.com>
To: "Liu, Yong" <yong.liu@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH] framework: support create addtional sessions on crb
Date: Wed, 2 Dec 2015 06:13:06 +0000	[thread overview]
Message-ID: <38D041F150D4184C8114E499040E62340723E7BE@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1448959904-23907-1-git-send-email-yong.liu@intel.com>

Hi yong,
	
	There are no logs when sending cmds. I hope see logs as master session.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yong Liu
> Sent: Tuesday, December 01, 2015 4:52 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH] framework: support create addtional sessions on
> crb
> 
> Add session create/destroy functions in crb module.
> Suite can create addtional session in dut by this function.
> When session useless, suite should close the session definitely.
> Below is sample code addtional session:
> 
>     session = self.dut.new_session()
>     session.send_expect("ls -al", "# ")
>     self.dut.close_session(session=session)
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> 
> diff --git a/framework/crb.py b/framework/crb.py index 3c158ec..68fe399
> 100644
> --- a/framework/crb.py
> +++ b/framework/crb.py
> @@ -56,6 +56,7 @@ class Crb(object):
>          self.skip_setup = False
>          self.serializer = serializer
>          self.ports_info = None
> +        self.sessions = []
> 
>          self.logger = getLogger(name)
>          self.session = SSHConnection(self.get_ip_address(), name, @@ -
> 81,6 +82,24 @@ class Crb(object):
> 
>          return self.session.send_expect(cmds, expected, timeout,
> verify)
> 
> +    def create_session(self, name=""):
> +        """
> +        Create new session for addtional useage. This session will not
> enable log.
> +        """
> +        session = SSHConnection(self.get_ip_address(), name,
> +                                     self.get_password())
> +        self.sessions.append(session)
> +        return session.session
> +
> +    def destroy_session(self, session=None):
> +        """
> +        Destroy addtional session.
> +        """
> +        for save_session in self.sessions:
> +            if save_session.session == session:
> +                save_session.close()
> +            self.sessions.remove(save_session)
> +
>      def send_command(self, cmds, timeout=TIMEOUT, alt_session=False):
>          """
>          Send commands to crb and return string before timeout.
> diff --git a/framework/dut.py b/framework/dut.py index c75f325..2cea7fb
> 100644
> --- a/framework/dut.py
> +++ b/framework/dut.py
> @@ -41,6 +41,7 @@ from crb import Crb
>  from net_device import NetDevice
>  from virt_resource import VirtResource
>  from utils import RED
> +from uuid import uuid4
> 
> 
>  class Dut(Crb):
> @@ -85,6 +86,21 @@ class Dut(Crb):
>              self.host_session.init_log(self.logger)
>              self.host_init_flag = True
> 
> +    def new_session(self):
> +        """
> +        Create new session for dut instance. Session name will be
> unique.
> +        """
> +        session_name = str(uuid4())
> +        session = self.create_session(name=session_name)
> +        session.send_expect("cd %s" % self.base_dir, "# ")
> +        return session
> +
> +    def close_session(self, session):
> +        """
> +        close new session in dut instance
> +        """
> +        self.destroy_session(session)
> +
>      def change_config_option(self, target, parameter, value):
>          """
>          This function change option in the config file
> --
> 1.9.3

  reply	other threads:[~2015-12-02  6:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-01  8:51 Yong Liu
2015-12-02  6:13 ` Tu, LijuanX A [this message]
2015-12-02  7:41 ` [dts] [PATCH v2] " Yong Liu

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=38D041F150D4184C8114E499040E62340723E7BE@shsmsx102.ccr.corp.intel.com \
    --to=lijuanx.a.tu@intel.com \
    --cc=dts@dpdk.org \
    --cc=yong.liu@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).