[{"id":2815,"web_url":"https://patchwork.libcamera.org/comment/2815/","msgid":"<20191007041414.GM4740@pendragon.ideasonboard.com>","date":"2019-10-07T04:14:14","subject":"Re: [libcamera-devel] [PATCH v3 5/5] test: ipa: Add test for the\n\tIPA Interface","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Sun, Oct 06, 2019 at 10:08:52PM +0200, Jacopo Mondi wrote:\n> Implementing a basic test for IPA Interface using the VIMC dummy IPA\n\ns/Implementing/Implement/\n\n> module. The test implements an out-of-band feedback channel between the\n> test and the dummy IPA module to verify the success of the IPA\n> interactions.\n> \n> Test the only available operation defined by the IPA interface by\n> receiving a confirmation code on the fifo communication channel.\n> \n> Signed-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\n> \n> diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> new file mode 100644\n> index 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\nI'd add a blank line here, or move it before the libcamera headers to\nsort them alphabetically (blank line is my preference).\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(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\nCould you please re-read my comments on the previous version regarding\nthis message and the next one ? After addressing them,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\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)\n> diff --git a/test/ipa/meson.build b/test/ipa/meson.build\n> index 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","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7934960BC6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Oct 2019 06:14:17 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(modemcable151.96-160-184.mc.videotron.ca [184.160.96.151])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 97A3FDD;\n\tMon,  7 Oct 2019 06:14:16 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570421657;\n\tbh=YmD582tHL6tRLgTes5wySB0u2QDmff9/1RuuKM7OCGU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YAE2xZj4sU+MtXz+m0RCXYPf0in/+kcuVZelo4sghLiQk1gxlLMq18SZziWcU3fcF\n\tqafF5lxGQWeVRRhDOk3IDPoe1rPZx4WO4lBqmNEFZ3HBwaq73IB63fis0TuufStIP3\n\tfV0Ij2lwhCrk8yPfeIg4XGv957rRrlEQhCpglw9I=","Date":"Mon, 7 Oct 2019 07:14:14 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191007041414.GM4740@pendragon.ideasonboard.com>","References":"<20191006200852.11775-1-jacopo@jmondi.org>\n\t<20191006200852.11775-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191006200852.11775-6-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 5/5] test: ipa: Add test for the\n\tIPA Interface","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 04:14:17 -0000"}}]