[Buildroot] [git commit] support/testing: add minimalmodbus runtime test

Yann E. MORIN yann.morin.1998 at free.fr
Mon Feb 5 15:06:19 UTC 2024


commit: https://git.buildroot.net/buildroot/commit/?id=8f7e112ab20265e9005b9b97c6a129d6bec66f12
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Signed-off-by: Marcus Hoffmann <bubu at bubu1.eu>
[yann.morin.1998 at free.fr: add the comment to explain failure is success]
Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
---
 support/testing/tests/package/sample_python_minimalmodbus.py | 11 +++++++++++
 support/testing/tests/package/test_python_minimalmodbus.py   | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/support/testing/tests/package/sample_python_minimalmodbus.py b/support/testing/tests/package/sample_python_minimalmodbus.py
new file mode 100644
index 0000000000..dc5db8d9e2
--- /dev/null
+++ b/support/testing/tests/package/sample_python_minimalmodbus.py
@@ -0,0 +1,11 @@
+import minimalmodbus
+from serial.serialutil import SerialException
+
+# We can't test proper behaviour in emulation, because there is
+# actually no emulated modbus hardware, so we rely on the module
+# to fail in an expected way to consider it is working correctly.
+# Failure (of the script) is success (of the test)!
+try:
+    instrument = minimalmodbus.Instrument('/dev/ttyUSB99', 1)
+except SerialException:
+    pass
diff --git a/support/testing/tests/package/test_python_minimalmodbus.py b/support/testing/tests/package/test_python_minimalmodbus.py
new file mode 100644
index 0000000000..53813406de
--- /dev/null
+++ b/support/testing/tests/package/test_python_minimalmodbus.py
@@ -0,0 +1,11 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Minimalmodbus(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_MINIMALMODBUS=y
+        """
+    sample_scripts = ["tests/package/sample_python_minimalmodbus.py"]



More information about the buildroot mailing list