summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qduplex_ser.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iseebcn.com>2019-03-09 21:25:56 +0100
committerManel Caro <mcaro@iseebcn.com>2019-03-09 21:25:56 +0100
commit9332c933fc05f42882640c9a4e35fab09854af84 (patch)
tree2b9b00b5a411b27f9705603c0d93b8925afd4677 /test-cli/test/tests/qduplex_ser.py
downloadboard-9332c933fc05f42882640c9a4e35fab09854af84.zip
board-9332c933fc05f42882640c9a4e35fab09854af84.tar.gz
board-9332c933fc05f42882640c9a4e35fab09854af84.tar.bz2
Board: Client Test Suite Initial Commit
Diffstat (limited to 'test-cli/test/tests/qduplex_ser.py')
-rw-r--r--test-cli/test/tests/qduplex_ser.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/test-cli/test/tests/qduplex_ser.py b/test-cli/test/tests/qduplex_ser.py
new file mode 100644
index 0000000..98bda81
--- /dev/null
+++ b/test-cli/test/tests/qduplex_ser.py
@@ -0,0 +1,46 @@
+from test.helpers.syscmd import SysCommand
+import unittest
+import uuid
+import serial
+import time
+
+class Qduplex(unittest.TestCase):
+
+ def __init__(self, testname, testfunc, port1, port2, baudrate):
+ super(Qduplex, self).__init__(testfunc)
+ self.__port1 = port1
+ self.__serial1 = serial.Serial(self.__port1, timeout=1)
+ self.__serial1.baudrate = baudrate
+
+ self.__port2 = port2
+ self.__serial2 = serial.Serial(self.__port2, timeout=1)
+ self.__serial2.baudrate = baudrate
+ self._testMethodDoc = testname
+
+ def __del__(self):
+ self.__serial1.close()
+ self.__serial2.close()
+
+ def execute(self):
+ self.__serial1.flushInput()
+ self.__serial1.flushOutput()
+ self.__serial2.flushInput()
+ self.__serial2.flushOutput()
+ test_uuid = str(uuid.uuid4()).encode()
+ self.__serial1.write(test_uuid)
+ time.sleep(0.05) # there might be a small delay
+ if self.__serial2.inWaiting() == 0:
+ self.fail("failed: PORT {} wait timeout exceded, wrong communication?".format(self.__port2))
+ else:
+ if (self.__serial2.readline() != test_uuid):
+ self.fail("failed: PORT {} write/read mismatch".format(self.__port2))
+
+ test_uuid = str(uuid.uuid4()).encode()
+ self.__serial2.write(test_uuid)
+ time.sleep(0.05) # there might be a small delay
+ if self.__serial1.inWaiting() == 0:
+ self.fail("failed: PORT {} wait timeout exceded, wrong communication?".format(self.__port1))
+ else:
+ if (self.__serial1.readline() != test_uuid):
+ self.fail("failed: PORT {} write/read mismatch".format(self.__port1))
+