[dts] [PATCH] framework tester: raise exception when parameter is invalid

Marvin Liu yong.liu at intel.com
Thu Jul 7 08:36:34 CEST 2016


Signed-off-by: Marvin Liu <yong.liu at intel.com>

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



More information about the dts mailing list