From: Marcus Hoffmann <marcus.hoffmann@othermo.de>
To: buildroot@buildroot.org
Cc: Davide Viti <zinosat@gmail.com>, Asaf Kahlon <asafka7@gmail.com>
Subject: [Buildroot] [next v2 2/2] support/testing/tests/package/test_python_paho_mqtt: new runtime test
Date: Mon, 29 Aug 2022 19:18:20 +0200 [thread overview]
Message-ID: <20220829171820.130690-1-marcus.hoffmann@othermo.de> (raw)
Signed-off-by: Marcus Hoffmann <marcus.hoffmann@othermo.de>
Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
.../tests/package/sample_python_paho_mqtt.py | 12 ++++++++
.../tests/package/test_python_paho_mqtt.py | 29 +++++++++++++++++++
2 files changed, 41 insertions(+)
create mode 100644 support/testing/tests/package/sample_python_paho_mqtt.py
create mode 100644 support/testing/tests/package/test_python_paho_mqtt.py
diff --git a/support/testing/tests/package/sample_python_paho_mqtt.py b/support/testing/tests/package/sample_python_paho_mqtt.py
new file mode 100644
index 0000000000..769ad6250f
--- /dev/null
+++ b/support/testing/tests/package/sample_python_paho_mqtt.py
@@ -0,0 +1,12 @@
+from paho.mqtt import publish, subscribe
+
+publish.single(
+ 'buildroot/test',
+ payload="Hello, World!",
+ qos=2,
+ retain=True,
+ hostname="localhost",
+ port=1883)
+
+message = subscribe.simple('buildroot/test')
+print(message.payload.decode())
diff --git a/support/testing/tests/package/test_python_paho_mqtt.py b/support/testing/tests/package/test_python_paho_mqtt.py
new file mode 100644
index 0000000000..b1e2b8fb42
--- /dev/null
+++ b/support/testing/tests/package/test_python_paho_mqtt.py
@@ -0,0 +1,29 @@
+from tests.package.test_python import TestPythonPackageBase
+import os
+import time
+
+
+class TestPythonPahoMQTT(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_MOSQUITTO=y
+ BR2_PACKAGE_MOSQUITTO_BROKER=y
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_PAHO_MQTT=y
+ """
+ sample_scripts = ["tests/package/sample_python_paho_mqtt.py"]
+
+ def test_run(self):
+ self.login()
+ self.check_sample_scripts_exist()
+ cmd = "mosquitto > /dev/null 2>&1 &"
+ _, exit_code = self.emulator.run(cmd, timeout=self.timeout)
+
+ # Give some time for mosquitto broker to start up
+ time.sleep(1)
+
+ cmd = "%s %s" % (self.interpreter, os.path.basename(self.sample_scripts[0]))
+ output, exit_code = self.emulator.run(cmd, timeout=self.timeout)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output[0], "Hello, World!")
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next reply other threads:[~2022-08-29 17:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 17:18 Marcus Hoffmann [this message]
2022-08-31 19:42 ` [Buildroot] [next v2 2/2] support/testing/tests/package/test_python_paho_mqtt: new runtime test Yann E. MORIN
2022-08-31 19:44 ` Yann E. MORIN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220829171820.130690-1-marcus.hoffmann@othermo.de \
--to=marcus.hoffmann@othermo.de \
--cc=asafka7@gmail.com \
--cc=buildroot@buildroot.org \
--cc=zinosat@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.