* [Buildroot] [PATCH 1/1] support/testing: add test for ola
@ 2022-07-26 17:53 Julien Olivain
2022-08-01 19:59 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2022-07-26 17:53 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
This test relies on the OLA Dummy plugin presenting a test device
and port. It starts the daemon, performs few configuration commands,
covers the Python bindings and also test the OLA web interface.
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
This OLA test was suggested in:
https://lists.buildroot.org/pipermail/buildroot/2022-July/647089.html
This patch was tested with:
make check-package
...
0 warnings generated
python3 -m flake8 \
support/testing/tests/package/test_ola.py \
support/testing/tests/package/test_ola/rootfs-overlay/usr/bin/sample_ola_rdm_discovery.py
[no-output]
support/testing/run-tests \
-d dl \
-o output_folder \
tests.package.test_ola.TestOla
...
OK
---
DEVELOPERS | 2 +
support/testing/tests/package/test_ola.py | 95 +++++++++++++++++++
.../usr/bin/sample_ola_rdm_discovery.py | 24 +++++
3 files changed, 121 insertions(+)
create mode 100644 support/testing/tests/package/test_ola.py
create mode 100755 support/testing/tests/package/test_ola/rootfs-overlay/usr/bin/sample_ola_rdm_discovery.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 1dede4b83b..eb5bc5d985 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1657,6 +1657,8 @@ F: package/zynaddsubfx/
F: support/testing/tests/package/sample_python_distro.py
F: support/testing/tests/package/sample_python_gnupg.py
F: support/testing/tests/package/test_octave.py
+F: support/testing/tests/package/test_ola.py
+F: support/testing/tests/package/test_ola/
F: support/testing/tests/package/test_python_distro.py
F: support/testing/tests/package/test_python_gnupg.py
diff --git a/support/testing/tests/package/test_ola.py b/support/testing/tests/package/test_ola.py
new file mode 100644
index 0000000000..017d6f7e3b
--- /dev/null
+++ b/support/testing/tests/package/test_ola.py
@@ -0,0 +1,95 @@
+import os
+
+import infra.basetest
+
+
+class TestOla(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_PACKAGE_OLA=y
+ BR2_PACKAGE_OLA_EXAMPLES=y
+ BR2_PACKAGE_OLA_PLUGIN_DUMMY=y
+ BR2_PACKAGE_OLA_PYTHON_BINDINGS=y
+ BR2_PACKAGE_OLA_WEB=y
+ BR2_PACKAGE_PYTHON3=y
+ BR2_ROOTFS_OVERLAY="{}"
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """.format(
+ # overlay to add a script to test ola python bindings
+ infra.filepath("tests/package/test_ola/rootfs-overlay"))
+
+ 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()
+
+ # Check program executes
+ cmd = "olad --version"
+ self.assertRunOk(cmd)
+
+ # Start the daemon and wait a bit for it to settle
+ cmd = "olad --daemon && sleep 2"
+ self.assertRunOk(cmd)
+
+ # Check dummy plugin is loaded
+ cmd = "ola_plugin_info | grep -Fi dummy"
+ self.assertRunOk(cmd)
+
+ # Check dummy device and port are listed
+ cmd = "ola_dev_info"
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ self.assertIn("Device 1: Dummy Device", output[0])
+ self.assertIn("port 0, OUT Dummy Port", output[1])
+
+ # Create Universe 0
+ cmd = "ola_patch --device 1 --port 0 --universe 0"
+ self.assertRunOk(cmd)
+
+ # Check Universe 0 is created
+ cmd = "ola_dev_info"
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ self.assertIn("patched to universe 0", output[1])
+
+ # Discover Dummy device RDM UID
+ cmd = "ola_rdm_discover --universe 0 | head -1"
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ rdm_uid = output[0]
+
+ # Get RDM manufacturer_label PID
+ cmd = "ola_rdm_get --universe 0 --uid {} manufacturer_label".format(rdm_uid)
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output[0], "Open Lighting Project")
+
+ # Get RDM dmx_start_address PID, checks default value is 1
+ cmd = "ola_rdm_get --universe 0 --uid {} dmx_start_address".format(rdm_uid)
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output[0], "DMX Address: 1")
+
+ # Set RDM dmx_start_address PID to 2
+ cmd = "ola_rdm_set --universe 0 --uid {} dmx_start_address 2".format(rdm_uid)
+ self.assertRunOk(cmd)
+
+ # Get the new RDM dmx_start_address PID, checks value is now 2
+ cmd = "ola_rdm_get --universe 0 --uid {} dmx_start_address".format(rdm_uid)
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output[0], "DMX Address: 2")
+
+ # Perform a full RDM discovery using python bindings. The test
+ # expect to find the same UID detected with the C client.
+ cmd = "sample_ola_rdm_discovery.py | head -1"
+ output, exit_code = self.emulator.run(cmd)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output[0], rdm_uid)
+
+ # Test olad web interface
+ cmd = "wget -q -O - http://127.0.0.1:9090/ola.html | grep -F '<title>OLA Admin</title>'"
+ self.assertRunOk(cmd)
diff --git a/support/testing/tests/package/test_ola/rootfs-overlay/usr/bin/sample_ola_rdm_discovery.py b/support/testing/tests/package/test_ola/rootfs-overlay/usr/bin/sample_ola_rdm_discovery.py
new file mode 100755
index 0000000000..c2aa0733bb
--- /dev/null
+++ b/support/testing/tests/package/test_ola/rootfs-overlay/usr/bin/sample_ola_rdm_discovery.py
@@ -0,0 +1,24 @@
+#! /usr/bin/env python3
+
+import sys
+
+from ola.ClientWrapper import ClientWrapper
+
+
+def show_uids(state, uids):
+ if state.Succeeded():
+ for uid in uids:
+ print(str(uid))
+ else:
+ print('Error: %s' % state.message, file=sys.stderr)
+ wrapper.Stop()
+
+
+wrapper = ClientWrapper()
+client = wrapper.Client()
+universe = 0
+full_discovery = True
+
+client.RunRDMDiscovery(universe, full_discovery, show_uids)
+
+wrapper.Run()
--
2.37.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/testing: add test for ola
2022-07-26 17:53 [Buildroot] [PATCH 1/1] support/testing: add test for ola Julien Olivain
@ 2022-08-01 19:59 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-08-01 19:59 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
On Tue, 26 Jul 2022 19:53:44 +0200
Julien Olivain <ju.o@free.fr> wrote:
> This test relies on the OLA Dummy plugin presenting a test device
> and port. It starts the daemon, performs few configuration commands,
> covers the Python bindings and also test the OLA web interface.
>
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> This OLA test was suggested in:
> https://lists.buildroot.org/pipermail/buildroot/2022-July/647089.html
Applied to master, thanks.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-01 20:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-26 17:53 [Buildroot] [PATCH 1/1] support/testing: add test for ola Julien Olivain
2022-08-01 19:59 ` Thomas Petazzoni via buildroot
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.