From patchwork Wed Mar 20 10:16:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19784 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1CABEC32C4 for ; Wed, 20 Mar 2024 10:17:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C6F3F62D37; Wed, 20 Mar 2024 11:17:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MNmCxSDM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8773E62CA8 for ; Wed, 20 Mar 2024 11:17:05 +0100 (CET) Received: from localhost.localdomain (unknown [IPv6:2001:b07:5d2e:52c9:cc1e:e404:491f:e6ea]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A8AC3F1; Wed, 20 Mar 2024 11:16:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710929798; bh=A2obIogv+J4rJzyAy8SkAi5Tjj86Yqz0mk0F770Wilg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MNmCxSDMg0HtvCTV1qlyvdhKiVNU9zoE2/RT8kMcuKmSW97KmNah/4QaPbUHeRHq/ 7cUWPdwxYnTITXgfQvG1vbfUsc/+a3hpiq/G+NHcEBk7CFzXAuVnmUNw5dvY3dqE2x 74LYjBWP2cuKuzzbLu/3pFMePATxSxllh4nIUCPc= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Stefan Klug 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a test suite for testing capture operations with multiple streams. Signed-off-by: Jacopo Mondi Reviewed-by: Stefan Klug --- src/apps/lc-compliance/tests/capture_test.cpp | 92 +++++++++++++++++-- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp index 3d3cc97791d9..3f4a2f71d10b 100644 --- a/src/apps/lc-compliance/tests/capture_test.cpp +++ b/src/apps/lc-compliance/tests/capture_test.cpp @@ -16,6 +16,8 @@ using namespace libcamera; +namespace { + const std::vector NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; const std::vector> ROLES = { { StreamRole::Raw }, @@ -24,6 +26,22 @@ const std::vector> ROLES = { { StreamRole::Viewfinder }, }; +const std::vector> MULTIROLES = { + { StreamRole::Raw, StreamRole::StillCapture }, + { StreamRole::Raw, StreamRole::VideoRecording }, + { StreamRole::StillCapture, StreamRole::VideoRecording }, + { StreamRole::VideoRecording, StreamRole::VideoRecording }, +}; + +std::map rolesMap = { + { StreamRole::Raw, "Raw" }, + { StreamRole::StillCapture, "StillCapture" }, + { StreamRole::VideoRecording, "VideoRecording" }, + { StreamRole::Viewfinder, "Viewfinder" } +}; + +} /* namespace */ + class SingleStream : public testing::TestWithParam, int>> { public: @@ -60,13 +78,6 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo &info) { - std::map rolesMap = { - { StreamRole::Raw, "Raw" }, - { StreamRole::StillCapture, "StillCapture" }, - { StreamRole::VideoRecording, "VideoRecording" }, - { StreamRole::Viewfinder, "Viewfinder" } - }; - std::string roleName = rolesMap[std::get<0>(info.param)[0]]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); @@ -134,3 +145,70 @@ INSTANTIATE_TEST_SUITE_P(CaptureTests, testing::Combine(testing::ValuesIn(ROLES), testing::ValuesIn(NUMREQUESTS)), SingleStream::nameParameters); + +class MultiStream : public testing::TestWithParam, int>> +{ +public: + static std::string nameParameters(const testing::TestParamInfo &info); + +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr camera_; +}; + +/* + * We use gtest's SetUp() and TearDown() instead of constructor and destructor + * in order to be able to assert on them. + */ +void MultiStream::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void MultiStream::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +std::string MultiStream::nameParameters(const testing::TestParamInfo &info) +{ + std::string roleName = rolesMap[std::get<0>(info.param)[0]] + "_" + + rolesMap[std::get<0>(info.param)[1]]; + std::string numRequestsName = std::to_string(std::get<1>(info.param)); + + return roleName + "_" + numRequestsName; +} + +/* + * Test multi-stream capture cycles + * + * Makes sure the camera completes the exact number of requests queued. Example + * failure is a camera that completes less requests than the number of requests + * queued. + */ +TEST_P(MultiStream, Capture) +{ + const auto [roles, numRequests] = GetParam(); + + CaptureBalanced capture(camera_); + + capture.configure(Span{ roles }); + + capture.capture(numRequests); +} + +INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, + MultiStream, + testing::Combine(testing::ValuesIn(MULTIROLES), + testing::ValuesIn(NUMREQUESTS)), + MultiStream::nameParameters);