Patch Detail
Show a patch.
GET /api/patches/2127/?format=api
{ "id": 2127, "url": "https://patchwork.libcamera.org/api/patches/2127/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2127/", "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": "<20191007085842.7608-6-jacopo@jmondi.org>", "date": "2019-10-07T08:58:42", "name": "[libcamera-devel,v4,5/5] test: ipa: Add test for the IPA Interface", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5e3682a1fa7f4833aad1ab4c3f74c3b5cda404ab", "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/2127/mbox/", "series": [ { "id": 525, "url": "https://patchwork.libcamera.org/api/series/525/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=525", "date": "2019-10-07T08:58:37", "name": "test: Add IPA interface test support", "version": 4, "mbox": "https://patchwork.libcamera.org/series/525/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2127/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2127/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA4FE6196D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 7 Oct 2019 10:57:03 +0200 (CEST)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id B4C9E24000F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 7 Oct 2019 08:57:03 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 7 Oct 2019 10:58:42 +0200", "Message-Id": "<20191007085842.7608-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20191007085842.7608-1-jacopo@jmondi.org>", "References": "<20191007085842.7608-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 5/5] test: ipa: Add test for the IPA\n\tInterface", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "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, 07 Oct 2019 08:57:04 -0000" }, "content": "Implement a basic test for IPA Interface using the VIMC dummy IPA\nmodule. The test implements an out-of-band feedback channel between the\ntest and the dummy IPA module to verify the success of the IPA\ninteractions.\n\nTest the only available operation defined by the IPA interface by\nreceiving a confirmation code on the fifo communication channel.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/ipa/ipa_interface_test.cpp | 142 ++++++++++++++++++++++++++++++++\n test/ipa/meson.build | 3 +-\n 2 files changed, 144 insertions(+), 1 deletion(-)\n create mode 100644 test/ipa/ipa_interface_test.cpp\n\n--\n2.23.0", "diff": "diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\nnew file mode 100644\nindex 000000000000..171e572461a5\n--- /dev/null\n+++ b/test/ipa/ipa_interface_test.cpp\n@@ -0,0 +1,142 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * ipa_interface_test.cpp - Test the IPA interface\n+ */\n+\n+#include <fcntl.h>\n+#include <string.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+\n+#include <iostream>\n+\n+#include <libcamera/event_dispatcher.h>\n+#include <libcamera/event_notifier.h>\n+#include <libcamera/timer.h>\n+\n+#include <ipa/ipa_vimc.h>\n+\n+#include \"device_enumerator.h\"\n+#include \"ipa_manager.h\"\n+#include \"ipa_module.h\"\n+#include \"pipeline_handler.h\"\n+#include \"test.h\"\n+#include \"thread.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class IPAInterfaceTest : public Test, public Object\n+{\n+public:\n+\tIPAInterfaceTest()\n+\t\t: trace_(IPAOperationNone), notifier_(nullptr), fd_(-1)\n+\t{\n+\t}\n+\n+\t~IPAInterfaceTest()\n+\t{\n+\t\tdelete notifier_;\n+\t}\n+\n+protected:\n+\tint init() override\n+\t{\n+\t\t/* Create a pipeline handler for vimc. */\n+\t\tstd::vector<PipelineHandlerFactory *> &factories =\n+\t\t\tPipelineHandlerFactory::factories();\n+\t\tfor (PipelineHandlerFactory *factory : factories) {\n+\t\t\tif (factory->name() == \"PipelineHandlerVimc\") {\n+\t\t\t\tpipe_ = factory->create(nullptr);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!pipe_) {\n+\t\t\tcerr << \"Vimc pipeline not found\" << endl;\n+\t\t\treturn TestPass;\n+\t\t}\n+\n+\t\t/* Create and open the communication FIFO. */\n+\t\tint ret = mkfifo(VIMC_IPA_FIFO_PATH, S_IRUSR | S_IWUSR);\n+\t\tif (ret) {\n+\t\t\tret = errno;\n+\t\t\tcerr << \"Failed to create IPA test FIFO at '\"\n+\t\t\t << VIMC_IPA_FIFO_PATH << \"': \" << strerror(ret)\n+\t\t\t << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tret = open(VIMC_IPA_FIFO_PATH, O_RDONLY | O_NONBLOCK);\n+\t\tif (ret < 0) {\n+\t\t\tret = errno;\n+\t\t\tcerr << \"Failed to open IPA test FIFO at '\"\n+\t\t\t << VIMC_IPA_FIFO_PATH << \"': \" << strerror(ret)\n+\t\t\t << endl;\n+\t\t\tunlink(VIMC_IPA_FIFO_PATH);\n+\t\t\treturn TestFail;\n+\t\t}\n+\t\tfd_ = ret;\n+\n+\t\tnotifier_ = new EventNotifier(fd_, EventNotifier::Read, this);\n+\t\tnotifier_->activated.connect(this, &IPAInterfaceTest::readTrace);\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tint run() override\n+\t{\n+\t\tEventDispatcher *dispatcher = thread()->eventDispatcher();\n+\t\tTimer timer;\n+\n+\t\tipa_ = IPAManager::instance()->createIPA(pipe_.get(), 0, 0);\n+\t\tif (!ipa_) {\n+\t\t\tcerr << \"Failed to create VIMC IPA interface\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test initialization of IPA module. */\n+\t\tipa_->init();\n+\t\ttimer.start(1000);\n+\t\twhile (timer.isRunning() && trace_ != IPAOperationInit)\n+\t\t\tdispatcher->processEvents();\n+\n+\t\tif (trace_ != IPAOperationInit) {\n+\t\t\tcerr << \"Failed to test IPA initialization sequence\"\n+\t\t\t << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup() override\n+\t{\n+\t\tclose(fd_);\n+\t\tunlink(VIMC_IPA_FIFO_PATH);\n+\t}\n+\n+private:\n+\tvoid readTrace(EventNotifier *notifier)\n+\t{\n+\t\tssize_t s = read(notifier->fd(), &trace_, sizeof(trace_));\n+\t\tif (s < 0) {\n+\t\t\tint ret = errno;\n+\t\t\tcerr << \"Failed to read from IPA test FIFO at '\"\n+\t\t\t << VIMC_IPA_FIFO_PATH << \"': \" << strerror(ret)\n+\t\t\t << endl;\n+\t\t\ttrace_ = IPAOperationNone;\n+\t\t}\n+\t}\n+\n+\tstd::shared_ptr<PipelineHandler> pipe_;\n+\tstd::unique_ptr<IPAInterface> ipa_;\n+\tenum IPAOperationCode trace_;\n+\tEventNotifier *notifier_;\n+\tint fd_;\n+};\n+\n+TEST_REGISTER(IPAInterfaceTest)\ndiff --git a/test/ipa/meson.build b/test/ipa/meson.build\nindex e174671d05e1..c501fcf99aed 100644\n--- a/test/ipa/meson.build\n+++ b/test/ipa/meson.build\n@@ -1,5 +1,6 @@\n ipa_test = [\n- ['ipa_module_test', 'ipa_module_test.cpp'],\n+ ['ipa_module_test', 'ipa_module_test.cpp'],\n+ ['ipa_interface_test', 'ipa_interface_test.cpp'],\n ]\n\n foreach t : ipa_test\n", "prefixes": [ "libcamera-devel", "v4", "5/5" ] }