[libcamera-devel] [PATCH v2 5/7] test: generated_serializer: Test Flags that is struct member

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Aug 19 02:52:34 CEST 2022


Hi Paul,

Thank you for the patch.

On Thu, Aug 18, 2022 at 03:49:20PM +0900, Paul Elder via libcamera-devel wrote:
> Add a Flags field to the test struct to test
> serialization/deserialization of Flags that are struct members.
> 
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> 
> ---
> Changes in v2:
> - use new attribute-based mojom definition for Flags
> ---
>  .../generated_serializer_test.cpp             | 19 +++++++++++++++++++
>  .../include/libcamera/ipa/test.mojom          |  8 ++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/test/serialization/generated_serializer/generated_serializer_test.cpp b/test/serialization/generated_serializer/generated_serializer_test.cpp
> index a4639a80..a2d71d62 100644
> --- a/test/serialization/generated_serializer/generated_serializer_test.cpp
> +++ b/test/serialization/generated_serializer/generated_serializer_test.cpp
> @@ -53,6 +53,11 @@ if (struct1.field != struct2.field) {				\
>  		t.i  = 58527;
>  		t.c = ipa::test::IPAOperationInit;
>  
> +		Flags<ipa::test::ErrorFlags> flags;
> +		flags |= ipa::test::ErrorFlags::Error1;
> +		flags |= ipa::test::ErrorFlags::Error2;
> +		t.f = flags;
> +
>  		std::vector<uint8_t> serialized;
>  
>  		std::tie(serialized, ignore) =
> @@ -72,6 +77,10 @@ if (struct1.field != struct2.field) {				\
>  		TEST_FIELD_EQUALITY(t, u, i);
>  		TEST_FIELD_EQUALITY(t, u, c);
>  
> +		if (t.f != u.f) {
> +			cerr << "Flags f field incorrect" << endl;
> +			return TestFail;
> +		}
>  
>  		/* Test vector of generated structs */
>  		std::vector<ipa::test::TestStruct> v = { t, u };
> @@ -96,12 +105,22 @@ if (struct1.field != struct2.field) {				\
>  		TEST_FIELD_EQUALITY(v[0], w[0], i);
>  		TEST_FIELD_EQUALITY(v[0], w[0], c);
>  
> +		if (v[0].f != w[0].f) {
> +			cerr << "Flags f field incorrect" << endl;
> +			return TestFail;
> +		}
> +
>  		TEST_FIELD_EQUALITY(v[1], w[1], s1);
>  		TEST_FIELD_EQUALITY(v[1], w[1], s2);
>  		TEST_FIELD_EQUALITY(v[1], w[1], s3);
>  		TEST_FIELD_EQUALITY(v[1], w[1], i);
>  		TEST_FIELD_EQUALITY(v[1], w[1], c);
>  
> +		if (v[1].f != w[1].f) {
> +			cerr << "Flags f field incorrect" << endl;
> +			return TestFail;
> +		}
> +
>  		return TestPass;
>  	}
>  
> diff --git a/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom b/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom
> index 73081b40..698f4e89 100644
> --- a/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom
> +++ b/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom
> @@ -9,6 +9,13 @@ enum IPAOperationCode {
>  	IPAOperationStop,
>  };
>  
> +enum ErrorFlags {

I assume this will become

[scopedEnum] enum ErrorFlags {

> +	Error1 = 0x1,
> +	Error2 = 0x2,
> +	Error3 = 0x4,
> +	Error4 = 0x8,
> +};
> +
>  struct IPASettings {};
>  
>  struct TestStruct {
> @@ -19,6 +26,7 @@ struct TestStruct {
>  	int32 i;
>  	string s3;
>  	IPAOperationCode c;
> +	[Flags] ErrorFlags f;

I forgot to mention that in the review of 4/7, so I'll mention it here:
should the attribute be [flags] to match the camelCase syntax of other
attributes ?

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

>  };
>  
>  interface IPATestInterface {

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list