Patch Detail
Show a patch.
GET /api/patches/635/?format=api
{ "id": 635, "url": "https://patchwork.libcamera.org/api/patches/635/?format=api", "web_url": "https://patchwork.libcamera.org/patch/635/", "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": "<20190226162641.12116-6-jacopo@jmondi.org>", "date": "2019-02-26T16:26:38", "name": "[libcamera-devel,v3,5/8] test: v4l2_subdevice: Add format handling test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ba05eadefab642b0dbcb7b423523e0a98394cdb1", "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/635/mbox/", "series": [ { "id": 193, "url": "https://patchwork.libcamera.org/api/series/193/?format=api", "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/635/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/635/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 4FD84610B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Feb 2019 17:26: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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D1DCC60008;\n\tTue, 26 Feb 2019 16:26:20 +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:38 +0100", "Message-Id": "<20190226162641.12116-6-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 5/8] test: v4l2_subdevice: 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:21 -0000" }, "content": "Add test for video format get and set operations on V4L2Subdevice class.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/meson.build | 1 +\n test/v4l2_subdevice/meson.build | 10 +++\n test/v4l2_subdevice/test_formats.cpp | 79 ++++++++++++++++++\n test/v4l2_subdevice/v4l2_subdevice_test.cpp | 90 +++++++++++++++++++++\n test/v4l2_subdevice/v4l2_subdevice_test.h | 36 +++++++++\n 5 files changed, 216 insertions(+)\n create mode 100644 test/v4l2_subdevice/meson.build\n create mode 100644 test/v4l2_subdevice/test_formats.cpp\n create mode 100644 test/v4l2_subdevice/v4l2_subdevice_test.cpp\n create mode 100644 test/v4l2_subdevice/v4l2_subdevice_test.h", "diff": "diff --git a/test/meson.build b/test/meson.build\nindex d515a716207e..5fb16fa6afb6 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -3,6 +3,7 @@ subdir('libtest')\n subdir('media_device')\n subdir('pipeline')\n subdir('v4l2_device')\n+subdir('v4l2_subdevice')\n \n public_tests = [\n ['event', 'event.cpp'],\ndiff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\nnew file mode 100644\nindex 000000000000..a4359fe1bc19\n--- /dev/null\n+++ b/test/v4l2_subdevice/meson.build\n@@ -0,0 +1,10 @@\n+v4l2_subdevice_tests = [\n+ [ 'test_formats', 'test_formats.cpp'],\n+]\n+\n+foreach t : v4l2_subdevice_tests\n+ exe = executable(t[0], [t[1], 'v4l2_subdevice_test.cpp'],\n+ link_with : test_libraries,\n+ include_directories : test_includes_internal)\n+ test(t[0], exe, suite: 'v4l2_subdevice', is_parallel: false)\n+endforeach\ndiff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\nnew file mode 100644\nindex 000000000000..91b460f64e7e\n--- /dev/null\n+++ b/test/v4l2_subdevice/test_formats.cpp\n@@ -0,0 +1,79 @@\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 <climits>\n+#include <iostream>\n+\n+#include \"v4l2_subdevice.h\"\n+\n+#include \"v4l2_subdevice_test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+/* Test format handling on the \"Scaler\" subdevice of vimc media device. */\n+\n+class FormatHandlingTest : public V4L2SubdeviceTest\n+{\n+protected:\n+\tint run();\n+};\n+\n+int FormatHandlingTest::run()\n+{\n+\tV4L2SubdeviceFormat format = {};\n+\n+\t/*\n+\t * Get format on a non-existing Scaler pad: expect failure.\n+\t */\n+\tint ret = scaler_->getFormat(2, &format);\n+\tif (!ret) {\n+\t\tcerr << \"Get format on a non existing pad should fail\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tret = scaler_->getFormat(0, &format);\n+\tif (ret) {\n+\t\tcerr << \"Failed to get format\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\t/*\n+\t * Set unrealistic image resolutions and make sure it gets updated.\n+\t */\n+\tformat.width = UINT_MAX;\n+\tformat.height = UINT_MAX;\n+\tret = scaler_->setFormat(0, &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 = scaler_->setFormat(0, &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(FormatHandlingTest);\ndiff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\nnew file mode 100644\nindex 000000000000..10fe2655e5e4\n--- /dev/null\n+++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n@@ -0,0 +1,90 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * v4l2_subdevice_test.cpp - V4L2 subdevice test\n+ */\n+\n+#include <iostream>\n+#include <string.h>\n+#include <sys/stat.h>\n+\n+#include \"device_enumerator.h\"\n+#include \"media_device.h\"\n+#include \"v4l2_subdevice.h\"\n+\n+#include \"v4l2_subdevice_test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+/*\n+ * This test runs on vimc media device. For a description of vimc, in the\n+ * context of libcamera testingrefer to\n+ * 'test/media_device/media_device_link_test.cpp' file.\n+ *\n+ * If the vimc module is not loaded, the test gets skipped.\n+ */\n+\n+int V4L2SubdeviceTest::init()\n+{\n+\tenumerator_ = DeviceEnumerator::create();\n+\tif (!enumerator_) {\n+\t\tcerr << \"Failed to create device enumerator\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tif (enumerator_->enumerate()) {\n+\t\tcerr << \"Failed to enumerate media devices\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tDeviceMatch dm(\"vimc\");\n+\tmedia_ = std::move(enumerator_->search(dm));\n+\tif (!media_) {\n+\t\tcerr << \"Unable to find \\'vimc\\' media device node\" << endl;\n+\t\treturn TestSkip;\n+\t}\n+\n+\tmedia_->acquire();\n+\n+\tint ret = media_->open();\n+\tif (ret) {\n+\t\tcerr << \"Unable to open media device: \" << media_->deviceNode()\n+\t\t << \": \" << strerror(ret) << endl;\n+\t\tmedia_->release();\n+\t\treturn TestSkip;\n+\t}\n+\n+\tMediaEntity *videoEntity = media_->getEntityByName(\"Scaler\");\n+\tif (!videoEntity) {\n+\t\tcerr << \"Unable to find media entity 'Scaler'\" << endl;\n+\t\tmedia_->release();\n+\t\treturn TestSkip;\n+\t}\n+\n+\tscaler_ = new V4L2Subdevice(videoEntity);\n+\tif (!scaler_) {\n+\t\tcerr << \"Unable to create media device from media entity: \"\n+\t\t << videoEntity->deviceNode();\n+\t\tmedia_->release();\n+\t\treturn TestSkip;\n+\t}\n+\n+\tret = scaler_->open();\n+\tif (ret) {\n+\t\tcerr << \"Unable to open video subdevice \"\n+\t\t << scaler_->deviceNode() << endl;\n+\t\tmedia_->release();\n+\t\treturn TestSkip;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void V4L2SubdeviceTest::cleanup()\n+{\n+\tmedia_->release();\n+\n+\tdelete scaler_;\n+}\ndiff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h\nnew file mode 100644\nindex 000000000000..7b64c6122745\n--- /dev/null\n+++ b/test/v4l2_subdevice/v4l2_subdevice_test.h\n@@ -0,0 +1,36 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * v4l2_subdevice_test.h - V4L2 subdevice test\n+ */\n+\n+#ifndef __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_\n+#define __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_\n+\n+#include <libcamera/buffer.h>\n+\n+#include \"device_enumerator.h\"\n+#include \"media_device.h\"\n+#include \"test.h\"\n+#include \"v4l2_subdevice.h\"\n+\n+using namespace libcamera;\n+\n+class V4L2SubdeviceTest : public Test\n+{\n+public:\n+\tV4L2SubdeviceTest()\n+\t\t: scaler_(nullptr){};\n+\n+protected:\n+\tint init();\n+\tvirtual int run() = 0;\n+\tvoid cleanup();\n+\n+\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n+\tstd::shared_ptr<MediaDevice> media_;\n+\tV4L2Subdevice *scaler_;\n+};\n+\n+#endif /* __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_ */\n", "prefixes": [ "libcamera-devel", "v3", "5/8" ] }