Show a patch.

GET /api/patches/11431/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 11431,
    "url": "https://patchwork.libcamera.org/api/patches/11431/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11431/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20210302093318.437308-4-paul.elder@ideasonboard.com>",
    "date": "2021-03-02T09:33:18",
    "name": "[libcamera-devel,v10,3/3] tests: Test IPA serializer generation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "af6064046c2903442c178b7acaf6452f7dcfc19e",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11431/mbox/",
    "series": [
        {
            "id": 1736,
            "url": "https://patchwork.libcamera.org/api/series/1736/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1736",
            "date": "2021-03-02T09:33:15",
            "name": "IPA isolation tests",
            "version": 10,
            "mbox": "https://patchwork.libcamera.org/series/1736/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11431/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11431/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 783E2BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Mar 2021 09:33:37 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4357768A97;\n\tTue,  2 Mar 2021 10:33:37 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B62860106\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Mar 2021 10:33:35 +0100 (CET)",
            "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7A4398F3;\n\tTue,  2 Mar 2021 10:33:33 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MKzKcrRh\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614677614;\n\tbh=SHTTcwqtT5hWucqeGCz52gCAq7U5+I7JBrqJrb2Qytk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=MKzKcrRhOciqnfC7ZZjYtZcNRuc/yGJ1d5eoBPkanivFopfA5c4Ie95S2rdY06t1U\n\t69QjwOn56gyHLXyfwRT+x0JjnAQphVGfX1UQdq1hClml8rCgEEk4/VIUPymNK7e/Ka\n\tsnQnXgzWsEj1sinr/x0WtMLwAqih4bXgs6Zx6B9s=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  2 Mar 2021 18:33:18 +0900",
        "Message-Id": "<20210302093318.437308-4-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20210302093318.437308-1-paul.elder@ideasonboard.com>",
        "References": "<20210302093318.437308-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v10 3/3] tests: Test IPA serializer\n\tgeneration",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a test to confirm that serializer and header generation works\nproperly for mojom definition files, and that the serializer works\nproperly.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v10:\n- move test.mojom to a subdirectory in the test directory for clean\n  including\n- rename everything vimc to test (for real)\n\nChanges in v9:\n- rename everything vimc to test\n- add std:: to vectors and ties\n\nNo change in v8\n\nChanges in v7:\n- add test to test serdes of a vector of *generated* structs\n\nChanges in v6:\n- use namespacing in the mojom file, and in the test\n- add the enum to the test mojom file, as vimc.h no longer exists\n\nChanges in v5:\n- add dummy event to event interface\n\nNew in v4\n---\n .../generated_serializer_test.cpp             | 156 ++++++++++++++++++\n .../include/libcamera/ipa/meson.build         |  40 +++++\n .../include/libcamera/ipa/test.mojom          |  33 ++++\n .../generated_serializer/meson.build          |  19 +++\n test/serialization/meson.build                |   2 +\n 5 files changed, 250 insertions(+)\n create mode 100644 test/serialization/generated_serializer/generated_serializer_test.cpp\n create mode 100644 test/serialization/generated_serializer/include/libcamera/ipa/meson.build\n create mode 100644 test/serialization/generated_serializer/include/libcamera/ipa/test.mojom\n create mode 100644 test/serialization/generated_serializer/meson.build",
    "diff": "diff --git a/test/serialization/generated_serializer/generated_serializer_test.cpp b/test/serialization/generated_serializer/generated_serializer_test.cpp\nnew file mode 100644\nindex 00000000..698c81d6\n--- /dev/null\n+++ b/test/serialization/generated_serializer/generated_serializer_test.cpp\n@@ -0,0 +1,156 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * generated_serializer_test.cpp - Test generated serializer\n+ */\n+\n+#include <algorithm>\n+#include <tuple>\n+#include <vector>\n+\n+#include \"test.h\"\n+\n+#include \"test_ipa_interface.h\"\n+#include \"test_ipa_serializer.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class IPAGeneratedSerializerTest : public Test\n+{\n+protected:\n+\tint init() override\n+\t{\n+\t\treturn TestPass;\n+\t}\n+\n+\tint run() override\n+\t{\n+\n+#define TEST_FIELD_EQUALITY(struct1, struct2, field)\t\t\\\n+if (struct1.field != struct2.field) {\t\t\t\t\\\n+\tcerr << #field << \" field incorrect: expected \\\"\"\t\\\n+\t     << t.field << \"\\\", got \\\"\" << u.field << \"\\\"\" << endl;\\\n+\treturn TestFail;\t\t\t\t\t\\\n+}\n+\n+\t\tipa::test::TestStruct t, u;\n+\n+\t\tt.m = {\n+\t\t\t{ \"a\", \"z\" },\n+\t\t\t{ \"b\", \"z\" },\n+\t\t\t{ \"c\", \"z\" },\n+\t\t\t{ \"d\", \"z\" },\n+\t\t\t{ \"e\", \"z\" },\n+\t\t};\n+\n+\t\tt.a = { \"a\", \"b\", \"c\", \"d\", \"e\" };\n+\n+\t\tt.s1 = \"hello world\";\n+\t\tt.s2 = \"goodbye\";\n+\t\tt.s3 = \"lorem ipsum\";\n+\t\tt.i  = 58527;\n+\n+\t\tstd::vector<uint8_t> serialized;\n+\n+\t\tstd::tie(serialized, ignore) =\n+\t\t\tIPADataSerializer<ipa::test::TestStruct>::serialize(t);\n+\n+\t\tu = IPADataSerializer<ipa::test::TestStruct>::deserialize(serialized);\n+\n+\t\tif (!equals(t.m, u.m))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!equals(t.a, u.a))\n+\t\t\treturn TestFail;\n+\n+\t\tTEST_FIELD_EQUALITY(t, u, s1);\n+\t\tTEST_FIELD_EQUALITY(t, u, s2);\n+\t\tTEST_FIELD_EQUALITY(t, u, s3);\n+\t\tTEST_FIELD_EQUALITY(t, u, i);\n+\n+\n+\t\t/* Test vector of generated structs */\n+\t\tstd::vector<ipa::test::TestStruct> v = { t, u };\n+\t\tstd::vector<ipa::test::TestStruct> w;\n+\n+\t\tstd::tie(serialized, ignore) =\n+\t\t\tIPADataSerializer<vector<ipa::test::TestStruct>>::serialize(v);\n+\n+\t\tw = IPADataSerializer<vector<ipa::test::TestStruct>>::deserialize(serialized);\n+\n+\t\tif (!equals(v[0].m, w[0].m) ||\n+\t\t    !equals(v[1].m, w[1].m))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!equals(v[0].a, w[0].a) ||\n+\t\t    !equals(v[1].a, w[1].a))\n+\t\t\treturn TestFail;\n+\n+\t\tTEST_FIELD_EQUALITY(v[0], w[0], s1);\n+\t\tTEST_FIELD_EQUALITY(v[0], w[0], s2);\n+\t\tTEST_FIELD_EQUALITY(v[0], w[0], s3);\n+\t\tTEST_FIELD_EQUALITY(v[0], w[0], i);\n+\n+\t\tTEST_FIELD_EQUALITY(v[1], w[1], s1);\n+\t\tTEST_FIELD_EQUALITY(v[1], w[1], s2);\n+\t\tTEST_FIELD_EQUALITY(v[1], w[1], s3);\n+\t\tTEST_FIELD_EQUALITY(v[1], w[1], i);\n+\n+\t\treturn TestPass;\n+\t}\n+\n+private:\n+\tbool equals(const map<string, string> &lhs, const map<string, string> &rhs)\n+\t{\n+\t\tbool eq = lhs.size() == rhs.size() &&\n+\t\t\t  equal(lhs.begin(), lhs.end(), rhs.begin(),\n+\t\t\t\t[](auto &a, auto &b) { return a.first == b.first &&\n+\t\t\t\t\t\t\t      a.second == b.second; });\n+\n+\t\tif (eq)\n+\t\t\treturn true;\n+\n+\t\tcerr << \"lhs:\" << endl;\n+\t\tfor (const auto &pair : lhs)\n+\t\t\tcerr << \"- \" << pair.first << \": \"\n+\t\t\t     << pair.second << endl;\n+\n+\t\tcerr << \"rhs:\" << endl;\n+\t\tfor (const auto &pair : rhs)\n+\t\t\tcerr << \"- \" << pair.first << \": \"\n+\t\t\t     << pair.second << endl;\n+\n+\t\treturn false;\n+\t}\n+\n+\tbool equals(const vector<string> &lhs, const vector<string> &rhs)\n+\t{\n+\t\tbool eq = lhs.size() == rhs.size();\n+\n+\t\tif (!eq) {\n+\t\t\tcerr << \"sizes not equal\" << endl;\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tfor (unsigned int i = 0; i < lhs.size(); i++)\n+\t\t\tif (lhs[i] != rhs[i])\n+\t\t\t\teq = false;\n+\n+\t\tif (eq)\n+\t\t\treturn true;\n+\n+\t\tcerr << \"lhs:\" << endl;\n+\t\tfor (const auto &str : lhs)\n+\t\t\tcerr << \"- \" << str << endl;\n+\n+\t\tcerr << \"rhs:\" << endl;\n+\t\tfor (const auto &str : rhs)\n+\t\t\tcerr << \"- \" << str << endl;\n+\n+\t\treturn false;\n+\t}\n+};\n+\n+TEST_REGISTER(IPAGeneratedSerializerTest)\ndiff --git a/test/serialization/generated_serializer/include/libcamera/ipa/meson.build b/test/serialization/generated_serializer/include/libcamera/ipa/meson.build\nnew file mode 100644\nindex 00000000..ba198f7a\n--- /dev/null\n+++ b/test/serialization/generated_serializer/include/libcamera/ipa/meson.build\n@@ -0,0 +1,40 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+# test.mojom-module\n+mojom = custom_target('test_mojom_module',\n+                      input : 'test.mojom',\n+                      output : 'test.mojom-module',\n+                      command : [\n+                          mojom_parser,\n+                          '--output-root', meson.build_root(),\n+                          '--input-root', meson.source_root(),\n+                          '--mojoms', '@INPUT@'\n+                      ])\n+\n+# test_ipa_interface.h\n+generated_test_header = custom_target('test_ipa_interface_h',\n+                       input : mojom,\n+                       output : 'test_ipa_interface.h',\n+                       depends : mojom_templates,\n+                       command : [\n+                           mojom_generator, 'generate',\n+                           '-g', 'libcamera',\n+                           '--bytecode_path', mojom_templates_dir,\n+                           '--libcamera_generate_header',\n+                           '--libcamera_output_path=@OUTPUT@',\n+                           './' +'@INPUT@'\n+                       ])\n+\n+# test_ipa_serializer.h\n+generated_test_serializer = custom_target('test_ipa_serializer_h',\n+                           input : mojom,\n+                           output : 'test_ipa_serializer.h',\n+                           depends : mojom_templates,\n+                           command : [\n+                               mojom_generator, 'generate',\n+                               '-g', 'libcamera',\n+                               '--bytecode_path', mojom_templates_dir,\n+                               '--libcamera_generate_serializer',\n+                               '--libcamera_output_path=@OUTPUT@',\n+                               './' +'@INPUT@'\n+                           ])\ndiff --git a/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom b/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom\nnew file mode 100644\nindex 00000000..5f200885\n--- /dev/null\n+++ b/test/serialization/generated_serializer/include/libcamera/ipa/test.mojom\n@@ -0,0 +1,33 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+\n+module ipa.test;\n+\n+enum IPAOperationCode {\n+\tIPAOperationNone,\n+\tIPAOperationInit,\n+\tIPAOperationStart,\n+\tIPAOperationStop,\n+};\n+\n+struct IPASettings {};\n+\n+struct TestStruct {\n+\tmap<string, string> m;\n+\tarray<string> a;\n+\tstring s1;\n+\tstring s2;\n+\tint32 i;\n+\tstring s3;\n+};\n+\n+interface IPATestInterface {\n+\tinit(IPASettings settings) => (int32 ret);\n+\tstart() => (int32 ret);\n+\tstop();\n+\n+\ttest(TestStruct s);\n+};\n+\n+interface IPATestEventInterface {\n+\tdummyEvent(uint32 val);\n+};\ndiff --git a/test/serialization/generated_serializer/meson.build b/test/serialization/generated_serializer/meson.build\nnew file mode 100644\nindex 00000000..2460e0b1\n--- /dev/null\n+++ b/test/serialization/generated_serializer/meson.build\n@@ -0,0 +1,19 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+subdir('include/libcamera/ipa')\n+\n+exe = executable('generated_serializer_test',\n+                 [\n+                     'generated_serializer_test.cpp',\n+                     generated_test_header,\n+                     generated_test_serializer,\n+                 ],\n+                 dependencies : libcamera_dep,\n+                 link_with : test_libraries,\n+                 include_directories : [\n+                     test_includes_internal,\n+                     './include',\n+                 ])\n+\n+test('generated_serializer_test', exe,\n+     suite : 'generated_serializer', is_parallel : false)\ndiff --git a/test/serialization/meson.build b/test/serialization/meson.build\nindex a4636337..60ebf325 100644\n--- a/test/serialization/meson.build\n+++ b/test/serialization/meson.build\n@@ -1,5 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+subdir('generated_serializer')\n+\n serialization_tests = [\n     ['control_serialization',     'control_serialization.cpp'],\n     ['ipa_data_serializer_test',  'ipa_data_serializer_test.cpp'],\n",
    "prefixes": [
        "libcamera-devel",
        "v10",
        "3/3"
    ]
}