summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qduplex_ser.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test/tests/qduplex_ser.py')
-rw-r--r--test-cli/test/tests/qduplex_ser.py43
1 files changed, 40 insertions, 3 deletions
diff --git a/test-cli/test/tests/qduplex_ser.py b/test-cli/test/tests/qduplex_ser.py
index c7231c2..020844a 100644
--- a/test-cli/test/tests/qduplex_ser.py
+++ b/test-cli/test/tests/qduplex_ser.py
@@ -9,6 +9,7 @@ class Qduplex(unittest.TestCase):
__port1 = None
__port2 = None
__baudrate = None
+ __resultlist = None # resultlist is a python list of python dictionaries
# varlist: port1, port2, baudrate
def __init__(self, testname, testfunc, varlist):
@@ -27,6 +28,7 @@ class Qduplex(unittest.TestCase):
else:
raise Exception('baudrate param inside Qduplex must be defined')
self._testMethodDoc = testname
+ self.__resultlist = []
# open serial connection
self.__serial1 = serial.Serial(self.__port1, self.__baudrate, timeout=1)
@@ -49,9 +51,23 @@ class Qduplex(unittest.TestCase):
self.__serial1.write(test_uuid)
time.sleep(0.05) # there might be a small delay
if self.__serial2.inWaiting() == 0:
+ self.__resultlist.append(
+ {
+ "desc": "Test result",
+ "data": "FAILED: port {} wait timeout exceded".format(self.__port2),
+ "type": "string"
+ }
+ )
self.fail("failed: port {} wait timeout exceded".format(self.__port2))
else:
if self.__serial2.readline() != test_uuid:
+ self.__resultlist.append(
+ {
+ "desc": "Test result",
+ "data": "FAILED: port {} write/read mismatch".format(self.__port2),
+ "type": "string"
+ }
+ )
self.fail("failed: port {} write/read mismatch".format(self.__port2))
time.sleep(0.05) # there might be a small delay
@@ -65,12 +81,33 @@ class Qduplex(unittest.TestCase):
self.__serial2.write(test_uuid)
time.sleep(0.05) # there might be a small delay
if self.__serial1.inWaiting() == 0:
+ self.__resultlist.append(
+ {
+ "desc": "Test result",
+ "data": "FAILED: port {} wait timeout exceded".format(self.__port1),
+ "type": "string"
+ }
+ )
self.fail("failed: port {} wait timeout exceded".format(self.__port1))
else:
if self.__serial1.readline() != test_uuid:
+ self.__resultlist.append(
+ {
+ "desc": "Test result",
+ "data": "FAILED: port {} write/read mismatch".format(self.__port1),
+ "type": "string"
+ }
+ )
self.fail("failed: port {} write/read mismatch".format(self.__port1))
+ # Test successful
+ self.__resultlist.append(
+ {
+ "desc": "Test OK",
+ "data": "OK",
+ "type": "string"
+ }
+ )
+
def getresults(self):
- # resultlist is a python list of python dictionaries
- resultlist = []
- return resultlist
+ return self.__resultlist