diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-12-23 12:24:15 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-12-29 11:33:31 +0100 |
commit | e9d1f0e80075b830d180f2690ad758278778560b (patch) | |
tree | dcfa6cb4f245a80b63f9478fb0336a53e7a8e63c | |
parent | c4820aff083050d60b92db4ca4c1c894c3756c93 (diff) |
apps: lc-compliance: Add multi-stream tests
Add a test suite for testing capture operations with multiple
streams.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
-rw-r--r-- | src/apps/lc-compliance/tests/capture_test.cpp | 92 |
1 files changed, 85 insertions, 7 deletions
diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp index 3d3cc977..3f4a2f71 100644 --- a/src/apps/lc-compliance/tests/capture_test.cpp +++ b/src/apps/lc-compliance/tests/capture_test.cpp @@ -16,6 +16,8 @@ using namespace libcamera; +namespace { + const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; const std::vector<std::vector<StreamRole>> ROLES = { { StreamRole::Raw }, @@ -24,6 +26,22 @@ const std::vector<std::vector<StreamRole>> ROLES = { { StreamRole::Viewfinder }, }; +const std::vector<std::array<StreamRole, 2>> MULTIROLES = { + { StreamRole::Raw, StreamRole::StillCapture }, + { StreamRole::Raw, StreamRole::VideoRecording }, + { StreamRole::StillCapture, StreamRole::VideoRecording }, + { StreamRole::VideoRecording, StreamRole::VideoRecording }, +}; + +std::map<StreamRole, std::string> rolesMap = { + { StreamRole::Raw, "Raw" }, + { StreamRole::StillCapture, "StillCapture" }, + { StreamRole::VideoRecording, "VideoRecording" }, + { StreamRole::Viewfinder, "Viewfinder" } +}; + +} /* namespace */ + class SingleStream : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>> { public: @@ -60,13 +78,6 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info) { - std::map<StreamRole, std::string> rolesMap = { - { StreamRole::Raw, "Raw" }, - { StreamRole::StillCapture, "StillCapture" }, - { StreamRole::VideoRecording, "VideoRecording" }, - { StreamRole::Viewfinder, "Viewfinder" } - }; - std::string roleName = rolesMap[std::get<0>(info.param)[0]]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); @@ -134,3 +145,70 @@ INSTANTIATE_TEST_SUITE_P(CaptureTests, testing::Combine(testing::ValuesIn(ROLES), testing::ValuesIn(NUMREQUESTS)), SingleStream::nameParameters); + +class MultiStream : public testing::TestWithParam<std::tuple<std::array<StreamRole, 2>, int>> +{ +public: + static std::string nameParameters(const testing::TestParamInfo<MultiStream::ParamType> &info); + +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr<Camera> camera_; +}; + +/* + * We use gtest's SetUp() and TearDown() instead of constructor and destructor + * in order to be able to assert on them. + */ +void MultiStream::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void MultiStream::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +std::string MultiStream::nameParameters(const testing::TestParamInfo<MultiStream::ParamType> &info) +{ + std::string roleName = rolesMap[std::get<0>(info.param)[0]] + "_" + + rolesMap[std::get<0>(info.param)[1]]; + std::string numRequestsName = std::to_string(std::get<1>(info.param)); + + return roleName + "_" + numRequestsName; +} + +/* + * Test multi-stream capture cycles + * + * Makes sure the camera completes the exact number of requests queued. Example + * failure is a camera that completes less requests than the number of requests + * queued. + */ +TEST_P(MultiStream, Capture) +{ + const auto [roles, numRequests] = GetParam(); + + CaptureBalanced capture(camera_); + + capture.configure(Span<const StreamRole>{ roles }); + + capture.capture(numRequests); +} + +INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, + MultiStream, + testing::Combine(testing::ValuesIn(MULTIROLES), + testing::ValuesIn(NUMREQUESTS)), + MultiStream::nameParameters); |