[{"id":28985,"web_url":"https://patchwork.libcamera.org/comment/28985/","msgid":"<20240315130359.tklrmsbortribrbj@jasper>","date":"2024-03-15T13:03:59","subject":"Re: [libcamera-devel] [PATCH v3 7/7] apps: lc-compliance: Add\n\tmulti-stream tests","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Jacopo,\n\nthanks for the patch.\n\nOn Sat, Dec 30, 2023 at 05:29:12PM +0100, Jacopo Mondi wrote:\n> Add a test suite for testing capture operations with multiple\n> streams.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nLooks good to me.\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> \n\nCheers,\nStefan\n\n> ---\n>  src/apps/lc-compliance/tests/capture_test.cpp | 92 +++++++++++++++++--\n>  1 file changed, 85 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp\n> index 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);","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 827B1BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Mar 2024 13:04:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7FDDC62C8D;\n\tFri, 15 Mar 2024 14:04:04 +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 BE97C61C65\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Mar 2024 14:04:02 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:c477:4921:2179:342c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AAEA0667;\n\tFri, 15 Mar 2024 14:03: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=\"GVrb8JYi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710507818;\n\tbh=ezkO/HWYfxirqunMfrfGocvM+QFp1qCERRFLUJ658rE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GVrb8JYiQM6B6C/sFrXo4WKajMxYkxk9JiD1QZ81m5Cu6MpcjaLoDmOFGVALbQXav\n\tfKq3fEej5319i63dzgxFM8fwX2onMiqbdb9f40edhoNpx+IS4yGHaa+qKjnCIIJMi5\n\tOqWVTDtN19fy/Bx/sFiLLhR7MCYfLNZakWVq0QXM=","Date":"Fri, 15 Mar 2024 14:03:59 +0100","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 7/7] apps: lc-compliance: Add\n\tmulti-stream tests","Message-ID":"<20240315130359.tklrmsbortribrbj@jasper>","References":"<20231230162912.827669-1-jacopo.mondi@ideasonboard.com>\n\t<20231230162912.827669-8-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231230162912.827669-8-jacopo.mondi@ideasonboard.com>","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]