[libcamera-devel] [PATCH] test: buffer_import: Propagate status code from buffer allocation
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat Jan 18 22:26:19 CET 2020
The BufferSource::allocate() return value isn't propagated correctly,
resulting in a test failure when the test should be skipped due to a
missing vivid device. Fix it.
While at it, return valid status codes from BufferSource::allocate() in
all error cases, with proper diagnostic messages.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
test/camera/buffer_import.cpp | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
index e7048335e031..16bfca9beeea 100644
--- a/test/camera/buffer_import.cpp
+++ b/test/camera/buffer_import.cpp
@@ -89,15 +89,23 @@ public:
ret = video_->getFormat(&format);
if (ret) {
std::cout << "Failed to get format on output device" << std::endl;
- return ret;
+ return TestFail;
}
format.size = config.size;
format.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false);
- if (video_->setFormat(&format))
+ if (video_->setFormat(&format)) {
+ std::cout << "Failed to set format on output device" << std::endl;
return TestFail;
+ }
- return video_->exportBuffers(config.bufferCount, &buffers_);
+ ret = video_->exportBuffers(config.bufferCount, &buffers_);
+ if (ret < 0) {
+ std::cout << "Failed to export buffers" << std::endl;
+ return TestFail;
+ }
+
+ return TestPass;
}
const std::vector<std::unique_ptr<FrameBuffer>> &buffers()
@@ -178,8 +186,8 @@ protected:
BufferSource source;
int ret = source.allocate(cfg);
- if (ret < 0)
- return TestFail;
+ if (ret != TestPass)
+ return ret;
std::vector<Request *> requests;
for (const std::unique_ptr<FrameBuffer> &buffer : source.buffers()) {
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list