{"id":19784,"url":"https://patchwork.libcamera.org/api/patches/19784/?format=json","web_url":"https://patchwork.libcamera.org/patch/19784/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20240320101652.12873-5-jacopo.mondi@ideasonboard.com>","date":"2024-03-20T10:16:51","name":"[4/4] apps: lc-compliance: Add multi-stream tests","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"cb24052da45fab43bc5ed2a5b668cf713d108922","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19784/mbox/","series":[{"id":4234,"url":"https://patchwork.libcamera.org/api/series/4234/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4234","date":"2024-03-20T10:16:47","name":"apps: lc-compliance: Properties and multi-stream tests","version":1,"mbox":"https://patchwork.libcamera.org/series/4234/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19784/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19784/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 1CABEC32C4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Mar 2024 10:17:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6F3F62D37;\n\tWed, 20 Mar 2024 11:17:10 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8773E62CA8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2024 11:17:05 +0100 (CET)","from localhost.localdomain (unknown\n\t[IPv6:2001:b07:5d2e:52c9:cc1e:e404:491f:e6ea])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A8AC3F1;\n\tWed, 20 Mar 2024 11:16:38 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MNmCxSDM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710929798;\n\tbh=A2obIogv+J4rJzyAy8SkAi5Tjj86Yqz0mk0F770Wilg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=MNmCxSDMg0HtvCTV1qlyvdhKiVNU9zoE2/RT8kMcuKmSW97KmNah/4QaPbUHeRHq/\n\t7cUWPdwxYnTITXgfQvG1vbfUsc/+a3hpiq/G+NHcEBk7CFzXAuVnmUNw5dvY3dqE2x\n\t74LYjBWP2cuKuzzbLu/3pFMePATxSxllh4nIUCPc=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH 4/4] apps: lc-compliance: Add multi-stream tests","Date":"Wed, 20 Mar 2024 11:16:51 +0100","Message-ID":"<20240320101652.12873-5-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.44.0","In-Reply-To":"<20240320101652.12873-1-jacopo.mondi@ideasonboard.com>","References":"<20240320101652.12873-1-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"Add a test suite for testing capture operations with multiple\nstreams.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/apps/lc-compliance/tests/capture_test.cpp | 92 +++++++++++++++++--\n 1 file changed, 85 insertions(+), 7 deletions(-)","diff":"diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp\nindex 3d3cc97791d9..3f4a2f71d10b 100644\n--- a/src/apps/lc-compliance/tests/capture_test.cpp\n+++ b/src/apps/lc-compliance/tests/capture_test.cpp\n@@ -16,6 +16,8 @@\n \n using namespace libcamera;\n \n+namespace {\n+\n const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n const std::vector<std::vector<StreamRole>> ROLES = {\n \t{ StreamRole::Raw },\n@@ -24,6 +26,22 @@ const std::vector<std::vector<StreamRole>> ROLES = {\n \t{ StreamRole::Viewfinder },\n };\n \n+const std::vector<std::array<StreamRole, 2>> MULTIROLES = {\n+\t{ StreamRole::Raw, StreamRole::StillCapture },\n+\t{ StreamRole::Raw, StreamRole::VideoRecording },\n+\t{ StreamRole::StillCapture, StreamRole::VideoRecording },\n+\t{ StreamRole::VideoRecording, StreamRole::VideoRecording },\n+};\n+\n+std::map<StreamRole, std::string> rolesMap = {\n+\t{ StreamRole::Raw, \"Raw\" },\n+\t{ StreamRole::StillCapture, \"StillCapture\" },\n+\t{ StreamRole::VideoRecording, \"VideoRecording\" },\n+\t{ StreamRole::Viewfinder, \"Viewfinder\" }\n+};\n+\n+} /* namespace */\n+\n class SingleStream : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>>\n {\n public:\n@@ -60,13 +78,6 @@ void SingleStream::TearDown()\n \n std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)\n {\n-\tstd::map<StreamRole, std::string> rolesMap = {\n-\t\t{ StreamRole::Raw, \"Raw\" },\n-\t\t{ StreamRole::StillCapture, \"StillCapture\" },\n-\t\t{ StreamRole::VideoRecording, \"VideoRecording\" },\n-\t\t{ StreamRole::Viewfinder, \"Viewfinder\" }\n-\t};\n-\n \tstd::string roleName = rolesMap[std::get<0>(info.param)[0]];\n \tstd::string numRequestsName = std::to_string(std::get<1>(info.param));\n \n@@ -134,3 +145,70 @@ INSTANTIATE_TEST_SUITE_P(CaptureTests,\n \t\t\t testing::Combine(testing::ValuesIn(ROLES),\n \t\t\t\t\t  testing::ValuesIn(NUMREQUESTS)),\n \t\t\t SingleStream::nameParameters);\n+\n+class MultiStream : public testing::TestWithParam<std::tuple<std::array<StreamRole, 2>, int>>\n+{\n+public:\n+\tstatic std::string nameParameters(const testing::TestParamInfo<MultiStream::ParamType> &info);\n+\n+protected:\n+\tvoid SetUp() override;\n+\tvoid TearDown() override;\n+\n+\tstd::shared_ptr<Camera> camera_;\n+};\n+\n+/*\n+ * We use gtest's SetUp() and TearDown() instead of constructor and destructor\n+ * in order to be able to assert on them.\n+ */\n+void MultiStream::SetUp()\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 MultiStream::TearDown()\n+{\n+\tif (!camera_)\n+\t\treturn;\n+\n+\tcamera_->release();\n+\tcamera_.reset();\n+}\n+\n+std::string MultiStream::nameParameters(const testing::TestParamInfo<MultiStream::ParamType> &info)\n+{\n+\tstd::string roleName = rolesMap[std::get<0>(info.param)[0]] + \"_\" +\n+\t\t\t       rolesMap[std::get<0>(info.param)[1]];\n+\tstd::string numRequestsName = std::to_string(std::get<1>(info.param));\n+\n+\treturn roleName + \"_\" + numRequestsName;\n+}\n+\n+/*\n+ * Test multi-stream capture cycles\n+ *\n+ * Makes sure the camera completes the exact number of requests queued. Example\n+ * failure is a camera that completes less requests than the number of requests\n+ * queued.\n+ */\n+TEST_P(MultiStream, Capture)\n+{\n+\tconst auto [roles, numRequests] = GetParam();\n+\n+\tCaptureBalanced capture(camera_);\n+\n+\tcapture.configure(Span<const StreamRole>{ roles });\n+\n+\tcapture.capture(numRequests);\n+}\n+\n+INSTANTIATE_TEST_SUITE_P(MultiCaptureTests,\n+\t\t\t MultiStream,\n+\t\t\t testing::Combine(testing::ValuesIn(MULTIROLES),\n+\t\t\t\t\t  testing::ValuesIn(NUMREQUESTS)),\n+\t\t\t MultiStream::nameParameters);\n","prefixes":["4/4"]}