From a39b91d44edfc737ddb26003f663ba26ee14e785 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 18 Jan 2020 07:21:25 +0200 Subject: test: buffer_import: Propagate status code from buffer allocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- test/camera/buffer_import.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'test/camera') 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> &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 requests; for (const std::unique_ptr &buffer : source.buffers()) { -- cgit v1.2.1