[{"id":33143,"web_url":"https://patchwork.libcamera.org/comment/33143/","msgid":"<Z5GjporNJ3mBBnIJ@pyrite.rasen.tech>","date":"2025-01-23T02:04:22","subject":"Re: [RFC PATCH v2 15/16] apps: lc-compliance: Add multi-stream tests","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Tue, Jan 14, 2025 at 06:23:00PM +0000, Barnabás Pőcze wrote:\n> Rename the `SingleStream` test to `SimpleCapture`, and extend it\n> to support using multiple roles. And instantiate another test suite\n> from the `SimpleCapture` test that tests multiple streams in one\n> capture session.\n> \n> Co-developed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/apps/lc-compliance/tests/capture_test.cpp | 85 +++++++++++--------\n>  1 file changed, 48 insertions(+), 37 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 147e17019..db1d52fc9 100644\n> --- a/src/apps/lc-compliance/tests/capture_test.cpp\n> +++ b/src/apps/lc-compliance/tests/capture_test.cpp\n> @@ -8,7 +8,7 @@\n>  \n>  #include \"capture.h\"\n>  \n> -#include <iostream>\n> +#include <sstream>\n>  \n>  #include <gtest/gtest.h>\n>  \n> @@ -18,19 +18,10 @@ namespace {\n>  \n>  using namespace libcamera;\n>  \n> -const int NUMREQUESTS[] = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n> -\n> -const StreamRole ROLES[] = {\n> -\tStreamRole::Raw,\n> -\tStreamRole::StillCapture,\n> -\tStreamRole::VideoRecording,\n> -\tStreamRole::Viewfinder\n> -};\n> -\n> -class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>\n> +class SimpleCapture : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>>\n>  {\n>  public:\n> -\tstatic std::string nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info);\n> +\tstatic std::string nameParameters(const testing::TestParamInfo<SimpleCapture::ParamType> &info);\n>  \n>  protected:\n>  \tvoid SetUp() override;\n> @@ -43,7 +34,7 @@ protected:\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 SingleStream::SetUp()\n> +void SimpleCapture::SetUp()\n>  {\n>  \tEnvironment *env = Environment::get();\n>  \n> @@ -52,7 +43,7 @@ void SingleStream::SetUp()\n>  \tASSERT_EQ(camera_->acquire(), 0);\n>  }\n>  \n> -void SingleStream::TearDown()\n> +void SimpleCapture::TearDown()\n>  {\n>  \tif (!camera_)\n>  \t\treturn;\n> @@ -61,19 +52,17 @@ void SingleStream::TearDown()\n>  \tcamera_.reset();\n>  }\n>  \n> -std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)\n> +std::string SimpleCapture::nameParameters(const testing::TestParamInfo<SimpleCapture::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> +\tconst auto &[roles, numRequests] = info.param;\n> +\tstd::ostringstream ss;\n>  \n> -\tstd::string roleName = rolesMap[std::get<0>(info.param)];\n> -\tstd::string numRequestsName = std::to_string(std::get<1>(info.param));\n> +\tfor (StreamRole r : roles)\n> +\t\tss << r << '_';\n>  \n> -\treturn roleName + \"_\" + numRequestsName;\n> +\tss << '_' << numRequests;\n> +\n> +\treturn std::move(ss).str();\n>  }\n>  \n>  /*\n> @@ -83,13 +72,13 @@ std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStre\n>   * failure is a camera that completes less requests than the number of requests\n>   * queued.\n>   */\n> -TEST_P(SingleStream, Capture)\n> +TEST_P(SimpleCapture, Capture)\n>  {\n> -\tauto [role, numRequests] = GetParam();\n> +\tconst auto &[roles, numRequests] = GetParam();\n>  \n>  \tCapture capture(camera_);\n>  \n> -\tcapture.configure(std::array{ role });\n> +\tcapture.configure(roles);\n>  \n>  \tcapture.run(numRequests, numRequests);\n>  }\n> @@ -101,14 +90,14 @@ TEST_P(SingleStream, Capture)\n>   * a camera that does not clean up correctly in its error path but is only\n>   * tested by single-capture applications.\n>   */\n> -TEST_P(SingleStream, CaptureStartStop)\n> +TEST_P(SimpleCapture, CaptureStartStop)\n>  {\n> -\tauto [role, numRequests] = GetParam();\n> +\tconst auto &[roles, numRequests] = GetParam();\n>  \tunsigned int numRepeats = 3;\n>  \n>  \tCapture capture(camera_);\n>  \n> -\tcapture.configure(std::array{ role });\n> +\tcapture.configure(roles);\n>  \n>  \tfor (unsigned int starts = 0; starts < numRepeats; starts++)\n>  \t\tcapture.run(numRequests, numRequests);\n> @@ -121,21 +110,43 @@ TEST_P(SingleStream, CaptureStartStop)\n>   * is a camera that does not handle cancelation of buffers coming back from the\n>   * video device while stopping.\n>   */\n> -TEST_P(SingleStream, UnbalancedStop)\n> +TEST_P(SimpleCapture, UnbalancedStop)\n>  {\n> -\tauto [role, numRequests] = GetParam();\n> +\tconst auto &[roles, numRequests] = GetParam();\n>  \n>  \tCapture capture(camera_);\n>  \n> -\tcapture.configure(std::array{ role });\n> +\tcapture.configure(roles);\n>  \n>  \tcapture.run(numRequests);\n>  }\n>  \n> -INSTANTIATE_TEST_SUITE_P(CaptureTests,\n> -\t\t\t SingleStream,\n> -\t\t\t testing::Combine(testing::ValuesIn(ROLES),\n> +const int NUMREQUESTS[] = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n> +\n> +const std::vector<StreamRole> SINGLEROLES[] = {\n> +\t{ StreamRole::Raw, },\n> +\t{ StreamRole::StillCapture, },\n> +\t{ StreamRole::VideoRecording, },\n> +\t{ StreamRole::Viewfinder, },\n> +};\n> +\n> +const std::vector<StreamRole> 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> +INSTANTIATE_TEST_SUITE_P(SingleStream,\n> +\t\t\t SimpleCapture,\n> +\t\t\t testing::Combine(testing::ValuesIn(SINGLEROLES),\n> +\t\t\t\t\t  testing::ValuesIn(NUMREQUESTS)),\n> +\t\t\t SimpleCapture::nameParameters);\n> +\n> +INSTANTIATE_TEST_SUITE_P(MultiStream,\n> +\t\t\t SimpleCapture,\n> +\t\t\t testing::Combine(testing::ValuesIn(MULTIROLES),\n>  \t\t\t\t\t  testing::ValuesIn(NUMREQUESTS)),\n> -\t\t\t SingleStream::nameParameters);\n> +\t\t\t SimpleCapture::nameParameters);\n>  \n>  } /* namespace */\n> -- \n> 2.48.0\n> \n>","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 D4D94C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jan 2025 02:04:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 082B968559;\n\tThu, 23 Jan 2025 03:04:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C725B68551\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jan 2025 03:04:29 +0100 (CET)","from pyrite.rasen.tech (unknown [IPv6:2603:6081:63f0:60f0::17f2])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 872391E3;\n\tThu, 23 Jan 2025 03:03:25 +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=\"b7jGNJmt\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737597806;\n\tbh=rlrJlh8etY33kfGJpY5+OplVnkl6RjxU8hI6/aGdEfE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=b7jGNJmt3NWEt7g+iCEAYYRvg53CIL0e3QiKCFQrVbOK3pxfItH0rmYIzoje4oKVQ\n\t579pJ6r6jD6OrzCrRhJnAJ883SfjuLwclXjE7r5oxxVJamCxve7WLoBCmut5paLE1O\n\tc9F0WbwlDqsHVbZQGICuPQuH3gSSGGC+MiPfBkgI=","Date":"Wed, 22 Jan 2025 21:04:22 -0500","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 15/16] apps: lc-compliance: Add multi-stream tests","Message-ID":"<Z5GjporNJ3mBBnIJ@pyrite.rasen.tech>","References":"<20250114182143.1773762-1-pobrn@protonmail.com>\n\t<20250114182143.1773762-16-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250114182143.1773762-16-pobrn@protonmail.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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]