From patchwork Wed Feb 6 06:07:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 519 Return-Path: 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 5013661022 for ; Wed, 6 Feb 2019 07:08:24 +0100 (CET) Received: from pendragon.ideasonboard.com (d51A4137F.access.telenet.be [81.164.19.127]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EC8522D7 for ; Wed, 6 Feb 2019 07:08:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549433304; bh=Pu+ypCssb0+WQtotRHwEBMjRh/ieRz+Jz2FNnrDcU1M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h6jdEsn9fSCJ+DSOWNznU866qyHnsfoeFRNJ3HjB+NeE8t8/5ucJ/YBkt4zqLEhSA fQl+6iQttlK3SKOKbvAVyZhsq04wqBdps6lAIQ3n/e8DaufLkjVoGHEuQZE+WsTMSM 1VmRnrA6s0mLNPJr0MR9mXqJio2G8pncJMqTNSRQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Feb 2019 08:07:55 +0200 Message-Id: <20190206060818.13907-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190206060818.13907-1-laurent.pinchart@ideasonboard.com> References: <20190206060818.13907-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 04/27] test: v4l2_device: Add request_buffers test X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2019 06:08:24 -0000 From: Kieran Bingham Add a utility to the test suite to request and allocate buffers from a V4L2Device to ensure it functions correctly. Signed-off-by: Kieran Bingham Signed-off-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Signed-off-by: Niklas Söderlund --- test/v4l2_device/meson.build | 1 + test/v4l2_device/request_buffers.cpp | 32 ++++++++++++++++++++++++++++ test/v4l2_device/v4l2_device_test.h | 7 +++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/v4l2_device/request_buffers.cpp diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build index 41675a303498..b6b672611d60 100644 --- a/test/v4l2_device/meson.build +++ b/test/v4l2_device/meson.build @@ -2,6 +2,7 @@ # They are not alphabetically sorted. v4l2_device_tests = [ [ 'double_open', 'double_open.cpp' ], + [ 'request_buffers', 'request_buffers.cpp' ], ] foreach t : v4l2_device_tests diff --git a/test/v4l2_device/request_buffers.cpp b/test/v4l2_device/request_buffers.cpp new file mode 100644 index 000000000000..bc6ff2c18a57 --- /dev/null +++ b/test/v4l2_device/request_buffers.cpp @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * libcamera V4L2 API tests + */ + +#include "v4l2_device_test.h" + +class RequestBuffersTest : public V4L2DeviceTest +{ +protected: + int run() + { + /* + * TODO: + * Test invalid requests + * Test different buffer allocations + */ + const unsigned int bufferCount = 8; + + createBuffers(bufferCount); + + int ret = dev_->exportBuffers(bufferCount, &pool_); + if (ret) + return TestFail; + + return TestPass; + } +}; + +TEST_REGISTER(RequestBuffersTest); diff --git a/test/v4l2_device/v4l2_device_test.h b/test/v4l2_device/v4l2_device_test.h index ca231ab47fde..f22f0bb555d8 100644 --- a/test/v4l2_device/v4l2_device_test.h +++ b/test/v4l2_device/v4l2_device_test.h @@ -9,6 +9,8 @@ #include +#include + #include "test.h" #include "device_enumerator.h" @@ -20,7 +22,9 @@ using namespace libcamera; class V4L2DeviceTest : public Test { public: - V4L2DeviceTest() : dev_(nullptr) { }; + V4L2DeviceTest() : dev_(nullptr){}; + + void createBuffers(unsigned int qty) { pool_.createBuffers(qty); } protected: int init(); @@ -29,6 +33,7 @@ protected: std::unique_ptr enumerator_; std::shared_ptr media_; V4L2Device *dev_; + BufferPool pool_; }; #endif /* __LIBCAMERA_V4L2_DEVICE_TEST_H_ */