[Buildroot] [git commit] support/testing: add zbar runtime test

Thomas Petazzoni thomas.petazzoni at bootlin.com
Thu May 9 20:09:22 UTC 2024


commit: https://git.buildroot.net/buildroot/commit/?id=85f0941532c424df2d7b1cfc153546d02dd3cd12
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Signed-off-by: Julien Olivain <ju.o at free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
 DEVELOPERS                                 |  1 +
 support/testing/tests/package/test_zbar.py | 37 ++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index 10f93d61aa..2054b8be4d 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1900,6 +1900,7 @@ F:	support/testing/tests/package/test_wine.py
 F:	support/testing/tests/package/test_xz.py
 F:	support/testing/tests/package/test_z3.py
 F:	support/testing/tests/package/test_z3/
+F:	support/testing/tests/package/test_zbar.py
 F:	support/testing/tests/package/test_zchunk.py
 F:	support/testing/tests/package/test_zstd.py
 
diff --git a/support/testing/tests/package/test_zbar.py b/support/testing/tests/package/test_zbar.py
new file mode 100644
index 0000000000..b840df089a
--- /dev/null
+++ b/support/testing/tests/package/test_zbar.py
@@ -0,0 +1,37 @@
+import os
+
+import infra.basetest
+
+
+class TestZbar(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_IMAGEMAGICK=y
+        BR2_PACKAGE_LIBQRENCODE=y
+        BR2_PACKAGE_LIBQRENCODE_TOOLS=y
+        BR2_PACKAGE_ZBAR=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()
+
+        txt_msg = "Hello Buildroot!"
+        qr_img = "qr.png"
+
+        # We check the program can execute.
+        self.assertRunOk("zbarimg --version")
+
+        # We generate a QR code image containing a message.
+        self.assertRunOk(f"qrencode -o '{qr_img}' '{txt_msg}'")
+
+        # We decode the QR code image and check the extracted message
+        # is the expected one.
+        out, ret = self.emulator.run(f"zbarimg -q --raw {qr_img}")
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], txt_msg)



More information about the buildroot mailing list