[libcamera-devel] [PATCH v5 8/8] test: Test V4L2BufferCache::isEmpty() member function

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Mar 28 01:12:09 CEST 2022


Hi Naush,

Thank you for the patch.

On Fri, Mar 25, 2022 at 09:09:03AM +0000, Naushir Patuck via libcamera-devel wrote:
> Add a test for V4L2BufferCache::isEmpty() for various levels for cache fullness.
> 
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>

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

You also have a R-b from Kieran on v4.

> ---
>  test/v4l2_videodevice/buffer_cache.cpp | 36 ++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp
> index b3f2bec11783..5a9aa2199c50 100644
> --- a/test/v4l2_videodevice/buffer_cache.cpp
> +++ b/test/v4l2_videodevice/buffer_cache.cpp
> @@ -126,6 +126,35 @@ public:
>  		return TestPass;
>  	}
>  
> +	int testIsEmpty(const std::vector<std::unique_ptr<FrameBuffer>> &buffers)
> +	{
> +		V4L2BufferCache cache(buffers.size());
> +
> +		if (!cache.isEmpty())
> +			return TestFail;
> +
> +		for (auto const &buffer : buffers) {
> +			FrameBuffer &b = *buffer.get();
> +			cache.get(b);
> +		}
> +
> +		if (cache.isEmpty())
> +			return TestFail;
> +
> +		unsigned int i;
> +		for (i = 0; i < buffers.size() - 1; i++)
> +			cache.put(i);
> +
> +		if (cache.isEmpty())
> +			return TestFail;
> +
> +		cache.put(i);
> +		if (!cache.isEmpty())
> +			return TestFail;
> +
> +		return TestPass;
> +	}
> +
>  	int init() override
>  	{
>  		std::random_device rd;
> @@ -204,6 +233,13 @@ public:
>  		if (testHot(&cacheHalf, buffers, numBuffers / 2) != TestPass)
>  			return TestFail;
>  
> +		/*
> +		 * Test that the isEmpty function reports the correct result at
> +		 * various levels of cache fullness.
> +		 */
> +		if (testIsEmpty(buffers) != TestPass)
> +			return TestFail;
> +
>  		return TestPass;
>  	}
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list