[libcamera-devel] [PATCH v7 11/11] lc-compliance: Add test to ensure MinimumRequests is valid

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Aug 2 01:57:10 CEST 2021


Hi Nícolas,

Thank you for the patch.

On Thu, Jul 22, 2021 at 08:28:51PM -0300, Nícolas F. R. A. Prado wrote:
> Add a test in lc-compliance to check that the MinimumRequests property
> is set and valid, that is, greater than 0.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado at collabora.com>
> ---
> 
> Added in v7
> 
>  src/lc-compliance/capture_test.cpp | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp
> index a7ba7448a21b..8d0da770e901 100644
> --- a/src/lc-compliance/capture_test.cpp
> +++ b/src/lc-compliance/capture_test.cpp
> @@ -101,6 +101,23 @@ void RoleParametrizedTest::TearDown()
>  	releaseCamera();
>  }
>  
> +class CameraTests : public ::testing::Test, public CameraHolder
> +{
> +protected:
> +	void SetUp() override;
> +	void TearDown() override;
> +};
> +
> +void CameraTests::SetUp()
> +{
> +	acquireCamera();
> +}
> +
> +void CameraTests::TearDown()
> +{
> +	releaseCamera();
> +}

There are two  tests that only call acquireCamera() and releaseCamera()
in SetUp() and TearDown(). It would be nice if this didn't have to be
duplicated, but we can't make CameraHolder inherit from ::testing::Test
as the other occurrence inherits from ::testing::TestWithParam. So be
it.

> +
>  std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)
>  {
>  	return roleToString(std::get<0>(info.param)) + "_" +
> @@ -187,6 +204,16 @@ TEST_P(RoleParametrizedTest, Overflow)
>  	capture.capture();
>  }
>  
> +TEST_F(CameraTests, RequiredProperties)
> +{
> +	const ControlList &properties = camera_->properties();
> +
> +	using namespace properties;
> +
> +	EXPECT_GT(properties.get(MinimumRequests), 0)
> +		<< "Camera should have a positive value for MinimumRequests property";
> +}

This isn't a capture test, should it go to a different file ? Maybe
properties.cpp or property_test.cpp ?

> +
>  INSTANTIATE_TEST_SUITE_P(CaptureTests,
>  			 SingleStream,
>  			 testing::Combine(testing::ValuesIn(ROLES),

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list