{"id":2121,"url":"https://patchwork.libcamera.org/api/1.1/patches/2121/?format=json","web_url":"https://patchwork.libcamera.org/patch/2121/","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":"<20191006200852.11775-6-jacopo@jmondi.org>","date":"2019-10-06T20:08:52","name":"[libcamera-devel,v3,5/5] test: ipa: Add test for the IPA Interface","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"40f9c97684f7373c3f0cb834ad91c20e8bc135c9","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/2121/mbox/","series":[{"id":524,"url":"https://patchwork.libcamera.org/api/1.1/series/524/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=524","date":"2019-10-06T20:08:47","name":"test: Add IPA interface test support","version":3,"mbox":"https://patchwork.libcamera.org/series/524/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2121/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2121/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8563861966\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 22:07:14 +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 relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 46A9EC0005\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 20:07:14 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun,  6 Oct 2019 22:08:52 +0200","Message-Id":"<20191006200852.11775-6-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.23.0","In-Reply-To":"<20191006200852.11775-1-jacopo@jmondi.org>","References":"<20191006200852.11775-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 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":"Sun, 06 Oct 2019 20:07:14 -0000"},"content":"Implementing 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\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/ipa/ipa_interface_test.cpp | 138 ++++++++++++++++++++++++++++++++\n test/ipa/meson.build            |   3 +-\n 2 files changed, 140 insertions(+), 1 deletion(-)\n create mode 100644 test/ipa/ipa_interface_test.cpp","diff":"diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\nnew file mode 100644\nindex 000000000000..71bdcc651392\n--- /dev/null\n+++ b/test/ipa/ipa_interface_test.cpp\n@@ -0,0 +1,138 @@\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+#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(vimcFifoPath, 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     << vimcFifoPath << \": \" << strerror(-ret) << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tret = open(vimcFifoPath, 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     << vimcFifoPath << \": \" << strerror(-ret) << endl;\n+\t\t\tunlink(vimcFifoPath);\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(vimcFifoPath);\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: \"\n+\t\t\t     << strerror(-ret) << 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","v3","5/5"]}