[libcamera-devel] [PATCH] test: buffer_import: Propagate status code from buffer allocation

Niklas Söderlund niklas.soderlund at ragnatech.se
Sun Jan 19 00:07:38 CET 2020


Hi Laurent,

Thanks for your patch.

On 2020-01-18 23:26:19 +0200, Laurent Pinchart wrote:
> The BufferSource::allocate() return value isn't propagated correctly,
> resulting in a test failure when the test should be skipped due to a
> missing vivid device. Fix it.
> 
> While at it, return valid status codes from BufferSource::allocate() in
> all error cases, with proper diagnostic messages.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> ---
>  test/camera/buffer_import.cpp | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
> index e7048335e031..16bfca9beeea 100644
> --- a/test/camera/buffer_import.cpp
> +++ b/test/camera/buffer_import.cpp
> @@ -89,15 +89,23 @@ public:
>  		ret = video_->getFormat(&format);
>  		if (ret) {
>  			std::cout << "Failed to get format on output device" << std::endl;
> -			return ret;
> +			return TestFail;
>  		}
>  
>  		format.size = config.size;
>  		format.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false);
> -		if (video_->setFormat(&format))
> +		if (video_->setFormat(&format)) {
> +			std::cout << "Failed to set format on output device" << std::endl;
>  			return TestFail;
> +		}
>  
> -		return video_->exportBuffers(config.bufferCount, &buffers_);
> +		ret = video_->exportBuffers(config.bufferCount, &buffers_);
> +		if (ret < 0) {
> +			std::cout << "Failed to export buffers" << std::endl;
> +			return TestFail;
> +		}
> +
> +		return TestPass;
>  	}
>  
>  	const std::vector<std::unique_ptr<FrameBuffer>> &buffers()
> @@ -178,8 +186,8 @@ protected:
>  
>  		BufferSource source;
>  		int ret = source.allocate(cfg);
> -		if (ret < 0)
> -			return TestFail;
> +		if (ret != TestPass)
> +			return ret;
>  
>  		std::vector<Request *> requests;
>  		for (const std::unique_ptr<FrameBuffer> &buffer : source.buffers()) {
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list