apps: lc-compliance: Add multi-stream tests
Rename the `SingleStream` test to `SimpleCapture`, and extend it to support using multiple roles. And instantiate another test suite from the `SimpleCapture` test that tests multiple streams in one capture session. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
This commit is contained in:
parent
13cca98046
commit
7fd317adf0
1 changed files with 51 additions and 37 deletions
|
@ -8,7 +8,10 @@
|
||||||
|
|
||||||
#include "capture.h"
|
#include "capture.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <tuple>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
@ -18,19 +21,10 @@ namespace {
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
const int NUMREQUESTS[] = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
|
class SimpleCapture : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>>
|
||||||
|
|
||||||
const StreamRole ROLES[] = {
|
|
||||||
StreamRole::Raw,
|
|
||||||
StreamRole::StillCapture,
|
|
||||||
StreamRole::VideoRecording,
|
|
||||||
StreamRole::Viewfinder
|
|
||||||
};
|
|
||||||
|
|
||||||
class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info);
|
static std::string nameParameters(const testing::TestParamInfo<SimpleCapture::ParamType> &info);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override;
|
void SetUp() override;
|
||||||
|
@ -43,7 +37,7 @@ protected:
|
||||||
* We use gtest's SetUp() and TearDown() instead of constructor and destructor
|
* We use gtest's SetUp() and TearDown() instead of constructor and destructor
|
||||||
* in order to be able to assert on them.
|
* in order to be able to assert on them.
|
||||||
*/
|
*/
|
||||||
void SingleStream::SetUp()
|
void SimpleCapture::SetUp()
|
||||||
{
|
{
|
||||||
Environment *env = Environment::get();
|
Environment *env = Environment::get();
|
||||||
|
|
||||||
|
@ -52,7 +46,7 @@ void SingleStream::SetUp()
|
||||||
ASSERT_EQ(camera_->acquire(), 0);
|
ASSERT_EQ(camera_->acquire(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleStream::TearDown()
|
void SimpleCapture::TearDown()
|
||||||
{
|
{
|
||||||
if (!camera_)
|
if (!camera_)
|
||||||
return;
|
return;
|
||||||
|
@ -61,19 +55,17 @@ void SingleStream::TearDown()
|
||||||
camera_.reset();
|
camera_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)
|
std::string SimpleCapture::nameParameters(const testing::TestParamInfo<SimpleCapture::ParamType> &info)
|
||||||
{
|
{
|
||||||
std::map<StreamRole, std::string> rolesMap = {
|
const auto &[roles, numRequests] = info.param;
|
||||||
{ StreamRole::Raw, "Raw" },
|
std::ostringstream ss;
|
||||||
{ StreamRole::StillCapture, "StillCapture" },
|
|
||||||
{ StreamRole::VideoRecording, "VideoRecording" },
|
|
||||||
{ StreamRole::Viewfinder, "Viewfinder" }
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string roleName = rolesMap[std::get<0>(info.param)];
|
for (StreamRole r : roles)
|
||||||
std::string numRequestsName = std::to_string(std::get<1>(info.param));
|
ss << r << '_';
|
||||||
|
|
||||||
return roleName + "_" + numRequestsName;
|
ss << '_' << numRequests;
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,13 +75,13 @@ std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStre
|
||||||
* failure is a camera that completes less requests than the number of requests
|
* failure is a camera that completes less requests than the number of requests
|
||||||
* queued.
|
* queued.
|
||||||
*/
|
*/
|
||||||
TEST_P(SingleStream, Capture)
|
TEST_P(SimpleCapture, Capture)
|
||||||
{
|
{
|
||||||
auto [role, numRequests] = GetParam();
|
const auto &[roles, numRequests] = GetParam();
|
||||||
|
|
||||||
Capture capture(camera_);
|
Capture capture(camera_);
|
||||||
|
|
||||||
capture.configure({ { role } });
|
capture.configure(roles);
|
||||||
|
|
||||||
capture.run(numRequests, numRequests);
|
capture.run(numRequests, numRequests);
|
||||||
}
|
}
|
||||||
|
@ -101,14 +93,14 @@ TEST_P(SingleStream, Capture)
|
||||||
* a camera that does not clean up correctly in its error path but is only
|
* a camera that does not clean up correctly in its error path but is only
|
||||||
* tested by single-capture applications.
|
* tested by single-capture applications.
|
||||||
*/
|
*/
|
||||||
TEST_P(SingleStream, CaptureStartStop)
|
TEST_P(SimpleCapture, CaptureStartStop)
|
||||||
{
|
{
|
||||||
auto [role, numRequests] = GetParam();
|
const auto &[roles, numRequests] = GetParam();
|
||||||
unsigned int numRepeats = 3;
|
unsigned int numRepeats = 3;
|
||||||
|
|
||||||
Capture capture(camera_);
|
Capture capture(camera_);
|
||||||
|
|
||||||
capture.configure({ { role } });
|
capture.configure(roles);
|
||||||
|
|
||||||
for (unsigned int starts = 0; starts < numRepeats; starts++)
|
for (unsigned int starts = 0; starts < numRepeats; starts++)
|
||||||
capture.run(numRequests, numRequests);
|
capture.run(numRequests, numRequests);
|
||||||
|
@ -121,21 +113,43 @@ TEST_P(SingleStream, CaptureStartStop)
|
||||||
* is a camera that does not handle cancelation of buffers coming back from the
|
* is a camera that does not handle cancelation of buffers coming back from the
|
||||||
* video device while stopping.
|
* video device while stopping.
|
||||||
*/
|
*/
|
||||||
TEST_P(SingleStream, UnbalancedStop)
|
TEST_P(SimpleCapture, UnbalancedStop)
|
||||||
{
|
{
|
||||||
auto [role, numRequests] = GetParam();
|
const auto &[roles, numRequests] = GetParam();
|
||||||
|
|
||||||
Capture capture(camera_);
|
Capture capture(camera_);
|
||||||
|
|
||||||
capture.configure({ { role } });
|
capture.configure(roles);
|
||||||
|
|
||||||
capture.run(numRequests);
|
capture.run(numRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(CaptureTests,
|
const int NUMREQUESTS[] = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
|
||||||
SingleStream,
|
|
||||||
testing::Combine(testing::ValuesIn(ROLES),
|
const std::vector<StreamRole> SINGLEROLES[] = {
|
||||||
|
{ StreamRole::Raw, },
|
||||||
|
{ StreamRole::StillCapture, },
|
||||||
|
{ StreamRole::VideoRecording, },
|
||||||
|
{ StreamRole::Viewfinder, },
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::vector<StreamRole> MULTIROLES[] = {
|
||||||
|
{ StreamRole::Raw, StreamRole::StillCapture },
|
||||||
|
{ StreamRole::Raw, StreamRole::VideoRecording },
|
||||||
|
{ StreamRole::StillCapture, StreamRole::VideoRecording },
|
||||||
|
{ StreamRole::VideoRecording, StreamRole::VideoRecording },
|
||||||
|
};
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(SingleStream,
|
||||||
|
SimpleCapture,
|
||||||
|
testing::Combine(testing::ValuesIn(SINGLEROLES),
|
||||||
testing::ValuesIn(NUMREQUESTS)),
|
testing::ValuesIn(NUMREQUESTS)),
|
||||||
SingleStream::nameParameters);
|
SimpleCapture::nameParameters);
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(MultiStream,
|
||||||
|
SimpleCapture,
|
||||||
|
testing::Combine(testing::ValuesIn(MULTIROLES),
|
||||||
|
testing::ValuesIn(NUMREQUESTS)),
|
||||||
|
SimpleCapture::nameParameters);
|
||||||
|
|
||||||
} /* namespace */
|
} /* namespace */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue