From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 52BB68DB1 for ; Wed, 2 Dec 2015 08:42:12 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 01 Dec 2015 23:42:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,372,1444719600"; d="scan'208";a="852066664" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 01 Dec 2015 23:42:10 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id tB27g84f002126; Wed, 2 Dec 2015 15:42:08 +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 tB27g6S0001143; Wed, 2 Dec 2015 15:42:08 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id tB27g6H9001139; Wed, 2 Dec 2015 15:42:06 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 2 Dec 2015 15:41:59 +0800 Message-Id: <1449042119-1107-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1448959904-23907-1-git-send-email-yong.liu@intel.com> References: <1448959904-23907-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH v2] framework: support create addtional sessions on crb 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, 02 Dec 2015 07:42:12 -0000 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. Suite should appoint out which logfile used to save output message. By default output message will be saved in dts.log. Below is sample code for addtional session: session = self.dut.new_session(suite="TestVlan") session.send_expect("ls -al", "# ") self.dut.close_session(session=session) Signed-off-by: Marvin Liu diff --git a/framework/crb.py b/framework/crb.py index 3c158ec..5ea0d63 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,28 @@ 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. + """ + logger = getLogger(name) + session = SSHConnection(self.get_ip_address(), name, + self.get_password()) + session.init_log(logger) + self.sessions.append(session) + return session + + def destroy_session(self, session=None): + """ + Destroy addtional session. + """ + for save_session in self.sessions: + if save_session == session: + save_session.close() + logger = getLogger(save_session.name) + logger.logger_exit() + 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..2101fc8 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,25 @@ class Dut(Crb): self.host_session.init_log(self.logger) self.host_init_flag = True + def new_session(self, suite=""): + """ + Create new session for dut instance. Session name will be unique. + """ + session_name = self.NAME + '_' + str(uuid4()) + session = self.create_session(name=session_name) + if suite != "": + session.logger.config_suite(suite, self.NAME) + else: + session.logger.config_execution(self.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