mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-10 00:04:06 -09:00
support/testing: add mosquitto runtime test
Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 3ba6f800fd)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
eb2004ef03
commit
fd6e1c41b9
@@ -1828,6 +1828,7 @@ F: support/testing/tests/package/test_mdadm.py
|
||||
F: support/testing/tests/package/test_mdadm/
|
||||
F: support/testing/tests/package/test_micropython.py
|
||||
F: support/testing/tests/package/test_micropython/
|
||||
F: support/testing/tests/package/test_mosquitto.py
|
||||
F: support/testing/tests/package/test_mtools.py
|
||||
F: support/testing/tests/package/test_mtr.py
|
||||
F: support/testing/tests/package/test_ncdu.py
|
||||
|
||||
38
support/testing/tests/package/test_mosquitto.py
Normal file
38
support/testing/tests/package/test_mosquitto.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestMosquitto(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_PACKAGE_MOSQUITTO=y
|
||||
BR2_PACKAGE_MOSQUITTO_BROKER=y
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
|
||||
self.emulator.boot(arch="armv5",
|
||||
kernel="builtin",
|
||||
options=["-initrd", cpio_file])
|
||||
self.emulator.login()
|
||||
|
||||
topic = "br-test-topic"
|
||||
log = "mqtt.log"
|
||||
msg = "Hello Buildroot!"
|
||||
|
||||
# We subscribe to a topic and write one message to a log file.
|
||||
self.assertRunOk(f"mosquitto_sub -t {topic} -C 1 > {log} &")
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# We publish a message.
|
||||
self.assertRunOk(f"mosquitto_pub -t {topic} -m '{msg}'")
|
||||
|
||||
# We check the log file contains our message.
|
||||
out, ret = self.emulator.run(f"cat {log}")
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[0], msg)
|
||||
Reference in New Issue
Block a user