[{"id":31323,"web_url":"https://patchwork.libcamera.org/comment/31323/","msgid":"<20240923203441.GD7165@pendragon.ideasonboard.com>","date":"2024-09-23T20:34:41","subject":"Re: [PATCH v3 2/9] test: ipa: libipa: Add tets for Interpolator","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Sep 20, 2024 at 03:39:17PM +0200, Stefan Klug wrote:\n> Add tests for the Interpolator class.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - Stylefixes\n> - Collected tags\n> - Fixed copyright\n> ---\n>  test/ipa/libipa/interpolator.cpp | 54 ++++++++++++++++++++++++++++++++\n>  test/ipa/libipa/meson.build      | 15 +++++++++\n>  test/ipa/meson.build             |  1 +\n>  3 files changed, 70 insertions(+)\n>  create mode 100644 test/ipa/libipa/interpolator.cpp\n>  create mode 100644 test/ipa/libipa/meson.build\n> \n> diff --git a/test/ipa/libipa/interpolator.cpp b/test/ipa/libipa/interpolator.cpp\n> new file mode 100644\n> index 000000000000..6abb776060d4\n> --- /dev/null\n> +++ b/test/ipa/libipa/interpolator.cpp\n> @@ -0,0 +1,54 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2024, Ideas on Board Oy\n> + *\n> + * Interpolator tests\n> + */\n> +\n> +#include \"../src/ipa/libipa/interpolator.h\"\n\n#include <libipa/interpolator.h>\n\n> +\n> +#include <cmath>\n> +#include <iostream>\n> +#include <map>\n> +#include <stdint.h>\n> +#include <stdio.h>\n> +\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +using namespace ipa;\n> +\n> +#define ASSERT_EQ(a, b)                    \\\n> +\tif ((a) != (b)) {                  \\\n> +\t\tprintf(#a \" != \" #b \"\\n\"); \\\n\nCome on, we're using C++ :-)\n\n> +\t\treturn TestFail;           \\\n\nHiding a return in a macro is really not nice.\n\n> +\t}\n> +\n> +class InterpolatorTest : public Test\n> +{\n> +protected:\n> +\tint run()\n> +\t{\n> +\t\tInterpolator<int> interpolator;\n> +\t\tinterpolator.setData({ { 10, 100 }, { 20, 200 }, { 30, 300 } });\n> +\n> +\t\tASSERT_EQ(interpolator.getInterpolated(0), 100);\n> +\t\tASSERT_EQ(interpolator.getInterpolated(10), 100);\n> +\t\tASSERT_EQ(interpolator.getInterpolated(20), 200);\n> +\t\tASSERT_EQ(interpolator.getInterpolated(25), 250);\n> +\t\tASSERT_EQ(interpolator.getInterpolated(30), 300);\n> +\t\tASSERT_EQ(interpolator.getInterpolated(40), 300);\n\nMake this a loop and you won't need ASSERT_EQ().\n\n> +\n> +\t\tinterpolator.setQuantization(10);\n> +\t\tunsigned int q = 0;\n> +\t\tASSERT_EQ(interpolator.getInterpolated(25, &q), 300);\n> +\t\tASSERT_EQ(q, 30);\n> +\t\tASSERT_EQ(interpolator.getInterpolated(24, &q), 200);\n> +\t\tASSERT_EQ(q, 20);\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(InterpolatorTest)\n> diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build\n> new file mode 100644\n> index 000000000000..4d2427dbd4e7\n> --- /dev/null\n> +++ b/test/ipa/libipa/meson.build\n> @@ -0,0 +1,15 @@\n> +# SPDX-License-Identifier: CC0-1.0\n> +\n> +libipa_test = [\n> +    {'name': 'interpolator', 'sources': ['interpolator.cpp']},\n> +]\n> +\n> +foreach test : libipa_test\n> +    exe = executable(test['name'], test['sources'],\n> +                     dependencies : [libcamera_private, libipa_dep],\n> +                     link_with : [test_libraries],\n> +                     include_directories : [test_includes_internal,\n> +                                            '../../../src/ipa/libipa/'])\n\nUse libipa_include\n\n> +\n> +    test(test['name'], exe, suite : 'ipa')\n> +endforeach\n> diff --git a/test/ipa/meson.build b/test/ipa/meson.build\n> index e9871aba44ee..63820de54899 100644\n> --- a/test/ipa/meson.build\n> +++ b/test/ipa/meson.build\n> @@ -1,5 +1,6 @@\n>  # SPDX-License-Identifier: CC0-1.0\n>  \n> +subdir('libipa')\n>  subdir('rkisp1')\n>  \n>  ipa_test = [","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 254FEC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Sep 2024 20:35:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 33C9A6350B;\n\tMon, 23 Sep 2024 22:35:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13CC76037E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Sep 2024 22:35:13 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A39763D;\n\tMon, 23 Sep 2024 22:33:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"loE2EpXZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727123626;\n\tbh=HjS2MUeY+ZlNW7ldwEEcT7V1nw0wgSEMIjPMfZ7b5pI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=loE2EpXZ38+7c1gAAaJiR1jF+YVJNGGAkFxzyrWd/xRFahnO4Byhk4frxFQG7es6G\n\tK8k5+kZd/63sX494DCbdSUbELEBjtbSIDblEcL1nrf1buabzG6XJJk21i1wC2XCyVf\n\tUBnaXhR1ca1e8qcKv0OaZ3tOPwOIH78JGfFuAF1A=","Date":"Mon, 23 Sep 2024 23:34:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v3 2/9] test: ipa: libipa: Add tets for Interpolator","Message-ID":"<20240923203441.GD7165@pendragon.ideasonboard.com>","References":"<20240920133941.90629-1-stefan.klug@ideasonboard.com>\n\t<20240920133941.90629-3-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240920133941.90629-3-stefan.klug@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]