{"id":13476,"url":"https://patchwork.libcamera.org/api/patches/13476/?format=json","web_url":"https://patchwork.libcamera.org/patch/13476/","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":"<20210824195636.1110845-16-nfraprado@collabora.com>","date":"2021-08-24T19:56:34","name":"[libcamera-devel,v8,15/17] lc-compliance: Add test to queue more requests than hardware depth","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"81d7a0bd8c70301e6d641d1e52283a72414c7935","submitter":{"id":84,"url":"https://patchwork.libcamera.org/api/people/84/?format=json","name":"Nícolas F. R. A. Prado","email":"nfraprado@collabora.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13476/mbox/","series":[{"id":2389,"url":"https://patchwork.libcamera.org/api/series/2389/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2389","date":"2021-08-24T19:56:19","name":"lc-compliance: Add test to queue more requests than hardware depth","version":8,"mbox":"https://patchwork.libcamera.org/series/2389/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13476/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13476/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 1002AC324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 Aug 2021 19:58:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3470C688A3;\n\tTue, 24 Aug 2021 21:57:55 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C16CB60505\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Aug 2021 21:57:54 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nfraprado) with ESMTPSA id 968AF1F43389"],"From":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 24 Aug 2021 16:56:34 -0300","Message-Id":"<20210824195636.1110845-16-nfraprado@collabora.com>","X-Mailer":"git-send-email 2.33.0","In-Reply-To":"<20210824195636.1110845-1-nfraprado@collabora.com>","References":"<20210824195636.1110845-1-nfraprado@collabora.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v8 15/17] lc-compliance: Add test to queue\n\tmore requests than hardware depth","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":"kernel@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?=\n\t<andrealmeid@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A pipeline handler should be able to handle an arbitrary number of\nsimultaneous requests by submitting what it can to the video device and\nqueuing the rest internally until resources are available. This isn't\ncurrently done by some pipeline handlers however [1].\n\nAdd a new test to lc-compliance that submits a lot of requests at once\nto check if the pipeline handler is behaving well in this situation.\n\n[1] https://bugs.libcamera.org/show_bug.cgi?id=24\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n\n---\n\n(no changes since v6)\n\nChanges in v6:\n- Made MAX_SIMULTANEOUS_REQUESTS a constexpr\n\nChanges in v5:\n- Updated to use googletest, and CameraHolder and roleToString from previous\n  patches\n\n src/lc-compliance/capture_test.cpp   | 45 ++++++++++++++++++++++++++++\n src/lc-compliance/simple_capture.cpp | 29 ++++++++++++++++++\n src/lc-compliance/simple_capture.h   | 11 +++++++\n 3 files changed, 85 insertions(+)","diff":"diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp\nindex 40242fbbc0ba..2e495810e40f 100644\n--- a/src/lc-compliance/capture_test.cpp\n+++ b/src/lc-compliance/capture_test.cpp\n@@ -18,6 +18,8 @@ using namespace libcamera;\n const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n const std::vector<StreamRole> ROLES = { Raw, StillCapture, VideoRecording, Viewfinder };\n \n+static constexpr unsigned int MAX_SIMULTANEOUS_REQUESTS = 8;\n+\n static const std::string &roleToString(const StreamRole &role)\n {\n \tstatic const std::map<StreamRole, std::string> rolesMap = {\n@@ -54,12 +56,37 @@ void SingleStream::TearDown()\n \treleaseCamera();\n }\n \n+class RoleParametrizedTest : public testing::TestWithParam<StreamRole>, public CameraHolder\n+{\n+public:\n+\tstatic std::string nameParameters(const testing::TestParamInfo<RoleParametrizedTest::ParamType> &info);\n+\n+protected:\n+\tvoid SetUp() override;\n+\tvoid TearDown() override;\n+};\n+\n+void RoleParametrizedTest::SetUp()\n+{\n+\tacquireCamera();\n+}\n+\n+void RoleParametrizedTest::TearDown()\n+{\n+\treleaseCamera();\n+}\n+\n std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)\n {\n \treturn roleToString(std::get<0>(info.param)) + \"_\" +\n \t       std::to_string(std::get<1>(info.param));\n }\n \n+std::string RoleParametrizedTest::nameParameters(const testing::TestParamInfo<RoleParametrizedTest::ParamType> &info)\n+{\n+\treturn roleToString(info.param);\n+}\n+\n /*\n  * Test single capture cycles\n  *\n@@ -122,8 +149,26 @@ TEST_P(SingleStream, UnbalancedStop)\n \tcapture.capture(numRequests);\n }\n \n+TEST_P(RoleParametrizedTest, Overflow)\n+{\n+\tauto role = GetParam();\n+\n+\tSimpleCaptureOverflow capture(camera_);\n+\n+\tcapture.configure(role);\n+\n+\tcapture.allocateBuffers(MAX_SIMULTANEOUS_REQUESTS);\n+\n+\tcapture.capture();\n+}\n+\n INSTANTIATE_TEST_SUITE_P(CaptureTests,\n \t\t\t SingleStream,\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+INSTANTIATE_TEST_SUITE_P(CaptureTests,\n+\t\t\t RoleParametrizedTest,\n+\t\t\t testing::ValuesIn(ROLES),\n+\t\t\t RoleParametrizedTest::nameParameters);\ndiff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\nindex e4f70974dd2c..d4805ff3403c 100644\n--- a/src/lc-compliance/simple_capture.cpp\n+++ b/src/lc-compliance/simple_capture.cpp\n@@ -206,3 +206,32 @@ void SimpleCaptureUnbalanced::requestComplete(Request *request)\n \tif (camera_->queueRequest(request))\n \t\tloop_->exit(-EINVAL);\n }\n+\n+/* SimpleCaptureOverflow */\n+\n+SimpleCaptureOverflow::SimpleCaptureOverflow(std::shared_ptr<Camera> camera)\n+\t: SimpleCapture(camera)\n+{\n+}\n+\n+void SimpleCaptureOverflow::capture()\n+{\n+\tstart();\n+\n+\tStream *stream = config_->at(0).stream();\n+\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers = allocator_->buffers(stream);\n+\n+\tcaptureCount_ = 0;\n+\tcaptureLimit_ = buffers.size();\n+\n+\tqueueRequests(stream, buffers);\n+\n+\trunCaptureSession();\n+\n+\tASSERT_EQ(captureCount_, captureLimit_);\n+}\n+\n+void SimpleCaptureOverflow::requestComplete([[maybe_unused]] Request *request)\n+{\n+\tcaptureCompleted();\n+}\ndiff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\nindex 8a6db2a355f6..9d86fb32e9e0 100644\n--- a/src/lc-compliance/simple_capture.h\n+++ b/src/lc-compliance/simple_capture.h\n@@ -69,4 +69,15 @@ private:\n \tvoid requestComplete(libcamera::Request *request) override;\n };\n \n+class SimpleCaptureOverflow : public SimpleCapture\n+{\n+public:\n+\tSimpleCaptureOverflow(std::shared_ptr<libcamera::Camera> camera);\n+\n+\tvoid capture();\n+\n+private:\n+\tvoid requestComplete(libcamera::Request *request) override;\n+};\n+\n #endif /* __LC_COMPLIANCE_SIMPLE_CAPTURE_H__ */\n","prefixes":["libcamera-devel","v8","15/17"]}