From patchwork Sun Feb 3 11:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 495 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 98FB760DD1 for ; Sun, 3 Feb 2019 12:01:08 +0100 (CET) Received: from localhost.localdomain (218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 460815AA; Sun, 3 Feb 2019 12:01:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549191668; bh=n2JjINr+mWY49vb4kt1nljqEvmVsceUWHcYrY14V15k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HuINa73w0toz9UoZDJu6gbuOd4ECfunrgTTN6H1d/TT6wtmzP9utmSeCMnPLC/0+6 CNKtyoEqawTpiQE0APOYQEFnAQn4Pxu67Ym6xr0FWVxYja82TtxS/zhWHOyqXAT54/ 3kJUhHHvUQA392nSBV/E3vHY7KxdG8fgHxuWnM/k= From: Kieran Bingham To: LibCamera Devel Date: Sun, 3 Feb 2019 12:00:59 +0100 Message-Id: <20190203110102.5663-9-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190203110102.5663-1-kieran.bingham@ideasonboard.com> References: <20190203110102.5663-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/11] test: v4l2_device: Add a functional capture 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: Sun, 03 Feb 2019 11:01:10 -0000 We now have enough infrastructure to be able to capture frames from a basic UVC device. Provide a test loop which captures frames, and returns them back to the kernel. Signed-off-by: Kieran Bingham --- test/v4l2_device/capture_frames.cpp | 51 +++++++++++++++++++++++++++++ test/v4l2_device/meson.build | 1 + 2 files changed, 52 insertions(+) create mode 100644 test/v4l2_device/capture_frames.cpp diff --git a/test/v4l2_device/capture_frames.cpp b/test/v4l2_device/capture_frames.cpp new file mode 100644 index 000000000000..276be91a9a82 --- /dev/null +++ b/test/v4l2_device/capture_frames.cpp @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * libcamera V4L2 API tests + */ + +#include "v4l2_device_test.h" + +class CaptureFrames : public V4L2DeviceTest +{ +protected: + int run() + { + int ret; + + BufferPool *pool = dev_->requestBuffers(8); + if (!pool) + return TestFail; + + ret = dev_->streamOn(); + if (ret) + return ret; + + /* + * With no dispatcher loop, the internal asynchronous buffer + * retrieval will not operate. + * + * We can manually validate the dequeueBuffer() and + * queueBuffer() calls directly here. + * + * The application should not use these calls directly if it + * makes any calls to: + * dispatcher->processEvents(); + */ + for (unsigned int i; i < 30; ++i) { + auto buffer = dev_->dequeueBuffer(); + + /* Check buffer */ + if (!buffer) + return TestFail; + + if (dev_->queueBuffer(buffer)) + return TestFail; + } + + return dev_->streamOff(); + } +}; + +TEST_REGISTER(CaptureFrames); diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build index cbaa79da9b81..f04c7ded009c 100644 --- a/test/v4l2_device/meson.build +++ b/test/v4l2_device/meson.build @@ -4,6 +4,7 @@ v4l2_device_tests = [ [ 'double_open', 'double_open.cpp' ], [ 'request_buffers', 'request_buffers.cpp' ], [ 'stream_on_off', 'stream_on_off.cpp' ], + [ 'capture_frames', 'capture_frames.cpp' ], ] foreach t : v4l2_device_tests