[libcamera-devel] [PATCH v1 3/6] tests: delayed_controls: Add cookie value test
Naushir Patuck
naush at raspberrypi.com
Fri Sep 2 14:08:05 CEST 2022
Add a test for passing and returning cookie values in DelayedControls.
Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
---
test/delayed_controls.cpp | 44 +++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/test/delayed_controls.cpp b/test/delayed_controls.cpp
index 322c545998b2..5cc7d3aed4fd 100644
--- a/test/delayed_controls.cpp
+++ b/test/delayed_controls.cpp
@@ -267,6 +267,45 @@ protected:
return TestPass;
}
+ int cookieValue()
+ {
+ std::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {
+ { V4L2_CID_BRIGHTNESS, { 1, false } },
+ };
+ std::unique_ptr<DelayedControls> delayed =
+ std::make_unique<DelayedControls>(dev_.get(), delays);
+ ControlList ctrls;
+
+ /* Set a cookie to the reset value. */
+ const unsigned int startCookie = 0x1234;
+ ctrls.set(V4L2_CID_BRIGHTNESS, 1);
+ dev_->setControls(&ctrls);
+ delayed->reset(startCookie);
+
+ /* Trigger the first frame start event */
+ delayed->applyControls(0);
+
+ for (unsigned int i = 1; i < 100; i++) {
+ ctrls.set(V4L2_CID_BRIGHTNESS, 1);
+ delayed->push(ctrls, startCookie + i);
+
+ delayed->applyControls(i);
+
+ auto [result, cookie] = delayed->get(i);
+ unsigned int expected = startCookie + i - 1;
+ if (cookie != expected) {
+ cerr << "Failed cookie value"
+ << " frame " << i
+ << " expected cookie " << expected
+ << " got cookie " << cookie
+ << endl;
+ return TestFail;
+ }
+ }
+
+ return TestPass;
+ }
+
int run() override
{
int ret;
@@ -291,6 +330,11 @@ protected:
if (ret)
return ret;
+ /* Test cookie values. */
+ ret = cookieValue();
+ if (ret)
+ return ret;
+
return TestPass;
}
--
2.25.1
More information about the libcamera-devel
mailing list