summaryrefslogtreecommitdiff
path: root/test/camera/buffer_import.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-18 07:21:25 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-20 13:35:55 +0200
commita39b91d44edfc737ddb26003f663ba26ee14e785 (patch)
treeeca8ffd2b81316be254a99317e4e6e92769a23fc /test/camera/buffer_import.cpp
parent632e0fc09f4e7f32307c101ef9ee970669e1ccf2 (diff)
test: buffer_import: Propagate status code from buffer allocation
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@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'test/camera/buffer_import.cpp')
-rw-r--r--test/camera/buffer_import.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
index e7048335..7c9cfafc 100644
--- a/test/camera/buffer_import.cpp
+++ b/test/camera/buffer_import.cpp
@@ -49,8 +49,6 @@ public:
int allocate(const StreamConfiguration &config)
{
- int ret;
-
/* Locate and open the video device. */
std::string videoDeviceName = "vivid-000-vid-out";
@@ -86,18 +84,24 @@ public:
/* Configure the format. */
V4L2DeviceFormat format;
- ret = video_->getFormat(&format);
- if (ret) {
+ if (video_->getFormat(&format)) {
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;
+ }
+
+ if (video_->exportBuffers(config.bufferCount, &buffers_) < 0) {
+ std::cout << "Failed to export buffers" << std::endl;
return TestFail;
+ }
- return video_->exportBuffers(config.bufferCount, &buffers_);
+ return TestPass;
}
const std::vector<std::unique_ptr<FrameBuffer>> &buffers()
@@ -178,8 +182,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()) {