From patchwork Fri Apr 24 21:53:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3528 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 261DD62E5D for ; Fri, 24 Apr 2020 23:50:14 +0200 (CEST) X-Originating-IP: 87.3.55.240 Received: from uno.homenet.telecomitalia.it (host240-55-dynamic.3-87-r.retail.telecomitalia.it [87.3.55.240]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 6904C60002; Fri, 24 Apr 2020 21:50:13 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Apr 2020 23:53:01 +0200 Message-Id: <20200424215304.558317-11-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200424215304.558317-1-jacopo@jmondi.org> References: <20200424215304.558317-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 10/13] test: v4l2_device: Test getControl() API 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-List-Received-Date: Fri, 24 Apr 2020 21:50:14 -0000 Add a simple test for the newly added method. Signed-off-by: Jacopo Mondi --- test/v4l2_videodevice/controls.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index da9e0111e221..cf3d599c43ff 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -121,6 +121,22 @@ protected: return TestFail; } + /* Test the getControl() API. */ + int32_t oldBrightness = ctrls.get(V4L2_CID_BRIGHTNESS).get(); + int32_t newBrightness; + ret = capture_->getControl(V4L2_CID_BRIGHTNESS, &newBrightness); + if (ret) { + cerr << "Failed to read a single control" << endl; + return TestFail; + } + + if (newBrightness != oldBrightness) { + cerr << "Wrong control value read from device: " + << "got: " << newBrightness << " expected: " + << oldBrightness << endl; + return TestFail; + } + return TestPass; } };