support/testing: add minimalmodbus runtime test

Signed-off-by: Marcus Hoffmann <bubu@bubu1.eu>
[yann.morin.1998@free.fr: add the comment to explain failure is success]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Marcus Hoffmann 2024-02-05 14:08:32 +01:00 committed by Yann E. MORIN
parent 8366622fc8
commit 8f7e112ab2
2 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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"]