[libcamera-devel,v2,2/3] test: camera_sensor: Test the model() function

Message ID 20200428181650.5071-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit 5c8570cf3719260d58a7a8cf44a655dbf9dcb131
Headers show
Series
  • [libcamera-devel,v2,1/3] libcamera: camera_sensor: Add model() function
Related show

Commit Message

Laurent Pinchart April 28, 2020, 6:16 p.m. UTC
Verify that the sensor model matches the expected value. The whole model
extraction heuristic isn't fully tested as that would require being able
to inject different entity names. It is still useful as an initial step.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/camera-sensor.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jacopo Mondi April 28, 2020, 8:10 p.m. UTC | #1
Hi Laurent,

On Tue, Apr 28, 2020 at 09:16:49PM +0300, Laurent Pinchart wrote:
> Verify that the sensor model matches the expected value. The whole model
> extraction heuristic isn't fully tested as that would require being able
> to inject different entity names. It is still useful as an initial step.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  test/camera-sensor.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp
> index 27c190fe7ace..6069d668e495 100644
> --- a/test/camera-sensor.cpp
> +++ b/test/camera-sensor.cpp
> @@ -61,6 +61,12 @@ protected:
>
>  	int run()
>  	{
> +		if (sensor_->model() != "Sensor A") {
> +			cerr << "Incorrect sensor model '" << sensor_->model()
> +			     << "'" << endl;
> +			return TestFail;
> +		}
> +
>  		const std::vector<unsigned int> &codes = sensor_->mbusCodes();
>  		auto iter = std::find(codes.begin(), codes.end(),
>  				      MEDIA_BUS_FMT_ARGB8888_1X32);
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp
index 27c190fe7ace..6069d668e495 100644
--- a/test/camera-sensor.cpp
+++ b/test/camera-sensor.cpp
@@ -61,6 +61,12 @@  protected:
 
 	int run()
 	{
+		if (sensor_->model() != "Sensor A") {
+			cerr << "Incorrect sensor model '" << sensor_->model()
+			     << "'" << endl;
+			return TestFail;
+		}
+
 		const std::vector<unsigned int> &codes = sensor_->mbusCodes();
 		auto iter = std::find(codes.begin(), codes.end(),
 				      MEDIA_BUS_FMT_ARGB8888_1X32);