[libcamera-devel] [PATCH v2 3/5] test: control serialization: Test lookup by ControlId
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Aug 3 18:37:50 CEST 2021
Hi Jacopo,
Thank you for the patch.
On Wed, Jul 28, 2021 at 06:11:14PM +0200, Jacopo Mondi wrote:
> Test that lookup by ControlId reference works in the control
> serialization test.
>
> Also make sure that the control limits are not changed by
> de-serialization.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> test/serialization/control_serialization.cpp | 22 ++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/test/serialization/control_serialization.cpp b/test/serialization/control_serialization.cpp
> index e23383d13bd6..45a706d27ba7 100644
> --- a/test/serialization/control_serialization.cpp
> +++ b/test/serialization/control_serialization.cpp
> @@ -140,6 +140,28 @@ protected:
> return TestFail;
> }
>
> + /* Test lookup by ControlId * on the de-serialized info map. */
> + auto newLimitsIter = newInfoMap.find(&controls::Brightness);
> + if (newLimitsIter == newInfoMap.end()) {
> + cerr << "Lookup by ControlId * failed" << endl;
> + return TestFail;
> + }
> +
> + auto initialLimitsIter = infoMap.find(&controls::Brightness);
> + if (initialLimitsIter == infoMap.end()) {
> + cerr << "Unable to retrieve the original control limits" << endl;
> + return TestFail;
> + }
I think you can drop the check here, as this test is about
serialization, not about testing basic usage of ControlInfoMap. You can
thus write
const ControlInfo &initialLimits = infoMap[&controls::Brightness];
below and drop initialLimitsIter.
> +
> + /* Make sure control limits looked up by id are not changed. */
> + const ControlInfo &newLimits = newLimitsIter->second;
> + const ControlInfo &initialLimits = initialLimitsIter->second;
> + if (newLimits.min().get<float>() != initialLimits.min().get<float>() ||
> + newLimits.max().get<float>() != initialLimits.max().get<float>()) {
You could write
if (newLimits.min() != initialLimits.min() ||
newLimits.max()) != initialLimits.max()) {
Could you also move this patch to the beginning of the series to make
sure the test fails ?
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> + cerr << "The brightness control limits have changed" << endl;
> + return TestFail;
> + }
> +
> /* Deserialize the control list and verify the contents. */
> buffer = ByteStreamBuffer(const_cast<const uint8_t *>(listData.data()),
> listData.size());
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list