mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
test: Test V4L2BufferCache::isEmpty() member function
Add a test for V4L2BufferCache::isEmpty() for various levels for cache fullness. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
5704856681
commit
7349031294
1 changed files with 36 additions and 0 deletions
|
@ -126,6 +126,35 @@ public:
|
|||
return TestPass;
|
||||
}
|
||||
|
||||
int testIsEmpty(const std::vector<std::unique_ptr<FrameBuffer>> &buffers)
|
||||
{
|
||||
V4L2BufferCache cache(buffers.size());
|
||||
|
||||
if (!cache.isEmpty())
|
||||
return TestFail;
|
||||
|
||||
for (auto const &buffer : buffers) {
|
||||
FrameBuffer &b = *buffer.get();
|
||||
cache.get(b);
|
||||
}
|
||||
|
||||
if (cache.isEmpty())
|
||||
return TestFail;
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < buffers.size() - 1; i++)
|
||||
cache.put(i);
|
||||
|
||||
if (cache.isEmpty())
|
||||
return TestFail;
|
||||
|
||||
cache.put(i);
|
||||
if (!cache.isEmpty())
|
||||
return TestFail;
|
||||
|
||||
return TestPass;
|
||||
}
|
||||
|
||||
int init() override
|
||||
{
|
||||
std::random_device rd;
|
||||
|
@ -204,6 +233,13 @@ public:
|
|||
if (testHot(&cacheHalf, buffers, numBuffers / 2) != TestPass)
|
||||
return TestFail;
|
||||
|
||||
/*
|
||||
* Test that the isEmpty function reports the correct result at
|
||||
* various levels of cache fullness.
|
||||
*/
|
||||
if (testIsEmpty(buffers) != TestPass)
|
||||
return TestFail;
|
||||
|
||||
return TestPass;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue