From patchwork Tue Oct 11 10:58:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17583 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B2429C0DA4 for ; Tue, 11 Oct 2022 10:59:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 620EE62D85; Tue, 11 Oct 2022 12:59:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665485964; bh=FQZp1R7GCguTvhcd4r9Ol4LNyOwEN4K5u13hidwZOMI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yLuU8+OUIwEkJoaPhTpkIwxm+mn0qlGN+r6HrDOOkaV8HW+JzJVZJ0RgfohTfOM8z twXbFCktb36fcomNxC9A6jj88jTYOEF2dpOCor0iOyYemKzVebT98ucjCLHFBqoU7X Me3XvrAr0MSY5g7SlQ2EIY61JWR93wOdcqOgSts09kV9GxBUKPZ2F9qk51DarVEuLc j/3TSoo5HhZ7ymNtEC9fOXzdsRKFVKlppfCQ8NPSSzmsc3rjMOQZUB74KNpcbXHgwK 9cRSMWrtuhs/JAS2pK7f2A2nPlkVYMhO5/DywuoP9GqZ/VutVMTLgzZBaz3BlOinpL WJBfurpjLsgpw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F247262D4E for ; Tue, 11 Oct 2022 12:59:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aCl2RTMk"; dkim-atps=neutral Received: from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 523A0143F; Tue, 11 Oct 2022 12:59:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665485962; bh=FQZp1R7GCguTvhcd4r9Ol4LNyOwEN4K5u13hidwZOMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCl2RTMkX1CH9LjYlHLO1VYjkSbz4Inv6FPeDwzZtXbdkLysepvBthjLa77tjFQd9 50i2Rx7pBfNq37sTg5EzGpt4GeFd4N+rpu4Ah+OPPG6Cmn35v0NY/6pB7i72e38ZKb iTZ7tzmsT1Cu56gN77auYbJgGW9EmNZzDJ8YCIlg= To: libcamera-devel@lists.libcamera.org Date: Tue, 11 Oct 2022 19:58:55 +0900 Message-Id: <20221011105859.457567-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221011105859.457567-1-paul.elder@ideasonboard.com> References: <20221011105859.457567-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 5/9] test: generated_serializer: Test Flags that is struct member X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add fields to the test struct to test serialization/deserialization of scoped enums and flags that are struct members. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- Changes in v5: - Add scoped enum to the test (basically the enum that the flag is created from) - This caught something that I missed in v4, which is why there is a v5 instead of just being merged... - Add a TEST_SCOPED_ENUM_EQUALITY macro No change in v4 Changes in v3: - add [scopedEnum] to enum ErrorFlags - s/[Flags]/[flags]/ Changes in v2: - use new attribute-based mojom definition for Flags --- .../generated_serializer_test.cpp | 21 +++++++++++++++++++ .../include/libcamera/ipa/test.mojom | 9 ++++++++ 2 files changed, 30 insertions(+) diff --git a/test/serialization/generated_serializer/generated_serializer_test.cpp b/test/serialization/generated_serializer/generated_serializer_test.cpp index a4639a80..4670fe46 100644 --- a/test/serialization/generated_serializer/generated_serializer_test.cpp +++ b/test/serialization/generated_serializer/generated_serializer_test.cpp @@ -35,6 +35,13 @@ if (struct1.field != struct2.field) { \ return TestFail; \ } +#define TEST_SCOPED_ENUM_EQUALITY(struct1, struct2, field) \ +if (struct1.field != struct2.field) { \ + cerr << #field << " field incorrect" << endl; \ + return TestFail; \ +} + + ipa::test::TestStruct t, u; t.m = { @@ -52,6 +59,12 @@ if (struct1.field != struct2.field) { \ t.s3 = "lorem ipsum"; t.i = 58527; t.c = ipa::test::IPAOperationInit; + t.e = ipa::test::ErrorFlags::Error1; + + Flags flags; + flags |= ipa::test::ErrorFlags::Error1; + flags |= ipa::test::ErrorFlags::Error2; + t.f = flags; std::vector serialized; @@ -72,6 +85,8 @@ if (struct1.field != struct2.field) { \ TEST_FIELD_EQUALITY(t, u, i); TEST_FIELD_EQUALITY(t, u, c); + TEST_SCOPED_ENUM_EQUALITY(t, u, e); + TEST_SCOPED_ENUM_EQUALITY(t, u, f); /* Test vector of generated structs */ std::vector v = { t, u }; @@ -96,12 +111,18 @@ if (struct1.field != struct2.field) { \ TEST_FIELD_EQUALITY(v[0], w[0], i); TEST_FIELD_EQUALITY(v[0], w[0], c); + TEST_SCOPED_ENUM_EQUALITY(v[0], w[0], e); + TEST_SCOPED_ENUM_EQUALITY(v[0], w[0], f); + 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); + TEST_SCOPED_ENUM_EQUALITY(v[1], w[1], e); + TEST_SCOPED_ENUM_EQUALITY(v[1], w[1], f); + 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..91c31642 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, }; +[scopedEnum] enum ErrorFlags { + Error1 = 0x1, + Error2 = 0x2, + Error3 = 0x4, + Error4 = 0x8, +}; + struct IPASettings {}; struct TestStruct { @@ -19,6 +26,8 @@ struct TestStruct { int32 i; string s3; IPAOperationCode c; + ErrorFlags e; + [flags] ErrorFlags f; }; interface IPATestInterface {