[{"id":1654,"web_url":"https://patchwork.libcamera.org/comment/1654/","msgid":"<20190521214924.GM5674@pendragon.ideasonboard.com>","date":"2019-05-21T21:49:24","subject":"Re: [libcamera-devel] [PATCH v6 2/2] tests: ipa: add tests to test\n\tIPAModule","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Tue, May 21, 2019 at 05:36:08PM -0400, Paul Elder wrote:\n> Add tests to test the the IPAModule class, for loading the IPA module\n> info from IPA module .so shared objects, with modules written in both C\n> and C++.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n> Changes in v6:\n> - allow each test to have different test info content\n> - rename C test module to make it clear it's in C (as opposed to no\n>   label)\n> \n> Changes in v5:\n> - remove non-error test output\n> - auto-check if the correct module info was loaded\n> - make the meson build for the test shared objects prettier\n> - make the C test module info have the same content as the C++ test module info\n> \n> No changes in v4\n> \n> Changes in v3:\n> - remove tests for incorrect bitness\n> - make the test IPA module .so a C one and a C++ one\n> \n> Changes in v2:\n> - added source for test .so\n> - updated tests to work with new (v2, see 1/2) IPAModule API\n> \n>  test/ipa/ipa_test.cpp    | 76 ++++++++++++++++++++++++++++++++++++++++\n>  test/ipa/meson.build     | 21 +++++++++++\n>  test/ipa/shared_test.c   |  6 ++++\n>  test/ipa/shared_test.cpp | 12 +++++++\n>  test/meson.build         |  1 +\n>  5 files changed, 116 insertions(+)\n>  create mode 100644 test/ipa/ipa_test.cpp\n>  create mode 100644 test/ipa/meson.build\n>  create mode 100644 test/ipa/shared_test.c\n>  create mode 100644 test/ipa/shared_test.cpp\n> \n> diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp\n> new file mode 100644\n> index 0000000..3ef403d\n> --- /dev/null\n> +++ b/test/ipa/ipa_test.cpp\n> @@ -0,0 +1,76 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * load-so.cpp - loading .so tests\n> + */\n> +\n> +#include <iostream>\n> +#include <string.h>\n> +\n> +#include \"ipa_module.h\"\n> +\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class IPAModuleTest : public Test\n> +{\n> +protected:\n> +\tint runTest(const string &path, struct IPAModuleInfo &testInfo)\n\nThis should be a const struct IPAModuleInfo &.\n\n> +\t{\n> +\t\tint ret = 0;\n> +\t\tstruct IPAModuleInfo info;\n> +\n> +\t\tIPAModule *ll = new IPAModule(path);\n> +\n> +\t\tif (!ll->isValid()) {\n> +\t\t\tcerr << \"test IPA module \" << path << \" is invalid\"\n> +\t\t\t     << endl;\n> +\t\t\tret = -1;\n> +\t\t\tgoto done;\n> +\t\t}\n> +\n> +\t\tinfo = ll->info();\n\nNo need for a copy,\n\n\t\tconst struct IPAModuleInfo &info = ll->info();\n\nThis will cross the goto done above, which you can replace by a\ndelete ll; return -1;\n\n> +\n> +\t\tif (strcmp(info.name, testInfo.name)) {\n> +\t\t\tcerr << \"test IPA module has incorrect name\" << endl;\n> +\t\t\tcerr << \"expected \\\"\" << testInfo.name << \"\\\", got \\\"\"\n> +\t\t\t     << info.name << \"\\\"\" << endl;\n> +\t\t\tret = -1;\n> +\t\t}\n> +\n> +\t\tif (info.version != testInfo.version) {\n> +\t\t\tcerr << \"test IPA module has incorrect version\" << endl;\n> +\t\t\tcerr << \"expected \\\"\" << testInfo.version << \"\\\", got \\\"\"\n> +\t\t\t     << info.version << \"\\\"\" << endl;\n> +\t\t\tret = -1;\n> +\t\t}\n> +\n> +\tdone:\n> +\t\tdelete ll;\n> +\t\treturn ret;\n> +\t}\n> +\n> +\tint run() override\n> +\t{\n> +\t\tint count = 0;\n> +\n> +\t\tstruct IPAModuleInfo testInfo = {\n\nYou can make his const.\n\nWith all this fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\t\"It's over nine thousand!\",\n> +\t\t\t9001,\n> +\t\t};\n> +\n> +\t\tcount += runTest(\"test/ipa/ipa-dummy-c.so\", testInfo);\n> +\n> +\t\tcount += runTest(\"test/ipa/ipa-dummy-cpp.so\", testInfo);\n> +\n> +\t\tif (count < 0)\n> +\t\t\treturn TestFail;\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(IPAModuleTest)\n> diff --git a/test/ipa/meson.build b/test/ipa/meson.build\n> new file mode 100644\n> index 0000000..6df0671\n> --- /dev/null\n> +++ b/test/ipa/meson.build\n> @@ -0,0 +1,21 @@\n> +ipa_modules_sources = [\n> +    ['ipa-dummy-c',   'shared_test.c'],\n> +    ['ipa-dummy-cpp', 'shared_test.cpp'],\n> +]\n> +\n> +foreach m : ipa_modules_sources\n> +    shared_library(m, name_prefix: '',\n> +                   include_directories: test_includes_public)\n> +endforeach\n> +\n> +ipa_test = [\n> +    ['ipa_test', 'ipa_test.cpp'],\n> +]\n> +\n> +foreach t : ipa_test\n> +    exe = executable(t[0], t[1],\n> +                     link_with : test_libraries,\n> +                     include_directories : test_includes_internal)\n> +\n> +    test(t[0], exe, suite: 'ipa', is_parallel: false)\n> +endforeach\n> diff --git a/test/ipa/shared_test.c b/test/ipa/shared_test.c\n> new file mode 100644\n> index 0000000..87d182b\n> --- /dev/null\n> +++ b/test/ipa/shared_test.c\n> @@ -0,0 +1,6 @@\n> +#include <libcamera/ipa/ipa_module_info.h>\n> +\n> +const struct IPAModuleInfo ipaModuleInfo = {\n> +\t.name = \"It's over nine thousand!\",\n> +\t.version = 9001,\n> +};\n> diff --git a/test/ipa/shared_test.cpp b/test/ipa/shared_test.cpp\n> new file mode 100644\n> index 0000000..4e5c976\n> --- /dev/null\n> +++ b/test/ipa/shared_test.cpp\n> @@ -0,0 +1,12 @@\n> +#include <libcamera/ipa/ipa_module_info.h>\n> +\n> +namespace libcamera {\n> +\n> +extern \"C\" {\n> +const struct libcamera::IPAModuleInfo ipaModuleInfo = {\n> +\t\"It's over nine thousand!\",\n> +\t9001,\n> +};\n> +};\n> +\n> +}; /* namespace libcamera */\n> diff --git a/test/meson.build b/test/meson.build\n> index d501f2b..ef41367 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -1,6 +1,7 @@\n>  subdir('libtest')\n>  \n>  subdir('camera')\n> +subdir('ipa')\n>  subdir('media_device')\n>  subdir('pipeline')\n>  subdir('v4l2_device')","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ABBCC60C40\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 May 2019 23:49:41 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 23A6952C;\n\tTue, 21 May 2019 23:49:41 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1558475381;\n\tbh=zBIJMdjsdVXuwVP4RM6efw37l324O82+zA9W8TrS2mA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=d/63DIbY7//B0LFv3/bhVc5aMLjc6uCnqsHJjSeyqR8CXDHhSg9oxCLSWaxiQpogF\n\t1jMCfB7BnbdbRupUOYV2m7WCUlNPe+MeLevxSxkQ/XZZn0kAk0tvoBxp0XDow8OSFE\n\tPPXArsyjVmb/1xb7hkNBOnSnuqq7Se+q4LNTZrOQ=","Date":"Wed, 22 May 2019 00:49:24 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190521214924.GM5674@pendragon.ideasonboard.com>","References":"<20190521213608.10843-1-paul.elder@ideasonboard.com>\n\t<20190521213608.10843-2-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190521213608.10843-2-paul.elder@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v6 2/2] tests: ipa: add tests to test\n\tIPAModule","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, 21 May 2019 21:49:41 -0000"}}]