From patchwork Wed May 29 15:43:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20119 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 06204BDE6B for ; Wed, 29 May 2024 15:43:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F0B19634BB; Wed, 29 May 2024 17:43:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PY90ObSG"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9888E6347E for ; Wed, 29 May 2024 17:43:54 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E6671149B for ; Wed, 29 May 2024 17:43:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1716997431; bh=rQX9K/c8x4MK/S49cTPA1lVubY9prEhgcIrdoHvNTaQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PY90ObSGxBjZSXA4X1Qdtomg5eH4kGec+X0/ha0qiN0jQ3DIxQgn66AfaY+CkY9AF vL4/x/GTtasePDxYWCSHSBNpEX+Y8NYD84fNZZYeoA1o+1Mi9BRKsZ9s8FYpaLOs1h WneLzHZ9Qku9NWdVMfMP2M0AgvO9G1P0viAuUQZk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 1/6] test: camera: Increase timeout for vimc capture tests Date: Wed, 29 May 2024 18:43:36 +0300 Message-ID: <20240529154341.10426-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240529154341.10426-1-laurent.pinchart@ideasonboard.com> References: <20240529154341.10426-1-laurent.pinchart@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" On slower machines, a 1s timeout to capture frames with vimc can be too short and cause test failures. Make the timeout proportional to the number of frames expected to be captured, using a conservative low estimate of the frame rate at 2fps. By itself, that change could increase the test time quite substantially on fast platforms, so break from the capture loop as soon as we capture enough frames. To do so, interrupt the dispatcher at every request completion, or it will only get interrupted after the timer times out. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Daniel Scally --- test/camera/buffer_import.cpp | 21 +++++++++++++++------ test/camera/capture.cpp | 22 ++++++++++++++-------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp index 9288400474a7..815d1caed9f3 100644 --- a/test/camera/buffer_import.cpp +++ b/test/camera/buffer_import.cpp @@ -63,6 +63,8 @@ protected: request->reuse(); request->addBuffer(stream, buffer); camera_->queueRequest(request); + + dispatcher_->interrupt(); } int init() override @@ -76,6 +78,8 @@ protected: return TestFail; } + dispatcher_ = Thread::current()->eventDispatcher(); + return TestPass; } @@ -133,17 +137,20 @@ protected: } } - EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); + const unsigned int nFrames = cfg.bufferCount * 2; Timer timer; - timer.start(1000ms); - while (timer.isRunning()) - dispatcher->processEvents(); + timer.start(500ms * nFrames); + while (timer.isRunning()) { + dispatcher_->processEvents(); + if (completeRequestsCount_ > nFrames) + break; + } - if (completeRequestsCount_ < cfg.bufferCount * 2) { + if (completeRequestsCount_ < nFrames) { std::cout << "Failed to capture enough frames (got " << completeRequestsCount_ << " expected at least " - << cfg.bufferCount * 2 << ")" << std::endl; + << nFrames << ")" << std::endl; return TestFail; } @@ -161,6 +168,8 @@ protected: } private: + EventDispatcher *dispatcher_; + std::vector> requests_; unsigned int completeBuffersCount_; diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp index de824083dfed..8766fb194ee5 100644 --- a/test/camera/capture.cpp +++ b/test/camera/capture.cpp @@ -59,6 +59,8 @@ protected: request->reuse(); request->addBuffer(stream, buffer); camera_->queueRequest(request); + + dispatcher_->interrupt(); } int init() override @@ -73,6 +75,7 @@ protected: } allocator_ = new FrameBufferAllocator(camera_); + dispatcher_ = Thread::current()->eventDispatcher(); return TestPass; } @@ -135,19 +138,20 @@ protected: } } - EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); + unsigned int nFrames = allocator_->buffers(stream).size() * 2; Timer timer; - timer.start(1000ms); - while (timer.isRunning()) - dispatcher->processEvents(); + timer.start(500ms * nFrames); + while (timer.isRunning()) { + dispatcher_->processEvents(); + if (completeRequestsCount_ > nFrames) + break; + } - unsigned int nbuffers = allocator_->buffers(stream).size(); - - if (completeRequestsCount_ < nbuffers * 2) { + if (completeRequestsCount_ < nFrames) { cout << "Failed to capture enough frames (got " << completeRequestsCount_ << " expected at least " - << nbuffers * 2 << ")" << endl; + << nFrames * 2 << ")" << endl; return TestFail; } @@ -164,6 +168,8 @@ protected: return TestPass; } + EventDispatcher *dispatcher_; + std::vector> requests_; std::unique_ptr config_;