[{"id":29657,"web_url":"https://patchwork.libcamera.org/comment/29657/","msgid":"<171699098312.191612.10284842341462515953@ping.linuxembedded.co.uk>","date":"2024-05-29T13:56:23","subject":"Re: [PATCH v1 1/6] test: camera: Increase timeout for vimc capture\n\ttests","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-04-25 00:42:19)\n> On slower machines, a 1s timeout to capture frames with vimc can be too\n> short and cause test failures. Make the timeout proportional to the\n> number of frames expected to be captured, using a conservative low\n> estimate of the frame rate at 2fps.\n> \n> By itself, that change could increase the test time quite substantially\n> on fast platforms, so break from the capture loop as soon as we capture\n> enough frames. To do so, interrupt the dispatcher at every request\n> completion, or it will only get interrupted after the timer times out.\n\nSounds good to me.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  test/camera/buffer_import.cpp | 21 +++++++++++++++------\n>  test/camera/capture.cpp       | 22 ++++++++++++++--------\n>  2 files changed, 29 insertions(+), 14 deletions(-)\n> \n> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> index 9288400474a7..815d1caed9f3 100644\n> --- a/test/camera/buffer_import.cpp\n> +++ b/test/camera/buffer_import.cpp\n> @@ -63,6 +63,8 @@ protected:\n>                 request->reuse();\n>                 request->addBuffer(stream, buffer);\n>                 camera_->queueRequest(request);\n> +\n> +               dispatcher_->interrupt();\n>         }\n>  \n>         int init() override\n> @@ -76,6 +78,8 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> +               dispatcher_ = Thread::current()->eventDispatcher();\n> +\n>                 return TestPass;\n>         }\n>  \n> @@ -133,17 +137,20 @@ protected:\n>                         }\n>                 }\n>  \n> -               EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> +               const unsigned int nFrames = cfg.bufferCount * 2;\n>  \n>                 Timer timer;\n> -               timer.start(1000ms);\n> -               while (timer.isRunning())\n> -                       dispatcher->processEvents();\n> +               timer.start(500ms * nFrames);\n> +               while (timer.isRunning()) {\n> +                       dispatcher_->processEvents();\n> +                       if (completeRequestsCount_ > nFrames)\n> +                               break;\n> +               }\n>  \n> -               if (completeRequestsCount_ < cfg.bufferCount * 2) {\n> +               if (completeRequestsCount_ < nFrames) {\n>                         std::cout << \"Failed to capture enough frames (got \"\n>                                   << completeRequestsCount_ << \" expected at least \"\n> -                                 << cfg.bufferCount * 2 << \")\" << std::endl;\n> +                                 << nFrames << \")\" << std::endl;\n>                         return TestFail;\n>                 }\n>  \n> @@ -161,6 +168,8 @@ protected:\n>         }\n>  \n>  private:\n> +       EventDispatcher *dispatcher_;\n> +\n>         std::vector<std::unique_ptr<Request>> requests_;\n>  \n>         unsigned int completeBuffersCount_;\n> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> index de824083dfed..8766fb194ee5 100644\n> --- a/test/camera/capture.cpp\n> +++ b/test/camera/capture.cpp\n> @@ -59,6 +59,8 @@ protected:\n>                 request->reuse();\n>                 request->addBuffer(stream, buffer);\n>                 camera_->queueRequest(request);\n> +\n> +               dispatcher_->interrupt();\n>         }\n>  \n>         int init() override\n> @@ -73,6 +75,7 @@ protected:\n>                 }\n>  \n>                 allocator_ = new FrameBufferAllocator(camera_);\n> +               dispatcher_ = Thread::current()->eventDispatcher();\n>  \n>                 return TestPass;\n>         }\n> @@ -135,19 +138,20 @@ protected:\n>                         }\n>                 }\n>  \n> -               EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> +               unsigned int nFrames = allocator_->buffers(stream).size() * 2;\n>  \n>                 Timer timer;\n> -               timer.start(1000ms);\n> -               while (timer.isRunning())\n> -                       dispatcher->processEvents();\n> +               timer.start(500ms * nFrames);\n> +               while (timer.isRunning()) {\n> +                       dispatcher_->processEvents();\n> +                       if (completeRequestsCount_ > nFrames)\n> +                               break;\n> +               }\n>  \n> -               unsigned int nbuffers = allocator_->buffers(stream).size();\n> -\n> -               if (completeRequestsCount_ < nbuffers * 2) {\n> +               if (completeRequestsCount_ < nFrames) {\n>                         cout << \"Failed to capture enough frames (got \"\n>                              << completeRequestsCount_ << \" expected at least \"\n> -                            << nbuffers * 2 << \")\" << endl;\n> +                            << nFrames * 2 << \")\" << endl;\n>                         return TestFail;\n>                 }\n>  \n> @@ -164,6 +168,8 @@ protected:\n>                 return TestPass;\n>         }\n>  \n> +       EventDispatcher *dispatcher_;\n> +\n>         std::vector<std::unique_ptr<Request>> requests_;\n>  \n>         std::unique_ptr<CameraConfiguration> config_;\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 76E9DBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 May 2024 13:56:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D64D634B6;\n\tWed, 29 May 2024 15:56:27 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 725966347E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 15:56:26 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B4B83B53;\n\tWed, 29 May 2024 15:56:22 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"JvBc/MiG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716990982;\n\tbh=imK47o3hbsXsxWvO9RzpcRvlw1yMMbbRO1X6DpWOVHI=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=JvBc/MiGonb9gQspKcVrZpaMSo0VRlSfKoiU5FPGogZjhJ/2kC97bacbk6eaIKmwy\n\tDGTEP1pRb0C7v1yRt6bloqKBh12arMHh+DLEc2NpXIcUteyNdxSRCRHotXnPNFsKfS\n\tiPfQGe5ow2yHPttc6sIBQXfl8jge/qVRBRzs05tI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240424234224.9658-2-laurent.pinchart@ideasonboard.com>","References":"<20240424234224.9658-1-laurent.pinchart@ideasonboard.com>\n\t<20240424234224.9658-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH v1 1/6] test: camera: Increase timeout for vimc capture\n\ttests","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 29 May 2024 14:56:23 +0100","Message-ID":"<171699098312.191612.10284842341462515953@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]