[v11,14/19] lc-compliance: Add test to queue more requests than hardware depth
diff mbox series

Message ID 20250428090413.38234-15-s.pueschel@pengutronix.de
State New
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Sven Püschel April 28, 2025, 9:02 a.m. UTC
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>

A pipeline handler should be able to handle an arbitrary number of
simultaneous requests by submitting what it can to the video device and
queuing the rest internally until resources are available. This isn't
currently done by some pipeline handlers however [1].

Add a new test to lc-compliance that submits a lot of requests at once
to check if the pipeline handler is behaving well in this situation.

[1] https://bugs.libcamera.org/show_bug.cgi?id=24

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v11:
- Removed Capture class overloading
- Adapted to also handle multiple roles

Changes in v9:
- rebased

(no changes since v6)

Changes in v6:
- Made MAX_SIMULTANEOUS_REQUESTS a constexpr

Changes in v5:
- Updated to use googletest, and CameraHolder and roleToString from previous
  patches
---
 src/apps/lc-compliance/tests/capture_test.cpp | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)

Patch
diff mbox series

diff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp
index 24081fef..3aa82858 100644
--- a/src/apps/lc-compliance/tests/capture_test.cpp
+++ b/src/apps/lc-compliance/tests/capture_test.cpp
@@ -21,6 +21,8 @@  namespace {
 
 using namespace libcamera;
 
+static constexpr unsigned int MAX_SIMULTANEOUS_REQUESTS = 8;
+
 class SimpleCapture : public testing::TestWithParam<std::tuple<std::vector<StreamRole>, int>>, public CameraHolder
 {
 public:
@@ -58,6 +60,36 @@  std::string SimpleCapture::nameParameters(const testing::TestParamInfo<SimpleCap
 	return ss.str();
 }
 
+class RoleParametrizedTest : public testing::TestWithParam<std::vector<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 RoleParametrizedTest::nameParameters(const testing::TestParamInfo<RoleParametrizedTest::ParamType> &info)
+{
+	std::ostringstream ss;
+
+	for (StreamRole r : info.param)
+		ss << r << '_';
+
+	return ss.str();
+}
+
 /*
  * Test single capture cycles
  *
@@ -120,6 +152,19 @@  TEST_P(SimpleCapture, UnbalancedStop)
 	capture.run(numRequests);
 }
 
+TEST_P(RoleParametrizedTest, Overflow)
+{
+	auto roles = GetParam();
+
+	Capture capture(camera_);
+
+	capture.configure(roles);
+
+	capture.allocateBuffers(MAX_SIMULTANEOUS_REQUESTS);
+
+	capture.run(MAX_SIMULTANEOUS_REQUESTS, MAX_SIMULTANEOUS_REQUESTS);
+}
+
 const int NUMREQUESTS[] = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
 
 const std::vector<StreamRole> SINGLEROLES[] = {
@@ -148,4 +193,14 @@  INSTANTIATE_TEST_SUITE_P(MultiStream,
 					  testing::ValuesIn(NUMREQUESTS)),
 			 SimpleCapture::nameParameters);
 
+INSTANTIATE_TEST_SUITE_P(SingleStream,
+			 RoleParametrizedTest,
+			 testing::ValuesIn(SINGLEROLES),
+			 RoleParametrizedTest::nameParameters);
+
+INSTANTIATE_TEST_SUITE_P(MultiStream,
+			 RoleParametrizedTest,
+			 testing::ValuesIn(MULTIROLES),
+			 RoleParametrizedTest::nameParameters);
+
 } /* namespace */