Show a patch.

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

{
    "id": 10478,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10478/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10478/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20201123164319.152742-8-kieran.bingham@ideasonboard.com>",
    "date": "2020-11-23T16:43:18",
    "name": "[libcamera-devel,RFC,7/8] test: Add configuration parser tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "d22e8b26e59fd39a121499c7481bd8228e0973fe",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10478/mbox/",
    "series": [
        {
            "id": 1477,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1477/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1477",
            "date": "2020-11-23T16:43:11",
            "name": "Configuration files and parsing",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1477/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10478/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10478/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 4FE17BE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Nov 2020 16:45:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 15E61633F6;\n\tMon, 23 Nov 2020 17:45:05 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E407633F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Nov 2020 17:45:00 +0100 (CET)",
            "from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AFF9171;\n\tMon, 23 Nov 2020 17:44:59 +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=\"Fc2CrJSM\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1606149899;\n\tbh=AWhmdsy7jYmfQVRscIK7cYnS6iEbSVhlB6iSzv6l2RI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Fc2CrJSMFXH8cpRvLAVd6QyRwgipzhGxaZs3I4yos4NufH7ZOH8yRNIV2gZJ6Cq/s\n\t90PI8JiH2oMd/JiETM920dL93RPRW3L9N+FC6zC0/4bRWbcRuBXJEyDZrESQhJjmKX\n\tokQYqzKjEh7wJvqU2xMwx9IHgvf7qOdOYm6JMY1c=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Mon, 23 Nov 2020 16:43:18 +0000",
        "Message-Id": "<20201123164319.152742-8-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20201123164319.152742-1-kieran.bingham@ideasonboard.com>",
        "References": "<20201123164319.152742-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [RFC PATCH 7/8] test: Add configuration parser\n\ttests",
        "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": "Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/configuration.cpp            | 105 ++++++++++++++++++++++++++++++\n test/data/test_configuration.json |  15 +++++\n test/data/unparsable.json         |   7 ++\n test/meson.build                  |   1 +\n 4 files changed, 128 insertions(+)\n create mode 100644 test/configuration.cpp\n create mode 100644 test/data/test_configuration.json\n create mode 100644 test/data/unparsable.json",
    "diff": "diff --git a/test/configuration.cpp b/test/configuration.cpp\nnew file mode 100644\nindex 000000000000..bed70b1b1218\n--- /dev/null\n+++ b/test/configuration.cpp\n@@ -0,0 +1,105 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * configuration.cpp - Configuration parser tests\n+ */\n+\n+#include \"libcamera/internal/configuration.h\"\n+\n+#include \"test.h\"\n+\n+#include <iostream>\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class ConfigurationTest : public Test\n+{\n+protected:\n+\tint init()\n+\t{\n+\t\treturn TestPass;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\tConfiguration c;\n+\n+\t\t/* Check access of json data before parsing */\n+\t\tif (!c.data().is_null()) {\n+\t\t\tstd::cerr << \"Empty json was not discarded\"\n+\t\t\t\t  << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Failure tests */\n+\t\tint ret = c.open(\"CantFindMe.json\");\n+\t\tif (ret != -ENOENT) {\n+\t\t\tstd::cerr << \"Found an invalid file\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * When run from source, Configuration looks in data/\n+\t\t * Find our test data relative to that.\n+\t\t */\n+\t\tret = c.open(\"../test/data/unparsable.json\");\n+\t\tif (ret != -EINVAL) {\n+\t\t\tstd::cerr << \"Unparsable file parsed\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* We expect to find this in the data/ folder of the sources. */\n+\t\tret = c.open(\"../test/data/test_configuration.json\");\n+\t\tif (ret != 0) {\n+\t\t\tstd::cerr << \"Failed to open configuration data\"\n+\t\t\t\t  << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Parse sample data */\n+\t\tjson j = c.data();\n+\n+\t\tfor (auto &array : j) {\n+\t\t\tstd::cout << array << std::endl;\n+\t\t}\n+\n+\t\tfor (auto &[key, value] : c.data().items()) {\n+\t\t\tstd::cout << key << \" : \" << value << \"\\n\";\n+\t\t}\n+\n+\t\tstd::string cameraName = \"Not Found\";\n+\n+\t\tauto it = j.find(\"device\");\n+\t\tif (it == j.end()) {\n+\t\t\tstd::cerr << \"Failed to find device key\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tstd::cout << \"Device: \" << j[\"device\"] << std::endl;\n+\t\tif (j[\"device\"].contains(\"cameraName\"))\n+\t\t\tcameraName = j[\"device\"][\"cameraName\"];\n+\n+\t\tfor (auto &[key, value] : j[\"device\"].items()) {\n+\t\t\tstd::cout << key << \" : \" << value << \"\\n\";\n+\t\t}\n+\n+\t\tif (cameraName != \"Test Camera Name\") {\n+\t\t\tstd::cerr << \"Failed to find expected string\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t}\n+\n+private:\n+\tstd::string fileName_;\n+};\n+\n+TEST_REGISTER(ConfigurationTest)\n+\ndiff --git a/test/data/test_configuration.json b/test/data/test_configuration.json\nnew file mode 100644\nindex 000000000000..926a14c23f17\n--- /dev/null\n+++ b/test/data/test_configuration.json\n@@ -0,0 +1,15 @@\n+{\n+  \"device\": {\n+\t\"cameraName\": \"Test Camera Name\",\n+\t\"manufacturer\": \"Test Manufacturer\"\n+  },\n+\n+  \"/base/soc/i2c0mux/i2c@1/imx219@10\": {\n+\t\"properties\": {\n+\t\t\"Rotation\" : 0,\n+\t\t\"Location\" : 1\n+\t}\n+  },\n+\n+  \"dummy_key\": \"Sample test string\"\n+}\ndiff --git a/test/data/unparsable.json b/test/data/unparsable.json\nnew file mode 100644\nindex 000000000000..5cf969511242\n--- /dev/null\n+++ b/test/data/unparsable.json\n@@ -0,0 +1,7 @@\n+{\n+  \"\\_SB_.PCI0.XHC_.RHUB.HS05-5:1.0-0408:5251\": {\n+\t\"properties\": {\n+\t\t\"The ID above is invalidly escaped\" : 0,\n+\t\t\"This will not parse\": 1\n+\t}\n+},\ndiff --git a/test/meson.build b/test/meson.build\nindex 0a1d434e3996..6b2105295ddf 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -25,6 +25,7 @@ public_tests = [\n internal_tests = [\n     ['byte-stream-buffer',              'byte-stream-buffer.cpp'],\n     ['camera-sensor',                   'camera-sensor.cpp'],\n+    ['configuration',                   'configuration.cpp'],\n     ['event',                           'event.cpp'],\n     ['event-dispatcher',                'event-dispatcher.cpp'],\n     ['event-thread',                    'event-thread.cpp'],\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "7/8"
    ]
}