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>
This commit is contained in:
parent
632e0fc09f
commit
a39b91d44e
1 changed files with 13 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
return video_->exportBuffers(config.bufferCount, &buffers_);
|
||||
if (video_->exportBuffers(config.bufferCount, &buffers_) < 0) {
|
||||
std::cout << "Failed to export buffers" << std::endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue