[libcamera-devel,v7,11/11] lc-compliance: Add test to ensure MinimumRequests is valid
diff mbox series

Message ID 20210722232851.747614-12-nfraprado@collabora.com
State Superseded
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Nícolas F. R. A. Prado July 22, 2021, 11:28 p.m. UTC
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@collabora.com>
---

Added in v7

 src/lc-compliance/capture_test.cpp | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Laurent Pinchart Aug. 1, 2021, 11:57 p.m. UTC | #1
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@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),

Patch
diff mbox series

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();
+}
+
 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";
+}
+
 INSTANTIATE_TEST_SUITE_P(CaptureTests,
 			 SingleStream,
 			 testing::Combine(testing::ValuesIn(ROLES),