From patchwork Sat Dec 23 11:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19345 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 4F341C3294 for ; Sat, 23 Dec 2023 11:10:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B13AA62B40; Sat, 23 Dec 2023 12:10:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703329837; 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=Tg4ljmSyBdBTapGIfqbqIUgKLHjM7hi13p8P7qvjeUpmD4E7222Yc+BMHUcSxKAkI UHRjVvIaaF7G6xmePg79quOXRwsoF2LkFQEGZLUdZkHZ26HqDxFR3murMubs+ojYdm HZBaWb1CjJUyCeFSZEtKKV2HlNtrCGLZPcfdWN+eInHlzYLOk70aQVgNEMjEPe+Orj MFK6kAd1XL60/SHlsK0VY3jLNTLata9XKBZDPGe25qzyNAAQ3WCqCjSfkr0Z2/0AXd DzNX+Tns56Q6SKiKynt/f5dB3wKpAgmqc66/ZCjPj/eNu2FIUVB2Qrb5Gv0j6/UL42 M5LIJZTyIeY7w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9197662B31 for ; Sat, 23 Dec 2023 12:10:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SvNU2e4d"; 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 1C610FF3; Sat, 23 Dec 2023 12:09:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703329783; bh=L1nZBbVzw9eXEQvoRnyKzXlyi4n9eV24kx6uDm1Hymc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SvNU2e4dUV+vKk1lXJsBGqPnxNGp7KtYFZCMQAfQ1JtTkJplNpen1MG7s3frfx4C5 BQ2rvGZjYkXfbjBWZJ4ndu6kk9+X8YhgGXj8HIPuTdpNL1xdsfWJ5MEJ325YoMrECk JjG1h2BOn6qtSEgkT3yfdkdmRd5Y8iQPjFE/VRzg= To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Dec 2023 12:10:19 +0100 Message-ID: <20231223111023.668199-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> References: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/5] 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 23 11:10:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19346 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 8EAC8BDB1D for ; Sat, 23 Dec 2023 11:10:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77FD762B5C; Sat, 23 Dec 2023 12:10:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703329839; 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=FDoRcWzmFnI4ZDZf+fMKW0akgXhLiuQjb7a32tuARLkzPy7yTWE5t9jkkpR1UHGRJ af68dcN13cvYwxBIHWbCmuat5g0SqZPh3vwDW8gdSiJsEHsJI6GciPfm+3edARBCJ+ hSB8uKFibW7SilTfCg9qah/H8W5aER5hT88WrYDs67Zi99FIJ80XVts9B4weMzsPH3 023lnw7q+AP+miIqUSao3zW/vvKcO6l9FnxLlGIgg0am3++l8gq80+y+sAwklK3B6h uFiEtwseyoD7j/oj7sufOQtFNzYMyXfg3hLVDy3c/1iu3j5H+RYdO0EJNW2zIGNiuU ubmOSKId5etNg== 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 0597A62B31 for ; Sat, 23 Dec 2023 12:10:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UYT5rkMP"; 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 942349A8; Sat, 23 Dec 2023 12:09:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703329783; bh=qneqtV9quvOjU67kpSxwhaJzfrt4bucT1eOPM/MgTvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYT5rkMPMTLQrhePi/PToHOrh1BLoz562Gn/opiP+qiR31CvxfFuxlmmuWRDaZXbl v9pvz+BvjQbSpdl+sC9p+9up2gePOvJxaCWL541ITXK1tvY3XJIWe1I3BC7yYZBoGU zq9ei0NVcEqZdawV4Y3KPBR/mDf6RwJhhrK6x6C4= To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Dec 2023 12:10:20 +0100 Message-ID: <20231223111023.668199-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> References: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/5] 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 --- 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 23 11:10:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19347 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 54E28C32BC for ; Sat, 23 Dec 2023 11:10:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96D8462B52; Sat, 23 Dec 2023 12:10:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703329840; 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=mUPxM8N4atEvi112fMav7Fyp8aaFJWFHMdgaCdoQHjVGgs+o05fLIiX1l9AK3ufFW e7GPZhFtYAjLBM0NdGPPV11oeQBEdbvAZZf1/P8aEjQXq1HlkfocKevzeYYgOCVNZi WtOYTZjmeA7zB5GgH74Uhe0WTdmWoA8IaDk8oUhm6XuldeE6r+e/mq2knEsC7djJNV USs9dJHEBFTvayemlN7Bj/VonIzXCX2XLvPnzAnVEMTHdtT5ekPvA5S0qk9m/RpPWo ZgfJFaG/ya4FDnDnt7THEKUToNTMwICsgENutgHq2TpZNkkaHy8NVCWmSBdn4LZMiv JXwFIUzc2CmFQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 637D062B31 for ; Sat, 23 Dec 2023 12:10:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qjTGecMZ"; 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 0A932105D; Sat, 23 Dec 2023 12:09:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703329784; bh=jT0KPQWhn4IpHg9WXjtMDYPB0JLx18I5UCCMc6EvPug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjTGecMZPD0vKT/gKPviQAweHNS4tSY5Oxn4+PXz+zjiJhdfS1qcfg354pumbkuAT sHiIJ38LV+UPt6Q+589r4RuOKotn98vK725I+edfETduo3TtMuJ8gzr7oXV9NxfMzS 8XcgPCpNm7Ett1FU919PCsntvrjv8dilOFt3rXlk= To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Dec 2023 12:10:21 +0100 Message-ID: <20231223111023.668199-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> References: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] 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 --- 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 23 11:10:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19348 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 D36CAC32BD for ; Sat, 23 Dec 2023 11:10:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3FEB662B5F; Sat, 23 Dec 2023 12:10:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703329841; 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=f6jcCNpW5dcbO66wEp9lTxQLV+y2FFzXM22fzS9zcXItHpgIi4h1plCZLYY0Vfwn+ uQjxgpk8UyyOJN83tI3FjZiR20syGXvF3LN2jxP+olXaxt74+xGLTmfpy+H66x+1za XKACooWM1wTu1BpuiMZ9Xuk1IM25vsigUgEmrjyBocZSJvpSUji6BQqyptqragD3RZ qdQH0mmVPIJKT8rYXAe0vG+FIUZ6XOY6wls/0vctYxEMXu5liLO3oS4en9ZH4BT6d8 Flb7KlIpFY2OXkaZwlmwtss0DFk+mn9nGBJnBKgMqi/utQBFxEltsyIcSoO+EYu0Rm 0EEXkNK0lylDQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AD69762B4A for ; Sat, 23 Dec 2023 12:10:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VmbT8NvT"; 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 5D9AEFF3; Sat, 23 Dec 2023 12:09:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703329784; bh=wAxlakPy353QsBJfhvYiGepVDOexcUVy88tbj9z6DxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VmbT8NvT/jPAViLYuLQ7mGNSQikeHa9gMAp2wIqqphiVORMNFzIkBK1cdBkvdwRKW o4auyJJLHpiBsZqT81wu0sLrHqwBNI3EV5pQFkNTpuAd3p4O037Z9yRCO97Pz2wV6D BOGjvRmG+OWyRZcf9k8EtYliv5j1+cllHP/ZPTQI= To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Dec 2023 12:10:22 +0100 Message-ID: <20231223111023.668199-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> References: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/5] 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 --- .../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 23 11:10:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19349 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 51ED1C32BE for ; Sat, 23 Dec 2023 11:10:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D66CD62B5B; Sat, 23 Dec 2023 12:10:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1703329841; 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=18CmpxU1COwY1hLaJxk7sqO4vS3jsgl1qw3xd+D15Jub1QRFakSs8PuzGpiNhhkYz 5Ck98UnQuTMfy6Ecl7uuLDlCSDYYkpt+ljulv9MRGlwPxO5bbcpQm2UtLw0eHbrrFm b6LgpGkGR+/6tz6zkTNU+RUIHIMbW75CaUgZVyTCdm7JFZr7bjGRzF3NjDA82frgu+ wWHFts5bfNhSQCNHkgC56l8FbA4tJugcDdG2NIg5CGVjSedaQ21DAY+Hz5AoZs7H+w /68opCETfSwrM4pWyp2z0KR3aVLYPUfC9mb1rTNEcAxHVIHXqnYbF9h2zvA+9Xr/RL 1caDPVDOQ/dcA== 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 2BB3662B58 for ; Sat, 23 Dec 2023 12:10:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SIxukxga"; 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 B32E29A8; Sat, 23 Dec 2023 12:09:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703329784; bh=uREwC1sYmKn54w5oKXVCF/CAeWzzERz9UG3mEK9qtCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIxukxgav5IKqInTdc1UJh76zRGn7mqgvI4ktQAxbAobcCCkwwbxZJVZxbBkNt50E YDJ8JJdCzr2Me9ZfaHoo01CZeu8Od2+InSbm1KZlMSpHDqZBPNizCosjZHgaZtDHTZ fXVYrOcd5sRsnozhJs2+nptAUZ/s9RNH+tiiASRs= To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Dec 2023 12:10:23 +0100 Message-ID: <20231223111023.668199-6-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> References: <20231223111023.668199-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/5] 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);