Message ID | 20220905073956.7342-4-naush@raspberrypi.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Naush Thanks for the patch. On Mon, 5 Sept 2022 at 08:40, Naushir Patuck via libcamera-devel <libcamera-devel@lists.libcamera.org> wrote: > > Add a test for passing and returning cookie values in DelayedControls. > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Not a lot to add here... LGTM. Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Thanks! David > --- > 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 >
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; }
Add a test for passing and returning cookie values in DelayedControls. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> --- test/delayed_controls.cpp | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)