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 07F312A5F for ; Thu, 7 Jul 2016 08:36:41 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 06 Jul 2016 23:36:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,323,1464678000"; d="scan'208";a="841965395" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 06 Jul 2016 23:36:40 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u676acml026233; Thu, 7 Jul 2016 14:36:38 +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 u676aZZh031643; Thu, 7 Jul 2016 14:36:37 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u676aZ1d031639; Thu, 7 Jul 2016 14:36:35 +0800 From: Marvin Liu To: dts@dpdk.org Cc: Marvin Liu Date: Thu, 7 Jul 2016 14:36:34 +0800 Message-Id: <1467873394-31607-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] framework tester: raise exception when parameter is invalid 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: Thu, 07 Jul 2016 06:36:42 -0000 Signed-off-by: Marvin Liu diff --git a/framework/exception.py b/framework/exception.py index 0e7a344..654e420 100644 --- a/framework/exception.py +++ b/framework/exception.py @@ -62,6 +62,9 @@ class SSHSessionDeadException(Exception): return 'SSH session with %s has been dead' % self.host +class ParameterInvalidException(Exception): + pass + class StartVMFailedException(Exception): """ diff --git a/framework/tester.py b/framework/tester.py index dffb1d5..55942d1 100644 --- a/framework/tester.py +++ b/framework/tester.py @@ -43,6 +43,7 @@ from etgen import IxiaPacketGenerator, SoftwarePacketGenerator from settings import IXIA import random from utils import GREEN +from exception import ParameterInvalidException class Tester(Crb): @@ -160,12 +161,18 @@ class Tester(Crb): """ Return tester local port pci id. """ + if localPort == -1: + raise ParameterInvalidException("local port should not be -1") + return self.ports_info[localPort]['pci'] def get_interface(self, localPort): """ Return tester local port interface name. """ + if localPort == -1: + raise ParameterInvalidException("local port should not be -1") + if 'intf' not in self.ports_info[localPort]: return 'N/A' @@ -175,6 +182,9 @@ class Tester(Crb): """ Return tester local port mac address. """ + if localPort == -1: + raise ParameterInvalidException("local port should not be -1") + if self.ports_info[localPort]['type'] == 'ixia': return "00:00:00:00:00:01" else: -- 1.9.3