From patchwork Wed Jul 28 16:11:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13142 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 82106C3231 for ; Wed, 28 Jul 2021 16:10:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0715A687CB; Wed, 28 Jul 2021 18:10:36 +0200 (CEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B6EE6687C9 for ; Wed, 28 Jul 2021 18:10:33 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 4D43360009; Wed, 28 Jul 2021 16:10:33 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Jul 2021 18:11:14 +0200 Message-Id: <20210728161116.64489-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210728161116.64489-1-jacopo@jmondi.org> References: <20210728161116.64489-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] test: control serialization: Test lookup by ControlId 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" Test that lookup by ControlId reference works in the control serialization test. Also make sure that the control limits are not changed by de-serialization. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- test/serialization/control_serialization.cpp | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/serialization/control_serialization.cpp b/test/serialization/control_serialization.cpp index e23383d13bd6..45a706d27ba7 100644 --- a/test/serialization/control_serialization.cpp +++ b/test/serialization/control_serialization.cpp @@ -140,6 +140,28 @@ protected: return TestFail; } + /* Test lookup by ControlId * on the de-serialized info map. */ + auto newLimitsIter = newInfoMap.find(&controls::Brightness); + if (newLimitsIter == newInfoMap.end()) { + cerr << "Lookup by ControlId * failed" << endl; + return TestFail; + } + + auto initialLimitsIter = infoMap.find(&controls::Brightness); + if (initialLimitsIter == infoMap.end()) { + cerr << "Unable to retrieve the original control limits" << endl; + return TestFail; + } + + /* Make sure control limits looked up by id are not changed. */ + const ControlInfo &newLimits = newLimitsIter->second; + const ControlInfo &initialLimits = initialLimitsIter->second; + if (newLimits.min().get() != initialLimits.min().get() || + newLimits.max().get() != initialLimits.max().get()) { + cerr << "The brightness control limits have changed" << endl; + return TestFail; + } + /* Deserialize the control list and verify the contents. */ buffer = ByteStreamBuffer(const_cast(listData.data()), listData.size());