Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: add libcamera runtime test
@ 2024-02-04 19:19 Julien Olivain
  2024-02-06 22:25 ` Peter Korsgaard
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2024-02-04 19:19 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 DEVELOPERS                                    |  2 +
 .../testing/tests/package/test_libcamera.py   | 79 +++++++++++++++++++
 .../test_libcamera/linux-vimc.fragment        |  4 +
 3 files changed, 85 insertions(+)
 create mode 100644 support/testing/tests/package/test_libcamera.py
 create mode 100644 support/testing/tests/package/test_libcamera/linux-vimc.fragment

diff --git a/DEVELOPERS b/DEVELOPERS
index 02b7516a92..0acf49296d 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1783,6 +1783,8 @@ F:	support/testing/tests/package/test_kexec/
 F:	support/testing/tests/package/test_kmscube.py
 F:	support/testing/tests/package/test_kmscube/
 F:	support/testing/tests/package/test_less.py
+F:	support/testing/tests/package/test_libcamera.py
+F:	support/testing/tests/package/test_libcamera/
 F:	support/testing/tests/package/test_libgpgme.py
 F:	support/testing/tests/package/test_libjxl.py
 F:	support/testing/tests/package/test_lrzip.py
diff --git a/support/testing/tests/package/test_libcamera.py b/support/testing/tests/package/test_libcamera.py
new file mode 100644
index 0000000000..8953021b82
--- /dev/null
+++ b/support/testing/tests/package/test_libcamera.py
@@ -0,0 +1,79 @@
+import os
+
+import infra.basetest
+
+
+class TestLibCamera(infra.basetest.BRTest):
+    # A specific configuration is needed for testing libcamera:
+    # a kernel config fragment enables v4l2 vimc driver.
+    # The libevent package is also enabled to have the libcamera "cam"
+    # test application.
+    kernel_fragment = \
+        infra.filepath("tests/package/test_libcamera/linux-vimc.fragment")
+    config = \
+        f"""
+        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.76"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kernel_fragment}"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_PACKAGE_LIBCAMERA=y
+        BR2_PACKAGE_LIBCAMERA_PIPELINE_VIMC=y
+        BR2_PACKAGE_LIBEVENT=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_CPIO_GZIP=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    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()
+
+        # The Kernel config of this test has only one v4l2 vimc
+        # driver. The camera index is expected to be #1.
+        cam_idx = 1
+
+        # We test libcamera with its simple "cam" application, by
+        # requesting a list of available cameras.
+        cmd = "cam --list"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        # libcamera generates info messages. We filter only the
+        # line(s) starting with our camera index.
+        cam_line = [ln for ln in out if ln.startswith(f"{cam_idx}:")]
+        # We should have the vimc camera in this line.
+        self.assertIn("platform/vimc.0", cam_line[0])
+
+        # List the camera information.
+        cmd = f"cam --camera {cam_idx} --info"
+        self.assertRunOk(cmd)
+
+        # List the camera controls and check we have a brightness
+        # control.
+        cmd = f"cam --camera {cam_idx} --list-controls"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertIn("Control: Brightness:", "\n".join(out))
+
+        # List the camera properties and check we have a camera
+        # "Model" property.
+        cmd = f"cam --camera {cam_idx} --list-properties"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertIn("Property: Model = ", "\n".join(out))
+
+        # Capture few frames.
+        cmd = f"cam --camera {cam_idx} --capture=5"
+        cmd += " --stream width=160,height=120,role=video,pixelformat=RGB888"
+        self.assertRunOk(cmd)
diff --git a/support/testing/tests/package/test_libcamera/linux-vimc.fragment b/support/testing/tests/package/test_libcamera/linux-vimc.fragment
new file mode 100644
index 0000000000..04436e7518
--- /dev/null
+++ b/support/testing/tests/package/test_libcamera/linux-vimc.fragment
@@ -0,0 +1,4 @@
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_TEST_SUPPORT=y
+CONFIG_V4L_TEST_DRIVERS=y
+CONFIG_VIDEO_VIMC=y
-- 
2.43.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: add libcamera runtime test
  2024-02-04 19:19 [Buildroot] [PATCH 1/1] support/testing: add libcamera runtime test Julien Olivain
@ 2024-02-06 22:25 ` Peter Korsgaard
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2024-02-06 22:25 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:

 > Signed-off-by: Julien Olivain <ju.o@free.fr>

Committed, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
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:[~2024-02-06 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-04 19:19 [Buildroot] [PATCH 1/1] support/testing: add libcamera runtime test Julien Olivain
2024-02-06 22:25 ` Peter Korsgaard

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