[libcamera-devel] [PATCH v2 8/8] test: v4l2_device: Provide buffer sharing test

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Feb 13 17:54:05 CET 2019


Hi Kieran,

On Wed, Feb 13, 2019 at 04:23:07PM +0000, Kieran Bingham wrote:
> On 13/02/2019 16:01, Laurent Pinchart wrote:
> > On Wed, Feb 13, 2019 at 03:10:27PM +0000, Kieran Bingham wrote:
> >> Obtain two V4L2Devices and use one to obtain a BufferPool.
> >>
> >> Propagate the formats from the first to the second device and then commence
> >> sending buffers between the two devices in a ping-pong fashion.
> >>
> >> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> >> ---
> >>  test/v4l2_device/buffer_sharing.cpp | 179 ++++++++++++++++++++++++++++
> >>  test/v4l2_device/meson.build        |   1 +
> >>  2 files changed, 180 insertions(+)
> >>  create mode 100644 test/v4l2_device/buffer_sharing.cpp
> >>
> >> diff --git a/test/v4l2_device/buffer_sharing.cpp b/test/v4l2_device/buffer_sharing.cpp
> >> new file mode 100644
> >> index 000000000000..f03201e82084
> >> --- /dev/null
> >> +++ b/test/v4l2_device/buffer_sharing.cpp
> >> @@ -0,0 +1,179 @@
> >> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> >> +/*
> >> + * Copyright (C) 2019, Google Inc.
> >> + *
> >> + * libcamera V4L2 API tests
> >> + *
> >> + * Validate the function of exporting buffers from a V4L2Device and
> >> + * the ability to import them to another V4L2Device instance.
> >> + * Ensure that the Buffers can successfully be queued and dequeued
> >> + * between both devices.
> >> + */
> >> +
> >> +#include <iostream>
> >> +
> >> +#include <libcamera/buffer.h>
> >> +#include <libcamera/camera_manager.h>
> >> +#include <libcamera/event_dispatcher.h>
> >> +#include <libcamera/timer.h>
> >> +
> >> +#include "v4l2_device_test.h"
> >> +
> >> +#include "log.h"
> >> +
> >> +LOG_DEFINE_CATEGORY(Test)
> > 
> > Can you use std::cout until we implement a test logger ?
> > 
> >> +class BufferSharingTest : public V4L2DeviceTest
> >> +{
> >> +public:
> >> +	BufferSharingTest()
> >> +		: output_(nullptr), framesCapture(0), framesOutput(0){};
> > 
> > 	BufferSharingTest()
> > 		: V4L2DeviceTest(), output_(nullptr), framesCapture(0),
> > 		  framesOutput(0)
> > 	{
> > 	}
> 
> 
> Checkstyle complains at this change, and prefers to have the {} inline.
> 
> --- test/v4l2_device/buffer_sharing.cpp
> +++ test/v4l2_device/buffer_sharing.cpp
> @@ -23,9 +23,7 @@
>  {
>  public:
>         BufferSharingTest()
> -               : output_(nullptr), framesCaptured_(0), framesOutput_(0)
> -       {
> -       };
> +               : output_(nullptr), framesCaptured_(0), framesOutput_(0){};
> 
> 
> Would you like to override checkstyle here?

The trailing ; is really not needed, and we need at least a space before
{}. When we have a list of initialisers I prefer splitting { and } to
separate lines for readability. If clang-format can do that through an
option it would be best. Otherwise we can override checkstyle here, or
keep {} inline (provided we add the space and remove the ;) if you
prefer (it's your code after all :-)).

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list