{"id":23285,"url":"https://patchwork.libcamera.org/api/1.1/patches/23285/?format=json","web_url":"https://patchwork.libcamera.org/patch/23285/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250428090413.38234-14-s.pueschel@pengutronix.de>","date":"2025-04-28T09:02:38","name":"[v11,13/19] lc-compliance: Move camera setup to CameraHolder class","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"5d12b711f7742d79ed14f9a995c49c20f2aed186","submitter":{"id":225,"url":"https://patchwork.libcamera.org/api/1.1/people/225/?format=json","name":"Sven Püschel","email":"s.pueschel@pengutronix.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23285/mbox/","series":[{"id":5148,"url":"https://patchwork.libcamera.org/api/1.1/series/5148/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5148","date":"2025-04-28T09:02:25","name":"lc-compliance: Add test to queue more requests than hardware depth","version":11,"mbox":"https://patchwork.libcamera.org/series/5148/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23285/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23285/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E3128C3326\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Apr 2025 09:05:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B4C068ADE;\n\tMon, 28 Apr 2025 11:05:33 +0200 (CEST)","from metis.whiteo.stw.pengutronix.de\n\t(metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6575168B27\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Apr 2025 11:05:08 +0200 (CEST)","from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77]\n\thelo=peter.guest.stw.pengutronix.de)\n\tby metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92)\n\t(envelope-from <s.pueschel@pengutronix.de>)\n\tid 1u9KQF-0001au-VH; Mon, 28 Apr 2025 11:05:08 +0200"],"From":"=?utf-8?q?Sven_P=C3=BCschel?= <s.pueschel@pengutronix.de>","To":"libcamera-devel@lists.libcamera.org","Cc":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, Paul Elder\n\t<paul.elder@ideasonboard.com>, =?utf-8?q?Sven_P=C3=BCschel?=\n\t<s.pueschel@pengutronix.de>","Subject":"[PATCH v11 13/19] lc-compliance: Move camera setup to CameraHolder\n\tclass","Date":"Mon, 28 Apr 2025 11:02:38 +0200","Message-ID":"<20250428090413.38234-14-s.pueschel@pengutronix.de>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<20250428090413.38234-1-s.pueschel@pengutronix.de>","References":"<20250428090413.38234-1-s.pueschel@pengutronix.de>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-SA-Exim-Connect-IP":"2a0a:edc0:0:900:1d::77","X-SA-Exim-Mail-From":"s.pueschel@pengutronix.de","X-SA-Exim-Scanned":"No (on metis.whiteo.stw.pengutronix.de);\n\tSAEximRunCond expanded to false","X-PTX-Original-Recipient":"libcamera-devel@lists.libcamera.org","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n\nDifferent base classes can be used for different setups on tests, but\nall of them will need to setup the camera for the test. To reuse that\ncode, move it to a separate CameraHolder class that is inherited by test\nclasses.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Sven Püschel <s.pueschel@pengutronix.de>\n\n---\nChanges in v11:\n- rebased\n\nChanges in v9:\n- rebased\n\nChanges in v8:\n- Moved CameraHolder to new test_base.{cpp,h} files\n\nChanges in v5:\n- New\n---\n src/apps/lc-compliance/meson.build            |  1 +\n src/apps/lc-compliance/test_base.cpp          | 28 +++++++++++++++++++\n src/apps/lc-compliance/test_base.h            | 24 ++++++++++++++++\n src/apps/lc-compliance/tests/capture_test.cpp | 18 +++---------\n 4 files changed, 57 insertions(+), 14 deletions(-)\n create mode 100644 src/apps/lc-compliance/test_base.cpp\n create mode 100644 src/apps/lc-compliance/test_base.h","diff":"diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build\nindex b1f605f3..80b9a160 100644\n--- a/src/apps/lc-compliance/meson.build\n+++ b/src/apps/lc-compliance/meson.build\n@@ -15,6 +15,7 @@ lc_compliance_sources = files([\n     'environment.cpp',\n     'helpers/capture.cpp',\n     'main.cpp',\n+    'test_base.cpp',\n     'tests/capture_test.cpp',\n ])\n \ndiff --git a/src/apps/lc-compliance/test_base.cpp b/src/apps/lc-compliance/test_base.cpp\nnew file mode 100644\nindex 00000000..c9957b9e\n--- /dev/null\n+++ b/src/apps/lc-compliance/test_base.cpp\n@@ -0,0 +1,28 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2021, Collabora Ltd.\n+ *\n+ * test_base.cpp - Base definitions for tests\n+ */\n+\n+#include \"test_base.h\"\n+\n+#include \"environment.h\"\n+\n+void CameraHolder::acquireCamera()\n+{\n+\tEnvironment *env = Environment::get();\n+\n+\tcamera_ = env->cm()->get(env->cameraId());\n+\n+\tASSERT_EQ(camera_->acquire(), 0);\n+}\n+\n+void CameraHolder::releaseCamera()\n+{\n+\tif (!camera_)\n+\t\treturn;\n+\n+\tcamera_->release();\n+\tcamera_.reset();\n+}\ndiff --git a/src/apps/lc-compliance/test_base.h b/src/apps/lc-compliance/test_base.h\nnew file mode 100644\nindex 00000000..52347749\n--- /dev/null\n+++ b/src/apps/lc-compliance/test_base.h\n@@ -0,0 +1,24 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2021, Collabora Ltd.\n+ *\n+ * test_base.h - Base definitions for tests\n+ */\n+\n+#ifndef __LC_COMPLIANCE_TEST_BASE_H__\n+#define __LC_COMPLIANCE_TEST_BASE_H__\n+\n+#include <libcamera/libcamera.h>\n+\n+#include <gtest/gtest.h>\n+\n+class CameraHolder\n+{\n+protected:\n+\tvoid acquireCamera();\n+\tvoid releaseCamera();\n+\n+\tstd::shared_ptr<libcamera::Camera> camera_;\n+};\n+\n+#endif /* __LC_COMPLIANCE_TEST_BASE_H__ */\ndiff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp\nindex 9fb82a2b..24081fef 100644\n--- a/src/apps/lc-compliance/tests/capture_test.cpp\n+++ b/src/apps/lc-compliance/tests/capture_test.cpp\n@@ -15,13 +15,13 @@\n \n #include <gtest/gtest.h>\n \n-#include \"environment.h\"\n+#include \"test_base.h\"\n \n namespace {\n \n using namespace libcamera;\n \n-class SimpleCapture : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>>\n+class SimpleCapture : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>>, public CameraHolder\n {\n public:\n \tstatic std::string nameParameters(const testing::TestParamInfo<SimpleCapture::ParamType> &info);\n@@ -29,8 +29,6 @@ public:\n protected:\n \tvoid SetUp() override;\n \tvoid TearDown() override;\n-\n-\tstd::shared_ptr<Camera> camera_;\n };\n \n /*\n@@ -39,20 +37,12 @@ protected:\n  */\n void SimpleCapture::SetUp()\n {\n-\tEnvironment *env = Environment::get();\n-\n-\tcamera_ = env->cm()->get(env->cameraId());\n-\n-\tASSERT_EQ(camera_->acquire(), 0);\n+\tacquireCamera();\n }\n \n void SimpleCapture::TearDown()\n {\n-\tif (!camera_)\n-\t\treturn;\n-\n-\tcamera_->release();\n-\tcamera_.reset();\n+\treleaseCamera();\n }\n \n std::string SimpleCapture::nameParameters(const testing::TestParamInfo<SimpleCapture::ParamType> &info)\n","prefixes":["v11","13/19"]}