[libcamera-devel] [PATCH v2 2/2] test: controls: control_info_map: Test default constructor
Kieran Bingham
kieran.bingham at ideasonboard.com
Thu Apr 20 12:47:06 CEST 2023
Hi Laurent,
Quoting Laurent Pinchart via libcamera-devel (2023-04-20 11:22:30)
> Hello Mattijs,
>
> Thank you for the patch.
>
> On Wed, Apr 05, 2023 at 10:14:31AM +0200, Mattijs Korpershoek wrote:
> > ControlInfoMap can be default-constructed. In that case, some of its
> > members (like idmap_) can be a nullptr, and ControlInfoMap.find() will segfault.
>
> Not anymore with patch 1/2 :-) It's however best to add the test first,
> to verify it fails, and then the fix, to verify it fixes the problem.
> With patch 1/2 and 2/2 swapped, I would phrase the commit message of
> this patch as
>
> --------
> ControlInfoMap can be default-constructed. In that case, some of its
> members (like idmap_) can be a nullptr. Add a test to ensure that the
> find() function doesn't segfault.
>
> The test is expected to fail, the issue will be fixed by a subsequent
> commit.
> --------
Sorry I have merged this series already - just about the time you wrote
your review.
--
Kieran
>
> > Add a test with a default constructed ControlInfoMap to cover this.
> >
> > Signed-off-by: Mattijs Korpershoek <mkorpershoek at baylibre.com>
> > ---
> > test/controls/control_info_map.cpp | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp
> > index db95945a1580..29b33515e48c 100644
> > --- a/test/controls/control_info_map.cpp
> > +++ b/test/controls/control_info_map.cpp
> > @@ -75,6 +75,13 @@ protected:
> > return TestFail;
> > }
> >
> > + /* Test looking up a control on a default-constructed infoMap */
>
> s/infoMap/infoMap./
>
> With this,
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>
> > + const ControlInfoMap emptyInfoMap;
> > + if (emptyInfoMap.find(12345) != emptyInfoMap.end()) {
> > + cerr << "find() on empty ControlInfoMap failed" << endl;
> > + return TestFail;
> > + }
> > +
> > return TestPass;
> > }
> > };
>
> --
> Regards,
>
> Laurent Pinchart
More information about the libcamera-devel
mailing list