{"id":620,"url":"https://patchwork.libcamera.org/api/1.1/patches/620/?format=json","web_url":"https://patchwork.libcamera.org/patch/620/","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":"<20190225121037.11415-7-jacopo@jmondi.org>","date":"2019-02-25T12:10:37","name":"[libcamera-devel,v2,6/6] 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/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/620/mbox/","series":[{"id":191,"url":"https://patchwork.libcamera.org/api/1.1/series/191/?format=json","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/620/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/620/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 C90CA610C9\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 57269100008;\n\tMon, 25 Feb 2019 12:10:21 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 25 Feb 2019 13:10:37 +0100","Message-Id":"<20190225121037.11415-7-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 6/6] 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":"Mon, 25 Feb 2019 12:10: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","v2","6/6"]}