{"id":637,"url":"https://patchwork.libcamera.org/api/patches/637/?format=json","web_url":"https://patchwork.libcamera.org/patch/637/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190226162641.12116-8-jacopo@jmondi.org>","date":"2019-02-26T16:26:40","name":"[libcamera-devel,v3,7/8] test: v4l2_device: Add format handling test","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ca8698f88ee1d45f5a946ed8958bbd82f3995fad","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/637/mbox/","series":[{"id":193,"url":"https://patchwork.libcamera.org/api/series/193/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=193","date":"2019-02-26T16:26:33","name":"v4l2_(sub)dev: improvements and tests","version":3,"mbox":"https://patchwork.libcamera.org/series/193/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/637/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/637/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E382610B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Feb 2019 17:26:22 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 2432F60004;\n\tTue, 26 Feb 2019 16:26:21 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 26 Feb 2019 17:26:40 +0100","Message-Id":"<20190226162641.12116-8-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190226162641.12116-1-jacopo@jmondi.org>","References":"<20190226162641.12116-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling 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":"Tue, 26 Feb 2019 16:26:22 -0000"},"content":"Add test for V4L2Device set and get format methods.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/v4l2_device/meson.build      |  1 +\n test/v4l2_device/test_formats.cpp | 65 +++++++++++++++++++++++++++++++\n 2 files changed, 66 insertions(+)\n create mode 100644 test/v4l2_device/test_formats.cpp","diff":"diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\nindex 9f7a7545ac9b..e5e50faac282 100644\n--- a/test/v4l2_device/meson.build\n+++ b/test/v4l2_device/meson.build\n@@ -6,6 +6,7 @@ v4l2_device_tests = [\n   [ 'stream_on_off',      'stream_on_off.cpp' ],\n   [ 'capture_async',      'capture_async.cpp' ],\n   [ 'buffer_sharing',     'buffer_sharing.cpp' ],\n+  [ 'test_formats',\t  'test_formats.cpp' ],\n ]\n \n foreach t : v4l2_device_tests\ndiff --git a/test/v4l2_device/test_formats.cpp b/test/v4l2_device/test_formats.cpp\nnew file mode 100644\nindex 000000000000..dcb05a3904f7\n--- /dev/null\n+++ b/test/v4l2_device/test_formats.cpp\n@@ -0,0 +1,65 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 device format handling test\n+ */\n+\n+#include <climits>\n+#include <iostream>\n+\n+#include \"v4l2_device.h\"\n+\n+#include \"v4l2_device_test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class Format : public V4L2DeviceTest\n+{\n+protected:\n+\tint run();\n+};\n+\n+int Format::run()\n+{\n+\tV4L2DeviceFormat format = {};\n+\n+\tint ret = capture_->getFormat(&format);\n+\tif (ret) {\n+\t\tcerr << \"Failed to get format\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tformat.width = UINT_MAX;\n+\tformat.height = UINT_MAX;\n+\tret = capture_->setFormat(&format);\n+\tif (ret) {\n+\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n+\t\t     << \"setFormat() should not fail.\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n+\t\tcerr << \"Failed to update image format\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tformat.width = 0;\n+\tformat.height = 0;\n+\tret = capture_->setFormat(&format);\n+\tif (ret) {\n+\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n+\t\t     << \"setFormat() should not fail.\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tif (format.width == 0 || format.height == 0) {\n+\t\tcerr << \"Failed to update image format\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+TEST_REGISTER(Format);\n","prefixes":["libcamera-devel","v3","7/8"]}