@@ -23,6 +23,8 @@ const std::vector<StreamRole> ROLES = {
StreamRole::Viewfinder
};
+static constexpr unsigned int MAX_SIMULTANEOUS_REQUESTS = 8;
+
static const std::string &roleToString(const StreamRole &role)
{
static const std::map<StreamRole, std::string> rolesMap = {
@@ -59,12 +61,37 @@ void SingleStream::TearDown()
releaseCamera();
}
+class RoleParametrizedTest : public testing::TestWithParam<StreamRole>, public CameraHolder
+{
+public:
+ static std::string nameParameters(const testing::TestParamInfo<RoleParametrizedTest::ParamType> &info);
+
+protected:
+ void SetUp() override;
+ void TearDown() override;
+};
+
+void RoleParametrizedTest::SetUp()
+{
+ acquireCamera();
+}
+
+void RoleParametrizedTest::TearDown()
+{
+ releaseCamera();
+}
+
std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)
{
return roleToString(std::get<0>(info.param)) + "_" +
std::to_string(std::get<1>(info.param));
}
+std::string RoleParametrizedTest::nameParameters(const testing::TestParamInfo<RoleParametrizedTest::ParamType> &info)
+{
+ return roleToString(info.param);
+}
+
/*
* Test single capture cycles
*
@@ -127,8 +154,26 @@ TEST_P(SingleStream, UnbalancedStop)
capture.capture(numRequests);
}
+TEST_P(RoleParametrizedTest, Overflow)
+{
+ auto role = GetParam();
+
+ SimpleCaptureOverflow capture(camera_);
+
+ capture.configure(role);
+
+ capture.allocateBuffers(MAX_SIMULTANEOUS_REQUESTS);
+
+ capture.capture();
+}
+
INSTANTIATE_TEST_SUITE_P(CaptureTests,
SingleStream,
testing::Combine(testing::ValuesIn(ROLES),
testing::ValuesIn(NUMREQUESTS)),
SingleStream::nameParameters);
+
+INSTANTIATE_TEST_SUITE_P(CaptureTests,
+ RoleParametrizedTest,
+ testing::ValuesIn(ROLES),
+ RoleParametrizedTest::nameParameters);
@@ -205,3 +205,32 @@ void SimpleCaptureUnbalanced::requestComplete(Request *request)
if (camera_->queueRequest(request))
loop_->exit(-EINVAL);
}
+
+/* SimpleCaptureOverflow */
+
+SimpleCaptureOverflow::SimpleCaptureOverflow(std::shared_ptr<Camera> camera)
+ : SimpleCapture(camera)
+{
+}
+
+void SimpleCaptureOverflow::capture()
+{
+ start();
+
+ Stream *stream = config_->at(0).stream();
+ const std::vector<std::unique_ptr<FrameBuffer>> &buffers = allocator_->buffers(stream);
+
+ captureCount_ = 0;
+ captureLimit_ = buffers.size();
+
+ queueRequests(stream, buffers);
+
+ runCaptureSession();
+
+ ASSERT_EQ(captureCount_, captureLimit_);
+}
+
+void SimpleCaptureOverflow::requestComplete([[maybe_unused]] Request *request)
+{
+ captureCompleted();
+}
@@ -68,3 +68,14 @@ public:
private:
void requestComplete(libcamera::Request *request) override;
};
+
+class SimpleCaptureOverflow : public SimpleCapture
+{
+public:
+ SimpleCaptureOverflow(std::shared_ptr<libcamera::Camera> camera);
+
+ void capture();
+
+private:
+ void requestComplete(libcamera::Request *request) override;
+};