Show a patch.

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

{
    "id": 264,
    "url": "https://patchwork.libcamera.org/api/patches/264/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/264/",
    "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": "<20190117212703.24047-3-kieran.bingham@ideasonboard.com>",
    "date": "2019-01-17T21:27:03",
    "name": "[libcamera-devel,v4,2/2] test: v4l2_device: Add test suite and initial test",
    "commit_ref": "479264dfcaca61f08a0609db584d11d8fb252103",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6233aa9444b7705f6875860316b7ad0fc9903d24",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/264/mbox/",
    "series": [
        {
            "id": 88,
            "url": "https://patchwork.libcamera.org/api/series/88/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=88",
            "date": "2019-01-17T21:27:01",
            "name": "V4L2Device: Add basic V4L2 support class",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/88/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/264/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/264/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40A4860C99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Jan 2019 22:27:13 +0100 (CET)",
            "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C89B8B6B;\n\tThu, 17 Jan 2019 22:27:12 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1547760432;\n\tbh=IMCeMnGyTTQX38rSg2Dop8a0AoZA1vscE7yzFyvGviA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=IRoH4kVF70CUUfmJlFY54g0+P8OerSQUYIMy6Xk1PWIwNYxoMJQl2CZVSAN8ljur9\n\t4UIAcwBqP5LNgnmv8XahW28oEV6q2vsNCgwJ6g039vMdfDCTxIOzpjSMQ4/wfGZMwe\n\t0ZkR5aLubPT1F+8naaYx20wAPMJqXde0eQjLjwlY=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Thu, 17 Jan 2019 21:27:03 +0000",
        "Message-Id": "<20190117212703.24047-3-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190117212703.24047-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190117212703.24047-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 2/2] test: v4l2_device: Add test suite\n\tand initial 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": "Thu, 17 Jan 2019 21:27:13 -0000"
    },
    "content": "Provide a base class to construct a v4l2_device object for further tests\nand an initial test which validates the FD handle can not be leaked.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/meson.build                      |  1 +\n test/v4l2_device/double_open.cpp      | 38 +++++++++++++++++++++++\n test/v4l2_device/meson.build          | 12 ++++++++\n test/v4l2_device/v4l2_device_test.cpp | 43 +++++++++++++++++++++++++++\n test/v4l2_device/v4l2_device_test.h   | 27 +++++++++++++++++\n 5 files changed, 121 insertions(+)\n create mode 100644 test/v4l2_device/double_open.cpp\n create mode 100644 test/v4l2_device/meson.build\n create mode 100644 test/v4l2_device/v4l2_device_test.cpp\n create mode 100644 test/v4l2_device/v4l2_device_test.h",
    "diff": "diff --git a/test/meson.build b/test/meson.build\nindex 32152888a55e..fb6b115eb2ab 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -1,6 +1,7 @@\n subdir('libtest')\n \n subdir('media_device')\n+subdir('v4l2_device')\n \n public_tests = [\n     ['event',           'event.cpp'],\ndiff --git a/test/v4l2_device/double_open.cpp b/test/v4l2_device/double_open.cpp\nnew file mode 100644\nindex 000000000000..ca2b201454a4\n--- /dev/null\n+++ b/test/v4l2_device/double_open.cpp\n@@ -0,0 +1,38 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 API tests\n+ */\n+\n+#include <iostream>\n+\n+#include \"v4l2_device_test.h\"\n+\n+namespace {\n+\n+class DoubleOpen : public V4L2DeviceTest\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tint ret;\n+\n+\t\t/*\n+\t\t * Expect failure: The device has already been opened by the\n+\t\t * V4L2DeviceTest base class\n+\t\t */\n+\t\tret = dev_->open();\n+\t\tif (!ret) {\n+\t\t\tstd::cout << \"Double open erroneously succeeded\" << std::endl;\n+\t\t\tdev_->close();\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+} /* namespace */\n+\n+TEST_REGISTER(DoubleOpen);\ndiff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\nnew file mode 100644\nindex 000000000000..41675a303498\n--- /dev/null\n+++ b/test/v4l2_device/meson.build\n@@ -0,0 +1,12 @@\n+# Tests are listed in order of complexity.\n+# They are not alphabetically sorted.\n+v4l2_device_tests = [\n+  [ 'double_open',        'double_open.cpp' ],\n+]\n+\n+foreach t : v4l2_device_tests\n+  exe = executable(t[0], [t[1], 'v4l2_device_test.cpp'],\n+\t\t   link_with : test_libraries,\n+\t\t   include_directories : test_includes_internal)\n+  test(t[0], exe, suite: 'v4l2_device', is_parallel: false)\n+endforeach\ndiff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp\nnew file mode 100644\nindex 000000000000..362553712caa\n--- /dev/null\n+++ b/test/v4l2_device/v4l2_device_test.cpp\n@@ -0,0 +1,43 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 API tests\n+ */\n+\n+#include <iostream>\n+#include <sys/stat.h>\n+\n+#include \"v4l2_device_test.h\"\n+\n+using namespace libcamera;\n+\n+bool exists(const std::string &path)\n+{\n+\tstruct stat sb;\n+\n+\tif (stat(path.c_str(), &sb) == 0)\n+\t\treturn true;\n+\n+\treturn false;\n+}\n+\n+int V4L2DeviceTest::init()\n+{\n+\tconst std::string device(\"/dev/video0\");\n+\n+\t/* Validate the device node exists. */\n+\tif (!exists(device)) {\n+\t\tstd::cout << \"No video device available\" << std::endl;\n+\t\treturn TestSkip;\n+\t}\n+\n+\tdev_ = new V4L2Device(device);\n+\n+\treturn dev_->open();\n+}\n+\n+void V4L2DeviceTest::cleanup()\n+{\n+\tdelete dev_;\n+};\ndiff --git a/test/v4l2_device/v4l2_device_test.h b/test/v4l2_device/v4l2_device_test.h\nnew file mode 100644\nindex 000000000000..405cb7d6f404\n--- /dev/null\n+++ b/test/v4l2_device/v4l2_device_test.h\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * vl42device_test.h - libcamera v4l2device test base class\n+ */\n+#ifndef __LIBCAMERA_V4L2_DEVICE_TEST_H_\n+#define __LIBCAMERA_V4L2_DEVICE_TEST_H_\n+\n+#include \"test.h\"\n+#include \"v4l2_device.h\"\n+\n+using namespace libcamera;\n+\n+class V4L2DeviceTest : public Test\n+{\n+public:\n+\tV4L2DeviceTest() : dev_(nullptr) { };\n+\n+protected:\n+\tint init();\n+\tvoid cleanup();\n+\n+\tV4L2Device *dev_;\n+};\n+\n+#endif /* __LIBCAMERA_V4L2_DEVICE_TEST_H_ */\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "2/2"
    ]
}