{"id":646,"url":"https://patchwork.libcamera.org/api/1.1/patches/646/?format=json","web_url":"https://patchwork.libcamera.org/patch/646/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190227173837.6902-8-jacopo@jmondi.org>","date":"2019-02-27T17:38:36","name":"[libcamera-devel,v4,7/8] test: v4l2_subdevice: Add ListFormat test","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"54b18814f71ea280a8e6e85ad956b211d68877f8","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/646/mbox/","series":[{"id":194,"url":"https://patchwork.libcamera.org/api/1.1/series/194/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=194","date":"2019-02-27T17:38:29","name":"v4l2_(sub)dev: improvements and tests","version":4,"mbox":"https://patchwork.libcamera.org/series/194/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/646/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/646/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 69837610B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 18:38:18 +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 00A0E10000D;\n\tWed, 27 Feb 2019 17:38:17 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 27 Feb 2019 18:38:36 +0100","Message-Id":"<20190227173837.6902-8-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190227173837.6902-1-jacopo@jmondi.org>","References":"<20190227173837.6902-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 7/8] 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":"Wed, 27 Feb 2019 17:38:18 -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..b40e1f124539\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 subdevice \"\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 subdevice \"\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","v4","7/8"]}