diff mbox series

[1/1] support/testing: new gstreamer1 runtime test

Message ID 20250101182705.976322-1-ju.o@free.fr
State Accepted
Headers show
Series [1/1] support/testing: new gstreamer1 runtime test | expand

Commit Message

Julien Olivain Jan. 1, 2025, 6:27 p.m. UTC
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/8751575397
---
 DEVELOPERS                                    |  1 +
 .../testing/tests/package/test_gstreamer1.py  | 82 +++++++++++++++++++
 2 files changed, 83 insertions(+)
 create mode 100644 support/testing/tests/package/test_gstreamer1.py

Comments

Peter Korsgaard Feb. 3, 2025, 10:13 p.m. UTC | #1
>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:

 > Signed-off-by: Julien Olivain <ju.o@free.fr>
 > ---
 > Patch tested in:
 > https://gitlab.com/jolivain/buildroot/-/jobs/8751575397

Creative!

Committed, thanks.
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 381bc9f490..d435abb8d2 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1887,6 +1887,7 @@  F:	support/testing/tests/package/test_gnuradio.py
 F:	support/testing/tests/package/test_gnuradio/
 F:	support/testing/tests/package/test_gpsd.py
 F:	support/testing/tests/package/test_gpsd/
+F:	support/testing/tests/package/test_gstreamer1.py
 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_gstreamer1.py b/support/testing/tests/package/test_gstreamer1.py
new file mode 100644
index 0000000000..aa4b67d1a6
--- /dev/null
+++ b/support/testing/tests/package/test_gstreamer1.py
@@ -0,0 +1,82 @@ 
+import os
+
+import infra.basetest
+
+
+class TestGstreamer1(infra.basetest.BRTest):
+    # This test creates a full, yet simple, Gstreamer pipeline which
+    # encodes/decodes a video, using only plugins from Base and Good
+    # packages. It will use Tesseract OCR to validate the final
+    # output. The DejaVu font package is also installed, in order to
+    # have few fonts for the Pango plugin.
+    config = \
+        """
+        BR2_arm=y
+        BR2_cortex_a9=y
+        BR2_ARM_ENABLE_VFP=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_PACKAGE_DEJAVU=y
+        BR2_PACKAGE_GSTREAMER1=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_OGG=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_PANGO=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_THEORA=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC=y
+        BR2_PACKAGE_GST1_PLUGINS_GOOD=y
+        BR2_PACKAGE_GST1_PLUGINS_GOOD_PNG=y
+        BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_MULTIFILE=y
+        BR2_PACKAGE_TESSERACT_OCR=y
+        BR2_PACKAGE_TESSERACT_OCR_LANG_ENG=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="armv7",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        video_file = "videotest.ogg"
+        num_frames = 10
+        msg_prefix = "Hello Buildroot:"
+
+        # We check the main program can execute.
+        self.assertRunOk("gst-launch-1.0 --version")
+
+        # We check we can list installed plugins.
+        self.assertRunOk("gst-inspect-1.0")
+
+        # We check we can query one of the plugin we requested.
+        self.assertRunOk("gst-inspect-1.0 theoraenc")
+
+        # We create a Ogg/Theora video file. We use the "videotestsrc"
+        # with the ball animation which will create a small file. We
+        # add a time overlay with a message. We encode with the Theora
+        # codec and store everything in an Ogg container file.
+        enc_pipeline = \
+            f"videotestsrc num-buffers={num_frames} pattern=ball ! " \
+            f"timeoverlay text=\"{msg_prefix}\" font-desc=\"Sans, 24\" ! " \
+            f"theoraenc ! oggmux ! filesink location={video_file}"
+        cmd = f"gst-launch-1.0 -v {enc_pipeline}"
+        self.assertRunOk(cmd)
+
+        # We decode our previous video file and store each frame in a
+        # PNG image file.
+        dec_pipeline = \
+            f"filesrc location={video_file} ! " \
+            "decodebin ! videoconvert ! pngenc ! " \
+            "multifilesink index=1 location=frame%02d.png"
+        cmd = f"gst-launch-1.0 -v {dec_pipeline}"
+        self.assertRunOk(cmd)
+
+        # We extract the text from our last image.
+        img_file = f"frame{num_frames}.png"
+        cmd = f"tesseract {img_file} output"
+        self.assertRunOk(cmd)
+
+        # We check we have our initial message.
+        out, ret = self.emulator.run("cat output.txt")
+        self.assertEqual(ret, 0)
+        self.assertTrue(out[0].startswith(msg_prefix))