{"id":2102,"url":"https://patchwork.libcamera.org/api/patches/2102/?format=json","web_url":"https://patchwork.libcamera.org/patch/2102/","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":"<20191004163734.15594-7-jacopo@jmondi.org>","date":"2019-10-04T16:37:34","name":"[libcamera-devel,v2,6/6] test: ipa: Add test for the IPA Interface","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5bf4481cdf63b80f2d026aaa5cf4eb6accce5684","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/2102/mbox/","series":[{"id":519,"url":"https://patchwork.libcamera.org/api/series/519/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=519","date":"2019-10-04T16:37:28","name":"test: Add IPA interface test support","version":2,"mbox":"https://patchwork.libcamera.org/series/519/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2102/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2102/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C33F6165B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  4 Oct 2019 18:36:02 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id B8075200008;\n\tFri,  4 Oct 2019 16:36:01 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  4 Oct 2019 18:37:34 +0200","Message-Id":"<20191004163734.15594-7-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.23.0","In-Reply-To":"<20191004163734.15594-1-jacopo@jmondi.org>","References":"<20191004163734.15594-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 6/6] 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":"Fri, 04 Oct 2019 16:36:02 -0000"},"content":"Implementing a basic test for IPA Interface using the VIMC dummy IPA\nmodule. The test implements a communication channel between the test and\nthe dummy IPA module to verify the success of the IPA interactions.\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 src/ipa/meson.build             |   2 +\n test/ipa/ipa_interface_test.cpp | 136 ++++++++++++++++++++++++++++++++\n test/ipa/meson.build            |  10 ++-\n 3 files changed, 146 insertions(+), 2 deletions(-)\n create mode 100644 test/ipa/ipa_interface_test.cpp","diff":"diff --git a/src/ipa/meson.build b/src/ipa/meson.build\nindex 2827dc0303b2..3e11e166f283 100644\n--- a/src/ipa/meson.build\n+++ b/src/ipa/meson.build\n@@ -5,6 +5,8 @@ ipa_vimc_sources = [\n \n ipa_install_dir = join_paths(get_option('libdir'), 'libcamera')\n \n+ipa_internal_includes =  include_directories('.')\n+\n ipa_includes = [\n     libcamera_includes,\n     libcamera_internal_includes,\ndiff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\nnew file mode 100644\nindex 000000000000..b6d0a4e7de20\n--- /dev/null\n+++ b/test/ipa/ipa_interface_test.cpp\n@@ -0,0 +1,136 @@\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 <iostream>\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 <libcamera/event_dispatcher.h>\n+#include <libcamera/event_notifier.h>\n+#include <libcamera/timer.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+#include \"ipa_vimc.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\tcerr << \"Failed to create IPA test fifo at: \"\n+\t\t\t     << vimcFifoPath << \": \" << strerror(errno) << 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\tcerr << \"Failed to open IPA test fifo at: \"\n+\t\t\t     << vimcFifoPath << \": \" << strerror(errno) << 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\tcerr << \"Failed to read from IPA test fifo: \"\n+\t\t\t     << strerror(errno) << 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 IPAOperationCodes 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..d19de18ab97e 100644\n--- a/test/ipa/meson.build\n+++ b/test/ipa/meson.build\n@@ -1,12 +1,18 @@\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+test_includes_ipa = [\n+    test_includes_internal,\n+    ipa_internal_includes,\n ]\n \n foreach t : ipa_test\n     exe = executable(t[0], t[1],\n                      dependencies : libcamera_dep,\n                      link_with : test_libraries,\n-                     include_directories : test_includes_internal)\n+                     include_directories : test_includes_ipa)\n \n     test(t[0], exe, suite : 'ipa')\n endforeach\n","prefixes":["libcamera-devel","v2","6/6"]}