Show a patch.

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

{
    "id": 731,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/731/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/731/",
    "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": "<20190313010532.28960-2-niklas.soderlund@ragnatech.se>",
    "date": "2019-03-13T01:05:29",
    "name": "[libcamera-devel,v3,1/4] test: camera: Add read default configuration test",
    "commit_ref": "86a1900657db9448a42593373f62fd7e9db3c6db",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "d9f531e497b91fb1806f7b186bb33787bd9bd031",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/731/mbox/",
    "series": [
        {
            "id": 206,
            "url": "https://patchwork.libcamera.org/api/1.1/series/206/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=206",
            "date": "2019-03-13T01:05:28",
            "name": "test: camera: Add basic tests for the camera",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/206/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/731/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/731/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DCC3610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Mar 2019 02:06:21 +0100 (CET)",
            "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 34d81ee4-452c-11e9-846a-005056917a89;\n\tWed, 13 Mar 2019 02:06:18 +0100 (CET)"
        ],
        "X-Halon-ID": "34d81ee4-452c-11e9-846a-005056917a89",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 13 Mar 2019 02:05:29 +0100",
        "Message-Id": "<20190313010532.28960-2-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190313010532.28960-1-niklas.soderlund@ragnatech.se>",
        "References": "<20190313010532.28960-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 1/4] test: camera: Add read default\n\tconfiguration test",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Wed, 13 Mar 2019 01:06:21 -0000"
    },
    "content": "Add a test to verify reading the default configuration from a camera\nworks.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/camera/camera_test.cpp           | 74 +++++++++++++++++++++++++++\n test/camera/camera_test.h             | 35 +++++++++++++\n test/camera/configuration_default.cpp | 71 +++++++++++++++++++++++++\n test/camera/meson.build               | 12 +++++\n test/meson.build                      |  1 +\n 5 files changed, 193 insertions(+)\n create mode 100644 test/camera/camera_test.cpp\n create mode 100644 test/camera/camera_test.h\n create mode 100644 test/camera/configuration_default.cpp\n create mode 100644 test/camera/meson.build",
    "diff": "diff --git a/test/camera/camera_test.cpp b/test/camera/camera_test.cpp\nnew file mode 100644\nindex 0000000000000000..a92f2165bf3a53c1\n--- /dev/null\n+++ b/test/camera/camera_test.cpp\n@@ -0,0 +1,74 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera Camera API tests\n+ */\n+\n+#include <iostream>\n+\n+#include \"camera_test.h\"\n+\n+using namespace libcamera;\n+using namespace std;\n+\n+int CameraTest::init()\n+{\n+\tcm_ = CameraManager::instance();\n+\n+\tif (cm_->start()) {\n+\t\tcout << \"Failed to start camera manager\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tcamera_ = cm_->get(\"VIMC Sensor B\");\n+\tif (!camera_) {\n+\t\tcout << \"Can not find VIMC camera\" << endl;\n+\t\treturn TestSkip;\n+\t}\n+\n+\t/* Sanity check that the camera has streams. */\n+\tif (camera_->streams().empty()) {\n+\t\tcout << \"Camera has no stream\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+void CameraTest::cleanup()\n+{\n+\tif (camera_) {\n+\t\tcamera_->release();\n+\t\tcamera_.reset();\n+\t}\n+\n+\tcm_->stop();\n+};\n+\n+bool CameraTest::configurationValid(const std::set<Stream *> &streams,\n+\t\t\t\t    const std::map<Stream *, StreamConfiguration> &conf) const\n+{\n+\t/* Test that the numbers of streams matches that of configuration. */\n+\tif (streams.size() != conf.size())\n+\t\treturn false;\n+\n+\t/*\n+\t * Test that stream can be found in configuration and that the\n+\t * configuration is valid.\n+\t */\n+\tfor (Stream *stream : streams) {\n+\t\tstd::map<Stream *, StreamConfiguration>::const_iterator it =\n+\t\t\tconf.find(stream);\n+\n+\t\tif (it == conf.end())\n+\t\t\treturn false;\n+\n+\t\tconst StreamConfiguration *sconf = &it->second;\n+\t\tif (sconf->width == 0 || sconf->height == 0 ||\n+\t\t    sconf->pixelFormat == 0 || sconf->bufferCount == 0)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\ndiff --git a/test/camera/camera_test.h b/test/camera/camera_test.h\nnew file mode 100644\nindex 0000000000000000..48fb47a23fe8f49c\n--- /dev/null\n+++ b/test/camera/camera_test.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * camera_test.h - libcamera camera test base class\n+ */\n+#ifndef __LIBCAMERA_CAMERA_TEST_H__\n+#define __LIBCAMERA_CAMERA_TEST_H__\n+\n+#include <libcamera/libcamera.h>\n+\n+#include \"test.h\"\n+\n+using namespace libcamera;\n+\n+class CameraTest : public Test\n+{\n+public:\n+\tCameraTest()\n+\t\t: cm_(nullptr) {}\n+\n+protected:\n+\tint init();\n+\tvoid cleanup();\n+\n+\tbool configurationValid(const std::set<Stream *> &streams,\n+\t\t\t\tconst std::map<Stream *, StreamConfiguration> &conf) const;\n+\n+\tstd::shared_ptr<Camera> camera_;\n+\n+private:\n+\tCameraManager *cm_;\n+};\n+\n+#endif /* __LIBCAMERA_CAMERA_TEST_H__ */\ndiff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp\nnew file mode 100644\nindex 0000000000000000..71e79844667591b2\n--- /dev/null\n+++ b/test/camera/configuration_default.cpp\n@@ -0,0 +1,71 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera Camera API tests\n+ */\n+\n+#include <iostream>\n+\n+#include \"camera_test.h\"\n+\n+using namespace std;\n+\n+namespace {\n+\n+class ConfigurationDefault : public CameraTest\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tstd::map<Stream *, StreamConfiguration> conf;\n+\n+\t\t/*\n+\t\t * Test that asking for default configuration for a valid\n+\t\t * array of streams returns something valid.\n+\t\t */\n+\t\tstd::set<Stream *> streams = { *camera_->streams().begin() };\n+\t\tconf = camera_->streamConfiguration(streams);\n+\t\tif (conf.empty()) {\n+\t\t\tcout << \"Failed to retrieve configuration for valid streams\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (!configurationValid(streams, conf)) {\n+\t\t\tcout << \"Default configuration invalid\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test that asking for configuration for an empty array of\n+\t\t * streams returns an empty list of configurations.\n+\t\t */\n+\t\tstd::set<Stream *> streams_empty = {};\n+\t\tconf = camera_->streamConfiguration(streams_empty);\n+\t\tif (!conf.empty()) {\n+\t\t\tcout << \"Failed to retrieve configuration for empty streams\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test that asking for configuration for an array of bad streams\n+\t\t * returns an empty list of configurations.\n+\t\t */\n+\t\tStream *stream_bad = reinterpret_cast<Stream *>(0xdeadbeef);\n+\t\tstd::set<Stream *> streams_bad = { stream_bad };\n+\t\tconf = camera_->streamConfiguration(streams_bad);\n+\t\tif (!conf.empty()) {\n+\t\t\tcout << \"Failed to retrieve configuration for bad streams\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+} /* namespace */\n+\n+TEST_REGISTER(ConfigurationDefault);\ndiff --git a/test/camera/meson.build b/test/camera/meson.build\nnew file mode 100644\nindex 0000000000000000..186ba211b9fde026\n--- /dev/null\n+++ b/test/camera/meson.build\n@@ -0,0 +1,12 @@\n+# Tests are listed in order of complexity.\n+# They are not alphabetically sorted.\n+camera_tests = [\n+  [ 'configuration_default',  'configuration_default.cpp' ],\n+]\n+\n+foreach t : camera_tests\n+  exe = executable(t[0], [t[1], 'camera_test.cpp'],\n+                   link_with : test_libraries,\n+                   include_directories : test_includes_internal)\n+  test(t[0], exe, suite: 'camera', is_parallel: false)\n+endforeach\ndiff --git a/test/meson.build b/test/meson.build\nindex 5fb16fa6afb62f8d..71a96921697c0e9e 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -1,5 +1,6 @@\n subdir('libtest')\n \n+subdir('camera')\n subdir('media_device')\n subdir('pipeline')\n subdir('v4l2_device')\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "1/4"
    ]
}