[PATCH 3/5] TestTCPConnect: option parsing bug fixes

olichtne at redhat.com olichtne at redhat.com
Fri Feb 8 10:09:47 UTC 2013


From: Ondrej Lichtner <olichtne at redhat.com>

This commit fixes two bugs during option parsing:

* option "sleep" is not mandatory but when not specified the module
* crashes

* option "port" needs to be an integer value, and the function extend
* was used on the port list, splitting the port string into individual
* characters

Signed-off-by: Ondrej Lichtner <olichtne at redhat.com>
---
 test_modules/TestTCPConnect.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test_modules/TestTCPConnect.py b/test_modules/TestTCPConnect.py
index 4a5dc5c..4da2600 100644
--- a/test_modules/TestTCPConnect.py
+++ b/test_modules/TestTCPConnect.py
@@ -123,7 +123,7 @@ class TestTCPConnect(TestGeneric):
         # either port or port_range should be set
         port = self.get_opt("port")
         if port:
-            self._port = port
+            self._port = int(port)
         else:
             port_range = self.get_opt("port_range")
             if port_range:
@@ -132,9 +132,11 @@ class TestTCPConnect(TestGeneric):
                 e = TestOptionMissing()
                 raise e
 
-        sleep_time = float(self.get_opt("sleep"))
+        sleep_time = self.get_opt("sleep")
         if sleep_time:
-            self._sleep_time = sleep_time
+            self._sleep_time = float(sleep_time)
+        else:
+            self._sleep_time = 0
 
         cont = self.get_opt("cont")
         if cont:
@@ -177,7 +179,7 @@ class TestTCPConnect(TestGeneric):
 
         ports = []
         if self._port:
-            ports.extend(self._port)
+            ports.append(self._port)
         else:
             r = self.parse_port_range()
             ports.extend(r)
-- 
1.7.11.7



More information about the LNST-developers mailing list