[libcamera-devel] [PATCH v2 2/3] test: v4l2_device: Extend formats test with tryFromat()

Kieran Bingham kieran.bingham at ideasonboard.com
Thu May 23 15:58:59 CEST 2019


Add a new test to verify the tryFormat() functionality updates the
attempted format.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 test/v4l2_device/formats.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp
index 6be045ff754c..1ed9901a9e4e 100644
--- a/test/v4l2_device/formats.cpp
+++ b/test/v4l2_device/formats.cpp
@@ -31,6 +31,22 @@ protected:
 			return TestFail;
 		}
 
+		format.size = { UINT_MAX, UINT_MAX };
+		ret = capture_->tryFormat(&format);
+		if (ret) {
+			cerr << "Failed to try format: image resolution is invalid: "
+			     << "(UINT_MAX x UINT_MAX) but setFormat() should not fail."
+			     << endl;
+			return TestFail;
+		}
+
+		if (format.size.width == UINT_MAX ||
+		    format.size.height == UINT_MAX) {
+			cerr << "Failed to update image (try) format = (UINT_MAX x UINT_MAX)"
+			     << endl;
+			return TestFail;
+		}
+
 		format.size = { UINT_MAX, UINT_MAX };
 		ret = capture_->setFormat(&format);
 		if (ret) {
-- 
2.20.1



More information about the libcamera-devel mailing list