[libcamera-devel] [PATCH v4 3/7] tests: delayed_controls: Add cookie value test
Naushir Patuck
naush at raspberrypi.com
Wed Oct 19 11:01:03 CEST 2022
Add a test for passing and returning cookie values in DelayedControls.
Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: David Plowman <david.plowman 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