mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 14:59:44 +03:00
test: camera: Increase timeout for vimc capture tests
On slower machines, a 1s timeout to capture frames with vimc can be too short and cause test failures. Make the timeout proportional to the number of frames expected to be captured, using a conservative low estimate of the frame rate at 2fps. By itself, that change could increase the test time quite substantially on fast platforms, so break from the capture loop as soon as we capture enough frames. To do so, interrupt the dispatcher at every request completion, or it will only get interrupted after the timer times out. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
This commit is contained in:
parent
a52d818e2b
commit
0554a55427
2 changed files with 29 additions and 14 deletions
|
@ -63,6 +63,8 @@ protected:
|
||||||
request->reuse();
|
request->reuse();
|
||||||
request->addBuffer(stream, buffer);
|
request->addBuffer(stream, buffer);
|
||||||
camera_->queueRequest(request);
|
camera_->queueRequest(request);
|
||||||
|
|
||||||
|
dispatcher_->interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int init() override
|
int init() override
|
||||||
|
@ -76,6 +78,8 @@ protected:
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatcher_ = Thread::current()->eventDispatcher();
|
||||||
|
|
||||||
return TestPass;
|
return TestPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,17 +137,20 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
|
const unsigned int nFrames = cfg.bufferCount * 2;
|
||||||
|
|
||||||
Timer timer;
|
Timer timer;
|
||||||
timer.start(1000ms);
|
timer.start(500ms * nFrames);
|
||||||
while (timer.isRunning())
|
while (timer.isRunning()) {
|
||||||
dispatcher->processEvents();
|
dispatcher_->processEvents();
|
||||||
|
if (completeRequestsCount_ > nFrames)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (completeRequestsCount_ < cfg.bufferCount * 2) {
|
if (completeRequestsCount_ < nFrames) {
|
||||||
std::cout << "Failed to capture enough frames (got "
|
std::cout << "Failed to capture enough frames (got "
|
||||||
<< completeRequestsCount_ << " expected at least "
|
<< completeRequestsCount_ << " expected at least "
|
||||||
<< cfg.bufferCount * 2 << ")" << std::endl;
|
<< nFrames << ")" << std::endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +168,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
EventDispatcher *dispatcher_;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Request>> requests_;
|
std::vector<std::unique_ptr<Request>> requests_;
|
||||||
|
|
||||||
unsigned int completeBuffersCount_;
|
unsigned int completeBuffersCount_;
|
||||||
|
|
|
@ -59,6 +59,8 @@ protected:
|
||||||
request->reuse();
|
request->reuse();
|
||||||
request->addBuffer(stream, buffer);
|
request->addBuffer(stream, buffer);
|
||||||
camera_->queueRequest(request);
|
camera_->queueRequest(request);
|
||||||
|
|
||||||
|
dispatcher_->interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int init() override
|
int init() override
|
||||||
|
@ -73,6 +75,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator_ = new FrameBufferAllocator(camera_);
|
allocator_ = new FrameBufferAllocator(camera_);
|
||||||
|
dispatcher_ = Thread::current()->eventDispatcher();
|
||||||
|
|
||||||
return TestPass;
|
return TestPass;
|
||||||
}
|
}
|
||||||
|
@ -135,19 +138,20 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
|
unsigned int nFrames = allocator_->buffers(stream).size() * 2;
|
||||||
|
|
||||||
Timer timer;
|
Timer timer;
|
||||||
timer.start(1000ms);
|
timer.start(500ms * nFrames);
|
||||||
while (timer.isRunning())
|
while (timer.isRunning()) {
|
||||||
dispatcher->processEvents();
|
dispatcher_->processEvents();
|
||||||
|
if (completeRequestsCount_ > nFrames)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int nbuffers = allocator_->buffers(stream).size();
|
if (completeRequestsCount_ < nFrames) {
|
||||||
|
|
||||||
if (completeRequestsCount_ < nbuffers * 2) {
|
|
||||||
cout << "Failed to capture enough frames (got "
|
cout << "Failed to capture enough frames (got "
|
||||||
<< completeRequestsCount_ << " expected at least "
|
<< completeRequestsCount_ << " expected at least "
|
||||||
<< nbuffers * 2 << ")" << endl;
|
<< nFrames * 2 << ")" << endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +168,8 @@ protected:
|
||||||
return TestPass;
|
return TestPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventDispatcher *dispatcher_;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Request>> requests_;
|
std::vector<std::unique_ptr<Request>> requests_;
|
||||||
|
|
||||||
std::unique_ptr<CameraConfiguration> config_;
|
std::unique_ptr<CameraConfiguration> config_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue