[libcamera-devel] [PATCH 2/5] test: v4l2_device: Implement functions inside class definition in cpp files

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat May 11 03:52:26 CEST 2019


Hi Niklas,

Thank you for the patch.

On Wed, May 08, 2019 at 06:58:11PM +0200, Niklas Söderlund wrote:
> Implement the functions instead of just defining them in the class
> description and implement them bellow for classes which are defined in
> cpp source files.

The content of the patch is fine, but I find this sentence hard to
parse. After rewording it,

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> There is no functional change only restructuring of
> existing code to align with the style of other tests.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
>  test/v4l2_device/formats.cpp | 58 +++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 30 deletions(-)
> 
> diff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp
> index 007e7e9487b57772..72676c9d334a69b0 100644
> --- a/test/v4l2_device/formats.cpp
> +++ b/test/v4l2_device/formats.cpp
> @@ -18,36 +18,34 @@ using namespace libcamera;
>  class Format : public V4L2DeviceTest
>  {
>  protected:
> -	int run() override;
> +	int run()
> +	{
> +		V4L2DeviceFormat format = {};
> +
> +		int ret = capture_->getFormat(&format);
> +		if (ret) {
> +			cerr << "Failed to get format" << endl;
> +			return TestFail;
> +		}
> +
> +		format.size = { UINT_MAX, UINT_MAX };
> +		ret = capture_->setFormat(&format);
> +		if (ret) {
> +			cerr << "Failed to set format: image resolution is invalid: "
> +			     << "(UINT_MAX x UINT_MAX) but setFormat() should not fail."
> +			     << endl;
> +			return TestFail;
> +		}
> +
> +		if (format.size.width == UINT_MAX ||
> +		    format.size.height == UINT_MAX) {
> +			cerr << "Failed to update image format = (UINT_MAX x UINT_MAX)"
> +			     << endl;
> +			return TestFail;
> +		}
> +
> +		return TestPass;
> +	}
>  };
>  
> -int Format::run()
> -{
> -	V4L2DeviceFormat format = {};
> -
> -	int ret = capture_->getFormat(&format);
> -	if (ret) {
> -		cerr << "Failed to get format" << endl;
> -		return TestFail;
> -	}
> -
> -	format.size = { UINT_MAX, UINT_MAX };
> -	ret = capture_->setFormat(&format);
> -	if (ret) {
> -		cerr << "Failed to set format: image resolution is invalid: "
> -		     << "(UINT_MAX x UINT_MAX) but setFormat() should not fail."
> -		     << endl;
> -		return TestFail;
> -	}
> -
> -	if (format.size.width == UINT_MAX ||
> -	    format.size.height == UINT_MAX) {
> -		cerr << "Failed to update image format = (UINT_MAX x UINT_MAX)"
> -		     << endl;
> -		return TestFail;
> -	}
> -
> -	return TestPass;
> -}
> -
>  TEST_REGISTER(Format);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list