Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing/tests/package/test_gnuradio.py: new runtime test
@ 2023-07-22 16:17 Julien Olivain
  2023-07-22 21:15 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2023-07-22 16:17 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
This test was suggested by Thomas in [1].
This test fails without the patch proposed in [2].

[1] https://lists.buildroot.org/pipermail/buildroot/2023-July/670933.html
[2] https://patchwork.ozlabs.org/project/buildroot/patch/1689767858-17206-1-git-send-email-gwenj@trabucayre.com/
---
 DEVELOPERS                                    |  2 +
 .../testing/tests/package/test_gnuradio.py    | 42 ++++++++++++
 .../rootfs-overlay/root/test_gnuradio.py      | 68 +++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 support/testing/tests/package/test_gnuradio.py
 create mode 100755 support/testing/tests/package/test_gnuradio/rootfs-overlay/root/test_gnuradio.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 01050ebf59..ced22151a5 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1740,6 +1740,8 @@ F:	support/testing/tests/package/test_ddrescue/
 F:	support/testing/tests/package/test_dos2unix.py
 F:	support/testing/tests/package/test_gawk.py
 F:	support/testing/tests/package/test_gnupg2.py
+F:	support/testing/tests/package/test_gnuradio.py
+F:	support/testing/tests/package/test_gnuradio/
 F:	support/testing/tests/package/test_gzip.py
 F:	support/testing/tests/package/test_highway.py
 F:	support/testing/tests/package/test_hwloc.py
diff --git a/support/testing/tests/package/test_gnuradio.py b/support/testing/tests/package/test_gnuradio.py
new file mode 100644
index 0000000000..1fc0479d21
--- /dev/null
+++ b/support/testing/tests/package/test_gnuradio.py
@@ -0,0 +1,42 @@
+import os
+
+import infra.basetest
+
+
+class TestGnuradio(infra.basetest.BRTest):
+    # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it does
+    # not include: BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
+    # needed by gnuradio
+    config = \
+        """
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.39"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_PACKAGE_GNURADIO=y
+        BR2_PACKAGE_GNURADIO_BLOCKS=y
+        BR2_PACKAGE_GNURADIO_PYTHON=y
+        BR2_PACKAGE_PYTHON3=y
+        BR2_ROOTFS_OVERLAY="{}"
+        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_CPIO_GZIP=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """.format(
+           # overlay to add a gnuradio python test script
+           infra.filepath("tests/package/test_gnuradio/rootfs-overlay"))
+
+    def test_run(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+        kern = os.path.join(self.builddir, "images", "Image")
+        self.emulator.boot(arch="aarch64",
+                           kernel=kern,
+                           kernel_cmdline=["console=ttyAMA0"],
+                           options=["-M", "virt", "-cpu", "cortex-a57", "-m", "256M", "-initrd", img])
+        self.emulator.login()
+
+        self.assertRunOk("/root/test_gnuradio.py", timeout=30)
diff --git a/support/testing/tests/package/test_gnuradio/rootfs-overlay/root/test_gnuradio.py b/support/testing/tests/package/test_gnuradio/rootfs-overlay/root/test_gnuradio.py
new file mode 100755
index 0000000000..4b63674533
--- /dev/null
+++ b/support/testing/tests/package/test_gnuradio/rootfs-overlay/root/test_gnuradio.py
@@ -0,0 +1,68 @@
+#! /usr/bin/env python3
+
+from gnuradio import blocks
+from gnuradio import gr
+
+INPUT_LENGTH = 100
+MUL_CONST = 3
+ADD_CONST = 5
+
+
+def compute_expected_data(input_data):
+    # demux input
+    even = input_data[::2]
+    odd = input_data[1::2]
+
+    # multiply "even" list by MUL_CONST
+    even = [x * MUL_CONST for x in even]
+
+    # add 5 to all "odd" elements
+    odd = [y + ADD_CONST for y in odd]
+
+    # mux the two lists
+    mux = [v for t in zip(even, odd) for v in t]
+
+    return mux
+
+
+def main():
+
+    gr.log.info("Starting Buildroot Test for GNU Radio " + gr.version())
+
+    input_data = list(range(INPUT_LENGTH))
+
+    tb = gr.top_block()
+
+    # Create Gnuradio Blocks
+    src = blocks.vector_source_i(input_data)
+    demux = blocks.deinterleave(gr.sizeof_int)
+    mul = blocks.multiply_const_ii(MUL_CONST)
+    add = blocks.add_const_ii(ADD_CONST)
+    mux = blocks.interleave(gr.sizeof_int)
+    sink = blocks.vector_sink_i()
+
+    # Create connection in top block
+    tb.connect(src, demux)
+    tb.connect((demux, 0), mul)
+    tb.connect((demux, 1), add)
+    tb.connect(mul, (mux, 0))
+    tb.connect(add, (mux, 1))
+    tb.connect(mux, sink)
+
+    tb.run()
+
+    gnuradio_data = sink.data()
+    expected_data = compute_expected_data(input_data)
+
+    # For easy debugging
+    if gnuradio_data != expected_data:
+        print("Gnuradio output:", gnuradio_data)
+        print("Expected output:", expected_data)
+
+    assert gnuradio_data == expected_data
+
+    gr.log.info("Test PASSED")
+
+
+if __name__ == "__main__":
+    main()
-- 
2.41.0

_______________________________________________
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/tests/package/test_gnuradio.py: new runtime test
  2023-07-22 16:17 [Buildroot] [PATCH 1/1] support/testing/tests/package/test_gnuradio.py: new runtime test Julien Olivain
@ 2023-07-22 21:15 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-07-22 21:15 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

On Sat, 22 Jul 2023 18:17:08 +0200
Julien Olivain <ju.o@free.fr> wrote:

> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> This test was suggested by Thomas in [1].
> This test fails without the patch proposed in [2].

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:[~2023-07-22 21:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-22 16:17 [Buildroot] [PATCH 1/1] support/testing/tests/package/test_gnuradio.py: new runtime test Julien Olivain
2023-07-22 21:15 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox