Patch Detail
Show a patch.
GET /api/patches/619/?format=api
{ "id": 619, "url": "https://patchwork.libcamera.org/api/patches/619/?format=api", "web_url": "https://patchwork.libcamera.org/patch/619/", "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": "<20190225121037.11415-6-jacopo@jmondi.org>", "date": "2019-02-25T12:10:36", "name": "[libcamera-devel,v2,5/6] test: v4l2_subdevice: Add ListFormat test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "001b8b70fdda9d63f03c6dc3c3cd24c9fe936ad0", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/619/mbox/", "series": [ { "id": 191, "url": "https://patchwork.libcamera.org/api/series/191/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=191", "date": "2019-02-25T12:10:31", "name": "v4l2_(sub)dev: improvements and tests", "version": 2, "mbox": "https://patchwork.libcamera.org/series/191/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/619/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/619/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3CCDA600FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 Feb 2019 13:10:21 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id BF81F100008;\n\tMon, 25 Feb 2019 12:10:20 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 25 Feb 2019 13:10:36 +0100", "Message-Id": "<20190225121037.11415-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190225121037.11415-1-jacopo@jmondi.org>", "References": "<20190225121037.11415-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 5/6] test: v4l2_subdevice: Add\n\tListFormat 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": "Mon, 25 Feb 2019 12:10:21 -0000" }, "content": "Add test to list formats on a v4l2 subdevice.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/v4l2_subdevice/list_formats.cpp | 76 ++++++++++++++++++++++++++++\n test/v4l2_subdevice/meson.build | 1 +\n 2 files changed, 77 insertions(+)\n create mode 100644 test/v4l2_subdevice/list_formats.cpp", "diff": "diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp\nnew file mode 100644\nindex 000000000000..a726b11df5f9\n--- /dev/null\n+++ b/test/v4l2_subdevice/list_formats.cpp\n@@ -0,0 +1,76 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 Subdevice format handling test\n+ */\n+\n+#include <iostream>\n+#include <vector>\n+\n+#include \"v4l2_subdevice.h\"\n+\n+#include \"v4l2_subdevice_test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+/* List image formats on the \"Scaler\" subdevice of vimc media device. */\n+\n+class ListFormatsTest : public V4L2SubdeviceTest\n+{\n+protected:\n+\tint run();\n+\n+private:\n+\tvoid printFormats(unsigned int pad,\n+\t\t\t std::vector<V4L2SubdeviceFormat> &formats);\n+};\n+\n+void ListFormatsTest::printFormats(unsigned int pad,\n+\t\t\t\t std::vector<V4L2SubdeviceFormat> &formats)\n+{\n+\tcout << \"Enumerate formats on pad \" << pad << endl;\n+\tfor (V4L2SubdeviceFormat &format : formats) {\n+\t\tcout << \"\tMbus code: 0x\" << hex << format.mbus_code << endl;\n+\t\tcout << \"\tWidth: \" << dec << format.width << endl;\n+\t\tcout << \"\tHeight: \" << dec << format.height << endl;\n+\t}\n+}\n+\n+int ListFormatsTest::run()\n+{\n+\t/* List all formats available on existing \"Scaler\" pads. */\n+\tstd::vector<V4L2SubdeviceFormat> formats = {};\n+\n+\tformats = scaler_->formats(0);\n+\tif (formats.empty()) {\n+\t\tcerr << \"Failed to list formats on pad 0 of sudevice \"\n+\t\t << scaler_->deviceNode() << endl;\n+\t\treturn TestFail;\n+\t}\n+\tprintFormats(0, formats);\n+\n+\tformats = {};\n+\tformats = scaler_->formats(1);\n+\tif (formats.empty()) {\n+\t\tcerr << \"Failed to list formats on pad 1 of sudevice \"\n+\t\t << scaler_->deviceNode() << endl;\n+\t\treturn TestFail;\n+\t}\n+\tprintFormats(1, formats);\n+\n+\t/* List format on a non-existing pad, format vector shall be empty. */\n+\tformats = {};\n+\tformats = scaler_->formats(2);\n+\tif (!formats.empty()) {\n+\t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n+\t\t << scaler_->deviceNode()\n+\t\t <<\" should return an empty format list\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+TEST_REGISTER(ListFormatsTest);\ndiff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\nindex a4359fe1bc19..6023d15e1558 100644\n--- a/test/v4l2_subdevice/meson.build\n+++ b/test/v4l2_subdevice/meson.build\n@@ -1,4 +1,5 @@\n v4l2_subdevice_tests = [\n+ [ 'list_formats', 'list_formats.cpp'],\n [ 'test_formats', 'test_formats.cpp'],\n ]\n \n", "prefixes": [ "libcamera-devel", "v2", "5/6" ] }