From patchwork Sat Dec 30 16:29:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19352 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 70FA7BE175 for ; Sat, 30 Dec 2023 16:29:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D166A62B5B; Sat, 30 Dec 2023 17:29:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953774; bh=L1nZBbVzw9eXEQvoRnyKzXlyi4n9eV24kx6uDm1Hymc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=S4HDtWojIBJawPbhHd9+DxnxQfkfH8yFHededMtlgdET7dzSvFDTfCiyVlpg+oGOQ v2t6oLAGpU26BYcUDUCtZnGUBTEgepOB18f22JZ6TtKBeF3h/OG5BYaswZqBT7cfJr fP1cnVzzuIUbNscF91bYFTW+kgZrtWTftjKCdoNW/5YmMcI0TBGg3KrlE3Cv94PR6u wuIwOj61H3siqr8WTUNyxcS57baJRGTXfWGTm9w+c1TXxsLffCD8qBtn8rEFNGW6ol Iltj8cNixNpQUVy+HFqQqt52E8Q8fm73qhyNdSDMBCIv+Aqxlmj2yOwv3s4pMDtIPb mAZ8VqUNcW43Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07FA961D89 for ; Sat, 30 Dec 2023 17:29:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sR9tu5ss"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 559548BE; Sat, 30 Dec 2023 17:28:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953714; bh=L1nZBbVzw9eXEQvoRnyKzXlyi4n9eV24kx6uDm1Hymc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sR9tu5ssA2IxF+zClwihGrulnad42aKxS91KnUzqwKZlf/YTWHYF39SuhKCK0YBe3 57+XZfvK7Y+8xRmoGLn09sGp1dMRTpM/ZZ+i+PRleiW36Fakb+04HoXrFIudNbiPuN /3c24BmbbZE0mlKr4qii91MNXGzfgWsSpCF6J0Lg= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:06 +0100 Message-ID: <20231230162912.827669-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/7] apps: lc-compliance: Fix source file ordering in meson.build 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nícolas F. R. A. Prado The capture_test.cpp file was added in the source list of meson in the wrong place. Fix it so the list is alphabetically sorted. Signed-off-by: Nícolas F. R. A. Prado Reviewed-by: Paul Elder Signed-off-by: Paul Elder Reviewed-by: Umang Jain --- src/apps/lc-compliance/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index dd7b73abbcef..2f07a50f171b 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -11,10 +11,10 @@ endif lc_compliance_enabled = true lc_compliance_sources = files([ + 'capture_test.cpp', 'environment.cpp', 'main.cpp', 'simple_capture.cpp', - 'capture_test.cpp', ]) lc_compliance = executable('lc-compliance', lc_compliance_sources, From patchwork Sat Dec 30 16:29:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19353 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 B412DC3295 for ; Sat, 30 Dec 2023 16:29:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A91862B61; Sat, 30 Dec 2023 17:29:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953776; bh=qneqtV9quvOjU67kpSxwhaJzfrt4bucT1eOPM/MgTvQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dd3WKFGqqIoqD7WFWFBK6+9XGNR4Jyjbi4I2ejuWTzmAbjR2782Zjr1yMCSWCNLOb QYu59nG/WCW2304/Q2H6G3lLYjPBQZ0Ixh5i8jXD83PrzQZ4ADRAF63RQP+piM51Tg bqqauOKJA+giTobhqI7RlWWZzDupkLi1/00SrkJmx71YaNvzz+LOxomX+X9GiLCRGG iH6b3K61+g5NHeB1NQUc8Vg9TtUHxy3TGZLj8dkAMgrUVUrAgKzn+fmTijLA3u7iq/ DP8qZQZhxWr6QpL4w3+9kRQs+fy3WNnrSUQz0XlSQUdJ1fhnb3+C6l32FFFwDyZQIF LsrKWeyddTfWg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C9AF62B40 for ; Sat, 30 Dec 2023 17:29:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VOXkWDbw"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E1CA9B6; Sat, 30 Dec 2023 17:28:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953715; bh=qneqtV9quvOjU67kpSxwhaJzfrt4bucT1eOPM/MgTvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOXkWDbwUe/yXTBcdhYoQfeLDIvOtnK/3lBpWdRIEzhw79LLQx1FFzuTQhCdldP/p ADk279NiTQrlbFEDyDsKJJPCH0AODbH1LGdL+xKHHjfPn8/hFAonF5pjyyKnP4R9wb 2yqHsHsjDaAn5WFhHKd9qWgoPAj+ZAg993bTN5NE= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:07 +0100 Message-ID: <20231230162912.827669-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/7] apps: lc-compliance: Check that requests complete successfully 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nícolas F. R. A. Prado When a request fails to queue it is completed but with its status set to RequestCancelled. Add a check in the requestComplete callback to make sure that the request was completed successfully. For the SimpleCaptureUnbalanced test we need to do this check only if the capture isn't over yet, otherwise the few extra requests that get cancelled at the end, which is the normal behavior, will make the test fail. Signed-off-by: Nícolas F. R. A. Prado Reviewed-by: Paul Elder Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham --- src/apps/lc-compliance/simple_capture.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp index cf4d7cf38bc3..e22a339c4e1c 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/simple_capture.cpp @@ -127,6 +127,9 @@ int SimpleCaptureBalanced::queueRequest(Request *request) void SimpleCaptureBalanced::requestComplete(Request *request) { + EXPECT_EQ(request->status(), Request::Status::RequestComplete) + << "Request didn't complete successfully"; + captureCount_++; if (captureCount_ >= captureLimit_) { loop_->exit(0); @@ -184,6 +187,9 @@ void SimpleCaptureUnbalanced::requestComplete(Request *request) return; } + EXPECT_EQ(request->status(), Request::Status::RequestComplete) + << "Request didn't complete successfully"; + request->reuse(Request::ReuseBuffers); if (camera_->queueRequest(request)) loop_->exit(-EINVAL); From patchwork Sat Dec 30 16:29:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19354 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 72BE9BE175 for ; Sat, 30 Dec 2023 16:29:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4D32E62B64; Sat, 30 Dec 2023 17:29:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953777; bh=jT0KPQWhn4IpHg9WXjtMDYPB0JLx18I5UCCMc6EvPug=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=HDOWb6UncHIPWPKv8drxrvedzlQSm/rQz6INUG5D8pY4X90F3nuyXdEIpoCPh5G0R gi9xve0CaZ/yHWeH3GbQpd6HMRyYjlfiPVqXc3kpf29t/mabGgD6KHEf+tdHVX2V0C bo0w/vKED6rbURTf4yyqQ+yfqWPSxeDHesjhPueJ6zk/lth5SY7pI1XcF/ktGa2udS zo7a+DIYTa7TEY4vfseQGKyUDODwZQyG+Gqaj3DjWxf9OnY2/g/P7jEwbzxYk12lPG UbGStBFhTJjM7wsfxpU8DXa/8uOUvM7sKWzA8WBtZLrwMV4yjCK/C3VL2tRP4xrmUC lUeB6P27nGhYg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E162E62B4A for ; Sat, 30 Dec 2023 17:29:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="R7+sGElc"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A792842; Sat, 30 Dec 2023 17:28:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953715; bh=jT0KPQWhn4IpHg9WXjtMDYPB0JLx18I5UCCMc6EvPug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R7+sGElc6Tbz6ZZ82yk7b4noS+DIWB+wq0OzCJnaXvghjBVYbIMS4WU3OY70m9qi9 x69xU8kL6J4RafwF41z1Rco1EsJZXowY69+MNcZI6dE+xN4oMMYRfp0b9YMrS+Hih3 KqZmPjzmVcHYzLnC+VMhaJpOBV11cZU0hScVFGtQ= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:08 +0100 Message-ID: <20231230162912.827669-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/7] apps: lc-compliance: Fix typo in comment 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Fix a small typo in a comment. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/apps/lc-compliance/simple_capture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp index e22a339c4e1c..545b444c2593 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/simple_capture.cpp @@ -95,7 +95,7 @@ void SimpleCaptureBalanced::capture(unsigned int numRequests) captureCount_ = 0; captureLimit_ = numRequests; - /* Queue the recommended number of reqeuests. */ + /* Queue the recommended number of requests. */ for (const std::unique_ptr &buffer : buffers) { std::unique_ptr request = camera_->createRequest(); ASSERT_TRUE(request) << "Can't create request"; @@ -158,7 +158,7 @@ void SimpleCaptureUnbalanced::capture(unsigned int numRequests) captureCount_ = 0; captureLimit_ = numRequests; - /* Queue the recommended number of reqeuests. */ + /* Queue the recommended number of requests. */ for (const std::unique_ptr &buffer : buffers) { std::unique_ptr request = camera_->createRequest(); ASSERT_TRUE(request) << "Can't create request"; From patchwork Sat Dec 30 16:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19355 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 0C5D5C32BC for ; Sat, 30 Dec 2023 16:29:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 464E362B5D; Sat, 30 Dec 2023 17:29:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953778; bh=wAxlakPy353QsBJfhvYiGepVDOexcUVy88tbj9z6DxY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dEdIDRYcxqPSpBbadKlGSe34Y8Q5EywTVugPcPGucNWI8tiB7NZOBYBU7nvJR0m8Y tLQwGm8ZdsVYWHI/dI55OgxWtFBQwz2C5CE1OvOm/MhqJq8Ckj53FAJrt/68GZUR2+ 1ufkiSw00khugAH/RAJw2AeZ4PSqni7Z46StaXrTErdVj2LQl8an6Fd60ow8eKUVlH qG6Dw3Y54180V3zH+UuyW9d+LIP7ZBkz2wAMBg2Lc4w75IcUdUSvh9KNXVOTUDmaJA tRyIshL821or4fJIFStuQsdaF1aKZse8hTtxcmxidzitfJ0v8DFYPeAeUFM9AFlVPh D3zMea0oD205w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51A0A62B40 for ; Sat, 30 Dec 2023 17:29:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OJFPY231"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F01C9C8A; Sat, 30 Dec 2023 17:28:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953716; bh=wAxlakPy353QsBJfhvYiGepVDOexcUVy88tbj9z6DxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OJFPY231S0FiB1vK+Rl6pY6ggmQ2TYjRzMD66ePvNWm/nKTbPOCdLqi5QZVE4m0G0 plb6VzNb+TXfZtw16HLjVwh/4zG0+NFdCzATz56PuG9q/YALCv5wsoRZBefJOH8fUh GsMtyCFdFBZMVCC6lNiQQHYMRCWT+yeR19ihWncA= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:09 +0100 Message-ID: <20231230162912.827669-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/7] apps: lc-compliance: Re-organize source directory 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Before adding more tests and more helper classes to lc-compliance, reorganize the source tree to split test and helpers in two separate directories. While at it, rename the 'SimpleCapture' class and its derived classes to just 'Capture'. Rename the source files accordingly. Re-sort headers inclusions to please checkstyle.py too. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Stefan Klug Tested-by: Stefan Klug --- .../capture.cpp} | 38 +++++++++---------- .../{simple_capture.h => helpers/capture.h} | 14 +++---- src/apps/lc-compliance/meson.build | 10 ++++- .../{ => tests}/capture_test.cpp | 9 +++-- 4 files changed, 39 insertions(+), 32 deletions(-) rename src/apps/lc-compliance/{simple_capture.cpp => helpers/capture.cpp} (81%) rename src/apps/lc-compliance/{simple_capture.h => helpers/capture.h} (76%) rename src/apps/lc-compliance/{ => tests}/capture_test.cpp (95%) diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp similarity index 81% rename from src/apps/lc-compliance/simple_capture.cpp rename to src/apps/lc-compliance/helpers/capture.cpp index 545b444c2593..5aab973f0392 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/helpers/capture.cpp @@ -5,24 +5,24 @@ * simple_capture.cpp - Simple capture helper */ -#include +#include "capture.h" -#include "simple_capture.h" +#include using namespace libcamera; -SimpleCapture::SimpleCapture(std::shared_ptr camera) +Capture::Capture(std::shared_ptr camera) : loop_(nullptr), camera_(camera), allocator_(std::make_unique(camera)) { } -SimpleCapture::~SimpleCapture() +Capture::~Capture() { stop(); } -void SimpleCapture::configure(StreamRole role) +void Capture::configure(StreamRole role) { config_ = camera_->generateConfiguration({ role }); @@ -42,7 +42,7 @@ void SimpleCapture::configure(StreamRole role) } } -void SimpleCapture::start() +void Capture::start() { Stream *stream = config_->at(0).stream(); int count = allocator_->allocate(stream); @@ -50,12 +50,12 @@ void SimpleCapture::start() ASSERT_GE(count, 0) << "Failed to allocate buffers"; EXPECT_EQ(count, config_->at(0).bufferCount) << "Allocated less buffers than expected"; - camera_->requestCompleted.connect(this, &SimpleCapture::requestComplete); + camera_->requestCompleted.connect(this, &Capture::requestComplete); ASSERT_EQ(camera_->start(), 0) << "Failed to start camera"; } -void SimpleCapture::stop() +void Capture::stop() { if (!config_ || !allocator_->allocated()) return; @@ -69,14 +69,14 @@ void SimpleCapture::stop() allocator_->free(stream); } -/* SimpleCaptureBalanced */ +/* CaptureBalanced */ -SimpleCaptureBalanced::SimpleCaptureBalanced(std::shared_ptr camera) - : SimpleCapture(camera) +CaptureBalanced::CaptureBalanced(std::shared_ptr camera) + : Capture(camera) { } -void SimpleCaptureBalanced::capture(unsigned int numRequests) +void CaptureBalanced::capture(unsigned int numRequests) { start(); @@ -116,7 +116,7 @@ void SimpleCaptureBalanced::capture(unsigned int numRequests) ASSERT_EQ(captureCount_, captureLimit_); } -int SimpleCaptureBalanced::queueRequest(Request *request) +int CaptureBalanced::queueRequest(Request *request) { queueCount_++; if (queueCount_ > captureLimit_) @@ -125,7 +125,7 @@ int SimpleCaptureBalanced::queueRequest(Request *request) return camera_->queueRequest(request); } -void SimpleCaptureBalanced::requestComplete(Request *request) +void CaptureBalanced::requestComplete(Request *request) { EXPECT_EQ(request->status(), Request::Status::RequestComplete) << "Request didn't complete successfully"; @@ -141,14 +141,14 @@ void SimpleCaptureBalanced::requestComplete(Request *request) loop_->exit(-EINVAL); } -/* SimpleCaptureUnbalanced */ +/* CaptureUnbalanced */ -SimpleCaptureUnbalanced::SimpleCaptureUnbalanced(std::shared_ptr camera) - : SimpleCapture(camera) +CaptureUnbalanced::CaptureUnbalanced(std::shared_ptr camera) + : Capture(camera) { } -void SimpleCaptureUnbalanced::capture(unsigned int numRequests) +void CaptureUnbalanced::capture(unsigned int numRequests) { start(); @@ -179,7 +179,7 @@ void SimpleCaptureUnbalanced::capture(unsigned int numRequests) ASSERT_EQ(status, 0); } -void SimpleCaptureUnbalanced::requestComplete(Request *request) +void CaptureUnbalanced::requestComplete(Request *request) { captureCount_++; if (captureCount_ >= captureLimit_) { diff --git a/src/apps/lc-compliance/simple_capture.h b/src/apps/lc-compliance/helpers/capture.h similarity index 76% rename from src/apps/lc-compliance/simple_capture.h rename to src/apps/lc-compliance/helpers/capture.h index 2911d6019923..0574ab1c7ac7 100644 --- a/src/apps/lc-compliance/simple_capture.h +++ b/src/apps/lc-compliance/helpers/capture.h @@ -13,14 +13,14 @@ #include "../common/event_loop.h" -class SimpleCapture +class Capture { public: void configure(libcamera::StreamRole role); protected: - SimpleCapture(std::shared_ptr camera); - virtual ~SimpleCapture(); + Capture(std::shared_ptr camera); + virtual ~Capture(); void start(); void stop(); @@ -35,10 +35,10 @@ protected: std::vector> requests_; }; -class SimpleCaptureBalanced : public SimpleCapture +class CaptureBalanced : public Capture { public: - SimpleCaptureBalanced(std::shared_ptr camera); + CaptureBalanced(std::shared_ptr camera); void capture(unsigned int numRequests); @@ -51,10 +51,10 @@ private: unsigned int captureLimit_; }; -class SimpleCaptureUnbalanced : public SimpleCapture +class CaptureUnbalanced : public Capture { public: - SimpleCaptureUnbalanced(std::shared_ptr camera); + CaptureUnbalanced(std::shared_ptr camera); void capture(unsigned int numRequests); diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index 2f07a50f171b..ae8c6f4db51b 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -11,10 +11,15 @@ endif lc_compliance_enabled = true lc_compliance_sources = files([ - 'capture_test.cpp', 'environment.cpp', + 'helpers/capture.cpp', 'main.cpp', - 'simple_capture.cpp', + 'tests/capture_test.cpp', +]) + +lc_compliance_includes = ([ + include_directories('.'), + include_directories('helpers/') ]) lc_compliance = executable('lc-compliance', lc_compliance_sources, @@ -26,5 +31,6 @@ lc_compliance = executable('lc-compliance', lc_compliance_sources, libevent, libgtest, ], + include_directories : lc_compliance_includes, install : true, install_tag : 'bin-devel') diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp similarity index 95% rename from src/apps/lc-compliance/capture_test.cpp rename to src/apps/lc-compliance/tests/capture_test.cpp index 1dcfcf92fc8c..284d36307619 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/tests/capture_test.cpp @@ -6,12 +6,13 @@ * capture_test.cpp - Test camera capture */ +#include "capture.h" + #include #include #include "environment.h" -#include "simple_capture.h" using namespace libcamera; @@ -83,7 +84,7 @@ TEST_P(SingleStream, Capture) { auto [role, numRequests] = GetParam(); - SimpleCaptureBalanced capture(camera_); + CaptureBalanced capture(camera_); capture.configure(role); @@ -102,7 +103,7 @@ TEST_P(SingleStream, CaptureStartStop) auto [role, numRequests] = GetParam(); unsigned int numRepeats = 3; - SimpleCaptureBalanced capture(camera_); + CaptureBalanced capture(camera_); capture.configure(role); @@ -121,7 +122,7 @@ TEST_P(SingleStream, UnbalancedStop) { auto [role, numRequests] = GetParam(); - SimpleCaptureUnbalanced capture(camera_); + CaptureUnbalanced capture(camera_); capture.configure(role); From patchwork Sat Dec 30 16:29:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19356 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 7AB3CC32BD for ; Sat, 30 Dec 2023 16:29:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8B7462B68; Sat, 30 Dec 2023 17:29:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953779; bh=uREwC1sYmKn54w5oKXVCF/CAeWzzERz9UG3mEK9qtCA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=flHbiBFaj170dvQBVK1RF+n3ZHqiCKoxdGL0hbwlr9Mu0hssLqgwd0F3Cr5wppsaL W1xzZSX2KpM9xtwI4/z09PthVwKNeF8GP/YBt6zLzBS8VGGY29BjCs+vNj7sTugpfW 9cqGYVC6wHRvl8hccsPY92RP5mHDBVoHJUedtampxlBVh6jfKb736psDZNcuuNThxG LkztVjCqAljfo+SC2cZTHokcCx+83ImHKeEBXal99xTCPX41BLcTUUiLhw7G6ig+Ys 4O/UIqfhPfTtdeUPhEu2i96I1QB4fo+PheBwvxGHito4YcKOmeCdjBHmQDw6lvl2Xm hXLmFisCeVLVQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC4CF62B54 for ; Sat, 30 Dec 2023 17:29:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BxMPbBtX"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E38D8BE; Sat, 30 Dec 2023 17:28:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953716; bh=uREwC1sYmKn54w5oKXVCF/CAeWzzERz9UG3mEK9qtCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BxMPbBtXS08t0TVol8cMU+tNHi6TmEK56QEgvVktzSipCwnhdFBdxHdgKIIGiCz3S qHXYQZFtSoIfOs52K8Ph1DXFUPSSHkME0cY3S31CFj7TmmMm1NJg0e4Lt9/FGd+FJg EjQfWsQjCAPw/kgP31ogNBNVkBFFJZpTGmUyYZRI= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:10 +0100 Message-ID: <20231230162912.827669-6-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/7] apps: lc-compliance: Test for mandatory controls 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Test for mandatory controls and properties to be supported by a Camera. Signed-off-by: Jacopo Mondi --- src/apps/lc-compliance/meson.build | 1 + .../lc-compliance/tests/controls_test.cpp | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/apps/lc-compliance/tests/controls_test.cpp diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index ae8c6f4db51b..c927dd12e9f4 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -15,6 +15,7 @@ lc_compliance_sources = files([ 'helpers/capture.cpp', 'main.cpp', 'tests/capture_test.cpp', + 'tests/controls_test.cpp' ]) lc_compliance_includes = ([ diff --git a/src/apps/lc-compliance/tests/controls_test.cpp b/src/apps/lc-compliance/tests/controls_test.cpp new file mode 100644 index 000000000000..e9bdf6fdb7e3 --- /dev/null +++ b/src/apps/lc-compliance/tests/controls_test.cpp @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Ideas On Board Oy + * + * controls_test.cpp - Test controls and properties + */ + +#include +#include + +#include +#include +#include + +#include + +#include "environment.h" + +using namespace libcamera; + +std::array controlMaps = { + &controls::controls, + &properties::properties, +}; + +class ControlTest : public testing::TestWithParam +{ +public: + static std::string nameParameters(const testing::TestParamInfo &info); + +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr camera_; +}; + +void ControlTest::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void ControlTest::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +std::string ControlTest::nameParameters(const testing::TestParamInfo &info) +{ + const ControlIdMap *idMap = info.param; + if (idMap == &controls::controls) + return "controls"; + else if (idMap == &properties::properties) + return "properties"; + + return "vendor"; +} + +/* Test that mandatory controls and properties are supported by a camera. */ +TEST_P(ControlTest, RequiredControls) +{ + auto controlMap = GetParam(); + + for (const auto &[id, ctrl] : *controlMap) { + if (!ctrl->required()) + continue; + + if (controlMap == &controls::controls) { + const auto it = camera_->controls().find(ctrl); + + if (it == camera_->controls().end()) + FAIL() << "Mandatory control \"" << ctrl->name() + << "\" not supported" << std::endl; + } else if (controlMap == &properties::properties) { + bool found = camera_->properties().contains(id); + + if (!found) + FAIL() << "Mandatory property \"" << ctrl->name() + << "\" not supported" << std::endl; + } + } +} + +/* + * Use a Value-Parametrized Test case so that vendors can easily test vendor + * control lists by expading 'controlMaps'. + */ +INSTANTIATE_TEST_SUITE_P(ControlsTest, ControlTest, + testing::ValuesIn(controlMaps), + ControlTest::nameParameters); From patchwork Sat Dec 30 16:29:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19357 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 13E4FC3295 for ; Sat, 30 Dec 2023 16:29:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A297462B6B; Sat, 30 Dec 2023 17:29:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953779; bh=EhdxCrVxDYg8lvNpqpoeOFt5YT2l7CeYtsR80UGqVN0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=iSu1DZ9+vJHb4KrbGzxWzMbRZack/jdZ/rcsXuKhOHzC+oCTrtgMigxU/73jVPTXP KQ071YvG/we5ZZjIaiBhE30UygrcPLSniNs8KYPGlO2LySmhCej06HhLQWlT2fRp9N OCH4RsaHhDGAtJOQzLRB56n23C0PmMRSjgUOOZo8+tP+wR3zV/Pl5a3giG6AG6NNOb jbM8Od7y1YhwjCN/sN+sTzm8O+c0p119WNIAI0Ka1fOi2fa8dTMu4xSolq1TQKU7pr B/vH4OeljF4uf7YpsVHD+4g3VocqYR8XEt7TE6rZGasfPhf0WAhwsyIjHp2YMytthH 1l290O5C1wp+Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 33BBE61D89 for ; Sat, 30 Dec 2023 17:29:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IffVZ7QY"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C719C842; Sat, 30 Dec 2023 17:28:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953717; bh=EhdxCrVxDYg8lvNpqpoeOFt5YT2l7CeYtsR80UGqVN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IffVZ7QYyL3Y4Bbxw0SK+xKtqYzF1tzNruxgL7+jbnaMZ3bE8YwhREplP0TC7z92E nUkXPBt8bkdBH4FzfgEd/2Xo4KMRASvAIZJkPXBK6rHo7azBzOd+TpAxfzme74s4+V uQrZEQZolpiPXjP50cr6Ztqjbcx2adGvDolQypiQ= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:11 +0100 Message-ID: <20231230162912.827669-7-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/7] apps: lc-compliance: Support multiple streams in helpers 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Prepare to add a test suite for capture operations with multiple streams. Modify the Capture helper class to support multiple roles and streams in the configure() and capture() operations. Multi-stream support will be added in next patches. Signed-off-by: Jacopo Mondi Reviewed-by: Stefan Klug --- src/apps/lc-compliance/helpers/capture.cpp | 85 ++++++++++++++----- src/apps/lc-compliance/helpers/capture.h | 2 +- src/apps/lc-compliance/tests/capture_test.cpp | 26 +++--- 3 files changed, 76 insertions(+), 37 deletions(-) diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp index 5aab973f0392..bb95af3d758c 100644 --- a/src/apps/lc-compliance/helpers/capture.cpp +++ b/src/apps/lc-compliance/helpers/capture.cpp @@ -7,6 +7,8 @@ #include "capture.h" +#include + #include using namespace libcamera; @@ -22,15 +24,27 @@ Capture::~Capture() stop(); } -void Capture::configure(StreamRole role) +void Capture::configure(Span roles) { - config_ = camera_->generateConfiguration({ role }); + config_ = camera_->generateConfiguration(roles); if (!config_) { - std::cout << "Role not supported by camera" << std::endl; + std::cout << "Roles not supported by camera" << std::endl; GTEST_SKIP(); } + /* + * Set the buffers count to the largest value across all streams. + * \todo: Should all streams from a Camera have the same buffer count ? + * */ + auto largest = + std::max_element(config_->begin(), config_->end(), + [](StreamConfiguration &l, StreamConfiguration &r) + { return l.bufferCount < r.bufferCount; }); + + for (auto &stream : *config_) + stream.bufferCount = largest->bufferCount; + if (config_->validate() != CameraConfiguration::Valid) { config_.reset(); FAIL() << "Configuration not valid"; @@ -44,11 +58,17 @@ void Capture::configure(StreamRole role) void Capture::start() { - Stream *stream = config_->at(0).stream(); - int count = allocator_->allocate(stream); + unsigned int i = 0; + for (auto const &config : *config_) { + Stream *stream = config.stream(); + int count = allocator_->allocate(stream); - ASSERT_GE(count, 0) << "Failed to allocate buffers"; - EXPECT_EQ(count, config_->at(0).bufferCount) << "Allocated less buffers than expected"; + ASSERT_GE(count, 0) << "Failed to allocate buffers for stream " << i; + EXPECT_EQ(count, config.bufferCount) + << "Allocated less buffers than expected for stream " << i; + + ++i; + } camera_->requestCompleted.connect(this, &Capture::requestComplete); @@ -64,9 +84,12 @@ void Capture::stop() camera_->requestCompleted.disconnect(this); - Stream *stream = config_->at(0).stream(); requests_.clear(); - allocator_->free(stream); + + for (auto const &config : *config_) { + Stream *stream = config.stream(); + allocator_->free(stream); + } } /* CaptureBalanced */ @@ -80,14 +103,12 @@ void CaptureBalanced::capture(unsigned int numRequests) { start(); - Stream *stream = config_->at(0).stream(); - const std::vector> &buffers = allocator_->buffers(stream); - /* No point in testing less requests then the camera depth. */ - if (buffers.size() > numRequests) { - std::cout << "Camera needs " + std::to_string(buffers.size()) - + " requests, can't test only " - + std::to_string(numRequests) << std::endl; + const unsigned int bufferCount = config_->at(0).bufferCount; + if (bufferCount > numRequests) { + std::cout << "Camera needs " << bufferCount + << " requests, can't test only " << numRequests + << std::endl; GTEST_SKIP(); } @@ -96,11 +117,21 @@ void CaptureBalanced::capture(unsigned int numRequests) captureLimit_ = numRequests; /* Queue the recommended number of requests. */ - for (const std::unique_ptr &buffer : buffers) { + for (unsigned int bufferIdx = 0; bufferIdx < bufferCount; ++bufferIdx) { std::unique_ptr request = camera_->createRequest(); ASSERT_TRUE(request) << "Can't create request"; - ASSERT_EQ(request->addBuffer(stream, buffer.get()), 0) << "Can't set buffer for request"; + /* Add buffers for each stream. */ + unsigned int i = 0; + for (const auto &config : *config_) { + Stream *stream = config.stream(); + const auto &buffers = allocator_->buffers(stream); + + ASSERT_EQ(request->addBuffer(stream, buffers[bufferIdx].get()), 0) + << "Can't add buffers for stream " << i; + + ++i; + } ASSERT_EQ(queueRequest(request.get()), 0) << "Failed to queue request"; @@ -152,18 +183,26 @@ void CaptureUnbalanced::capture(unsigned int numRequests) { start(); - Stream *stream = config_->at(0).stream(); - const std::vector> &buffers = allocator_->buffers(stream); - captureCount_ = 0; captureLimit_ = numRequests; /* Queue the recommended number of requests. */ - for (const std::unique_ptr &buffer : buffers) { + const unsigned int bufferCount = config_->at(0).bufferCount; + for (unsigned int bufferIdx = 0; bufferIdx < bufferCount; ++bufferIdx) { std::unique_ptr request = camera_->createRequest(); ASSERT_TRUE(request) << "Can't create request"; - ASSERT_EQ(request->addBuffer(stream, buffer.get()), 0) << "Can't set buffer for request"; + /* Add buffers for each stream. */ + unsigned int i = 0; + for (const auto &config : *config_) { + Stream *stream = config.stream(); + const auto &buffers = allocator_->buffers(stream); + + ASSERT_EQ(request->addBuffer(stream, buffers[bufferIdx].get()), 0) + << "Can't add buffers for stream " << i; + + ++i; + } ASSERT_EQ(camera_->queueRequest(request.get()), 0) << "Failed to queue request"; diff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h index 0574ab1c7ac7..3e2b2889244d 100644 --- a/src/apps/lc-compliance/helpers/capture.h +++ b/src/apps/lc-compliance/helpers/capture.h @@ -16,7 +16,7 @@ class Capture { public: - void configure(libcamera::StreamRole role); + void configure(libcamera::Span roles); protected: Capture(std::shared_ptr camera); diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp index 284d36307619..3d3cc97791d9 100644 --- a/src/apps/lc-compliance/tests/capture_test.cpp +++ b/src/apps/lc-compliance/tests/capture_test.cpp @@ -17,14 +17,14 @@ using namespace libcamera; const std::vector NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; -const std::vector ROLES = { - StreamRole::Raw, - StreamRole::StillCapture, - StreamRole::VideoRecording, - StreamRole::Viewfinder +const std::vector> ROLES = { + { StreamRole::Raw }, + { StreamRole::StillCapture }, + { StreamRole::VideoRecording }, + { StreamRole::Viewfinder }, }; -class SingleStream : public testing::TestWithParam> +class SingleStream : public testing::TestWithParam, int>> { public: static std::string nameParameters(const testing::TestParamInfo &info); @@ -67,7 +67,7 @@ std::string SingleStream::nameParameters(const testing::TestParamInfo(info.param)]; + std::string roleName = rolesMap[std::get<0>(info.param)[0]]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); return roleName + "_" + numRequestsName; @@ -82,11 +82,11 @@ std::string SingleStream::nameParameters(const testing::TestParamInfo{ role }); capture.capture(numRequests); } @@ -100,12 +100,12 @@ TEST_P(SingleStream, Capture) */ TEST_P(SingleStream, CaptureStartStop) { - auto [role, numRequests] = GetParam(); + const auto [role, numRequests] = GetParam(); unsigned int numRepeats = 3; CaptureBalanced capture(camera_); - capture.configure(role); + capture.configure(Span{ role }); for (unsigned int starts = 0; starts < numRepeats; starts++) capture.capture(numRequests); @@ -120,11 +120,11 @@ TEST_P(SingleStream, CaptureStartStop) */ TEST_P(SingleStream, UnbalancedStop) { - auto [role, numRequests] = GetParam(); + const auto [role, numRequests] = GetParam(); CaptureUnbalanced capture(camera_); - capture.configure(role); + capture.configure(Span{ role }); capture.capture(numRequests); } From patchwork Sat Dec 30 16:29:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19358 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 BCB61C32BE for ; Sat, 30 Dec 2023 16:29:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6759962B6E; Sat, 30 Dec 2023 17:29:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703953780; bh=0qXTzc+FXDdLo6Zf6MEwfvpOHyPH64OjZgdVDuKTecs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gCVgzHV2Fz6qohjPcAWqsC5kP3C9IGPvARMcaARybo5xGKplguoUsd2c6D1HznRP1 Blj7U/1avptBj7Z+OrU0wJp2qX00wkKeVHtEfSe1tQlva8gnEJ2Va0XxvIJumx9VAQ Z4jdvWC4Dto5QWU4QSobbwijcYKuZAkJltmIGnZaQDR9D6Qb0IV9THExQCR/XawxhG BL93gcQVM9Il5wKd2jhvKHbNhsz1tm9A7SN+rw/wWuANuxKlCxKt24gnXXi5+kNXX6 4QXWA3KZkr+ByMnkLfHi8X8R2I5nMsfoVwAuuQprrFyLyN2oo/4NFe8UWh7kfLyARP 4mEyuAcC13dtQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9517362B5A for ; Sat, 30 Dec 2023 17:29:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bS6Tv8pE"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 37CFE8BE; Sat, 30 Dec 2023 17:28:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703953717; bh=0qXTzc+FXDdLo6Zf6MEwfvpOHyPH64OjZgdVDuKTecs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bS6Tv8pEq3/a6QF1htJQBWHtKftnsVULPQkWiegT49129V0aShkdXpQa/uvCGIXqo Js4Dh7Grc24Dt6PYkhN4nwulf9vDL0yWsCxZqKx8fdTAtgXvxdyP6T0hZIjBdee5w1 0gnNEJCWS8GYQb7C0JL4hGdN2g7krcbBYfaHOxjE= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Dec 2023 17:29:12 +0100 Message-ID: <20231230162912.827669-8-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> References: <20231230162912.827669-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/7] apps: lc-compliance: Add multi-stream tests 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a test suite for testing capture operations with multiple streams. Signed-off-by: Jacopo Mondi Reviewed-by: Stefan Klug --- src/apps/lc-compliance/tests/capture_test.cpp | 92 +++++++++++++++++-- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp index 3d3cc97791d9..3f4a2f71d10b 100644 --- a/src/apps/lc-compliance/tests/capture_test.cpp +++ b/src/apps/lc-compliance/tests/capture_test.cpp @@ -16,6 +16,8 @@ using namespace libcamera; +namespace { + const std::vector NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; const std::vector> ROLES = { { StreamRole::Raw }, @@ -24,6 +26,22 @@ const std::vector> ROLES = { { StreamRole::Viewfinder }, }; +const std::vector> MULTIROLES = { + { StreamRole::Raw, StreamRole::StillCapture }, + { StreamRole::Raw, StreamRole::VideoRecording }, + { StreamRole::StillCapture, StreamRole::VideoRecording }, + { StreamRole::VideoRecording, StreamRole::VideoRecording }, +}; + +std::map rolesMap = { + { StreamRole::Raw, "Raw" }, + { StreamRole::StillCapture, "StillCapture" }, + { StreamRole::VideoRecording, "VideoRecording" }, + { StreamRole::Viewfinder, "Viewfinder" } +}; + +} /* namespace */ + class SingleStream : public testing::TestWithParam, int>> { public: @@ -60,13 +78,6 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo &info) { - std::map rolesMap = { - { StreamRole::Raw, "Raw" }, - { StreamRole::StillCapture, "StillCapture" }, - { StreamRole::VideoRecording, "VideoRecording" }, - { StreamRole::Viewfinder, "Viewfinder" } - }; - std::string roleName = rolesMap[std::get<0>(info.param)[0]]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); @@ -134,3 +145,70 @@ INSTANTIATE_TEST_SUITE_P(CaptureTests, testing::Combine(testing::ValuesIn(ROLES), testing::ValuesIn(NUMREQUESTS)), SingleStream::nameParameters); + +class MultiStream : public testing::TestWithParam, int>> +{ +public: + static std::string nameParameters(const testing::TestParamInfo &info); + +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr camera_; +}; + +/* + * We use gtest's SetUp() and TearDown() instead of constructor and destructor + * in order to be able to assert on them. + */ +void MultiStream::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void MultiStream::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +std::string MultiStream::nameParameters(const testing::TestParamInfo &info) +{ + std::string roleName = rolesMap[std::get<0>(info.param)[0]] + "_" + + rolesMap[std::get<0>(info.param)[1]]; + std::string numRequestsName = std::to_string(std::get<1>(info.param)); + + return roleName + "_" + numRequestsName; +} + +/* + * Test multi-stream capture cycles + * + * Makes sure the camera completes the exact number of requests queued. Example + * failure is a camera that completes less requests than the number of requests + * queued. + */ +TEST_P(MultiStream, Capture) +{ + const auto [roles, numRequests] = GetParam(); + + CaptureBalanced capture(camera_); + + capture.configure(Span{ roles }); + + capture.capture(numRequests); +} + +INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, + MultiStream, + testing::Combine(testing::ValuesIn(MULTIROLES), + testing::ValuesIn(NUMREQUESTS)), + MultiStream::nameParameters);