Show a patch.

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

{
    "id": 10586,
    "url": "https://patchwork.libcamera.org/api/patches/10586/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10586/",
    "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": "<20201205103106.242080-24-paul.elder@ideasonboard.com>",
    "date": "2020-12-05T10:31:06",
    "name": "[libcamera-devel,v5,23/23] tests: Test IPA serializer generation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "f0959b89efba9c328892eefb5748fb7386beeefe",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/users/17/?format=api",
        "username": "epaul",
        "first_name": "Paul",
        "last_name": "Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/10586/mbox/",
    "series": [
        {
            "id": 1506,
            "url": "https://patchwork.libcamera.org/api/series/1506/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1506",
            "date": "2020-12-05T10:30:43",
            "name": "IPA isolation implementation",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/1506/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10586/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10586/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 9A7CABDB20\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  5 Dec 2020 10:32:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 623EC6360B;\n\tSat,  5 Dec 2020 11:32:07 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D189635FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  5 Dec 2020 11:32:06 +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 D41CC2A4;\n\tSat,  5 Dec 2020 11:32:04 +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=\"gVqKM5oL\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1607164325;\n\tbh=w4O8NFX8tlOHCCs9jFzGKMAlEDd+urJLOME4ogM1QJ8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gVqKM5oLt+FE7jZ596sJG9aMzEjexDm+9UQDoXtNqPcPmyxV0Czxy5ZKZbvNI3JY5\n\tIRN/fyO4O410viQDi2KvgB7qNviBDRBUbLcOHZOnwbUmoR2JfWsoADBMNsw/EvTD4C\n\tB4qrYKwExU0anbbhE22kP32aLtgE/6E3FUPoJWbk=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat,  5 Dec 2020 19:31:06 +0900",
        "Message-Id": "<20201205103106.242080-24-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20201205103106.242080-1-paul.elder@ideasonboard.com>",
        "References": "<20201205103106.242080-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v5 23/23] 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>\n\n---\nChanges in v5:\n- add dummy event to event interface\n\nNew in v4\n---\n .../generated_serializer_test.cpp             | 128 ++++++++++++++++++\n .../generated_serializer/meson.build          |  49 +++++++\n .../generated_serializer/vimc.mojom           |  24 ++++\n test/serialization/meson.build                |   2 +\n 4 files changed, 203 insertions(+)\n create mode 100644 test/serialization/generated_serializer/generated_serializer_test.cpp\n create mode 100644 test/serialization/generated_serializer/meson.build\n create mode 100644 test/serialization/generated_serializer/vimc.mojom",
    "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..57c61b02\n--- /dev/null\n+++ b/test/serialization/generated_serializer/generated_serializer_test.cpp\n@@ -0,0 +1,128 @@\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 \"vimc_test_ipa_interface.h\"\n+#include \"vimc_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\tTestStruct 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\tvector<uint8_t> serialized;\n+\n+\t\ttie(serialized, ignore) =\n+\t\t\tIPADataSerializer<TestStruct>::serialize(t);\n+\n+\t\tu = IPADataSerializer<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+\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/meson.build b/test/serialization/generated_serializer/meson.build\nnew file mode 100644\nindex 00000000..68bcf23d\n--- /dev/null\n+++ b/test/serialization/generated_serializer/meson.build\n@@ -0,0 +1,49 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+# vimc.mojom-module\n+mojom = custom_target('vimc_test_mojom_module',\n+                      input : 'vimc.mojom',\n+                      output : 'vimc.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+# vimc_test_ipa_interface.h\n+header = custom_target('vimc_test_ipa_interface_h',\n+                       input : mojom,\n+                       output : 'vimc_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+# vimc_test_ipa_serializer.h\n+serializer = custom_target('vimc_test_ipa_serializer_h',\n+                           input : mojom,\n+                           output : 'vimc_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+                           ])\n+\n+exe = executable('generated_serializer_test',\n+                 ['generated_serializer_test.cpp', header, serializer],\n+                 dependencies : libcamera_dep,\n+                 link_with : test_libraries,\n+                 include_directories : test_includes_internal)\n+\n+test('generated_serializer_test', exe,\n+     suite : 'generated_serializer', is_parallel : false)\ndiff --git a/test/serialization/generated_serializer/vimc.mojom b/test/serialization/generated_serializer/vimc.mojom\nnew file mode 100644\nindex 00000000..c6f29d61\n--- /dev/null\n+++ b/test/serialization/generated_serializer/vimc.mojom\n@@ -0,0 +1,24 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\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 IPAVimcInterface {\n+\tinit(IPASettings settings) => (int32 ret);\n+\tstart() => (int32 ret);\n+\tstop();\n+\n+\ttest(TestStruct s);\n+};\n+\n+interface IPAVimcEventInterface {\n+\tdummyEvent(uint32 val);\n+};\ndiff --git a/test/serialization/meson.build b/test/serialization/meson.build\nindex c140a31c..57726b12 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",
        "v5",
        "23/23"
    ]
}