Patch Detail
Show a patch.
GET /api/patches/22009/?format=api
{ "id": 22009, "url": "https://patchwork.libcamera.org/api/patches/22009/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22009/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20241119121928.30939-12-laurent.pinchart@ideasonboard.com>", "date": "2024-11-19T12:19:22", "name": "[v4,11/17] test: libipa: Add Vector class test", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "7c7f31126c0f4e8456a478eda7d3ae7b3bb2eaf0", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22009/mbox/", "series": [ { "id": 4804, "url": "https://patchwork.libcamera.org/api/series/4804/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4804", "date": "2024-11-19T12:19:11", "name": "Improve linear algebra helpers in libipa", "version": 4, "mbox": "https://patchwork.libcamera.org/series/4804/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22009/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22009/checks/", "tags": {}, "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 C23CFC32F3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Nov 2024 12:20:18 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2733565F37;\n\tTue, 19 Nov 2024 13:20:18 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B1E6065F2C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 13:20:12 +0100 (CET)", "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 0F722193C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 13:19:54 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"awAZI1NE\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732018795;\n\tbh=5buo3fwsEH7UtzIWAB+ZiaYNVvSs8lcucQ+C69aj92A=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=awAZI1NEOJ+HWd6TjE6ax4EuDPcvSlOSddb1HwNgoyNTU04JgOILsm7P7SwMXT//E\n\tiv0GAo6IlsS3949aW8kpvn++RqdDzJn7zNiysFIwfMHgHq6tpsIYqbhb40WcJWtovJ\n\tE67LFl/iqNt1d0EYbzH6FHLdobXTyqQlXal3yFps=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v4 11/17] test: libipa: Add Vector class test", "Date": "Tue, 19 Nov 2024 14:19:22 +0200", "Message-ID": "<20241119121928.30939-12-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "In-Reply-To": "<20241119121928.30939-1-laurent.pinchart@ideasonboard.com>", "References": "<20241119121928.30939-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>" }, "content": "Add a unit test to exercize the API of the ipa::Vector class.\n\nThe test binary being called 'vector', implicit includes cause the\nbinary to be picked by '#include <vector>', causing builds to fail. Set\nimplicit_include_directories to false to avoid this, as done in commit\n6cd849125888 (\"test: Don't add current build directory to include\npath\").\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n---\nChanges since v2:\n\n- Fix initialization of 'v1' variable\n---\n test/ipa/libipa/meson.build | 2 +\n test/ipa/libipa/vector.cpp | 100 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 102 insertions(+)\n create mode 100644 test/ipa/libipa/vector.cpp", "diff": "diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build\nindex 4d2427dbd4e7..f9b3c46d000f 100644\n--- a/test/ipa/libipa/meson.build\n+++ b/test/ipa/libipa/meson.build\n@@ -2,11 +2,13 @@\n \n libipa_test = [\n {'name': 'interpolator', 'sources': ['interpolator.cpp']},\n+ {'name': 'vector', 'sources': ['vector.cpp']},\n ]\n \n foreach test : libipa_test\n exe = executable(test['name'], test['sources'],\n dependencies : [libcamera_private, libipa_dep],\n+ implicit_include_directories : false,\n link_with : [test_libraries],\n include_directories : [test_includes_internal,\n '../../../src/ipa/libipa/'])\ndiff --git a/test/ipa/libipa/vector.cpp b/test/ipa/libipa/vector.cpp\nnew file mode 100644\nindex 000000000000..8e4ec77d7820\n--- /dev/null\n+++ b/test/ipa/libipa/vector.cpp\n@@ -0,0 +1,100 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2024, Ideas on Board Oy\n+ *\n+ * Vector tests\n+ */\n+\n+#include \"../src/ipa/libipa/vector.h\"\n+\n+#include <cmath>\n+#include <iostream>\n+\n+#include \"test.h\"\n+\n+using namespace libcamera::ipa;\n+\n+#define ASSERT_EQ(a, b)\t\t\t\t\t\t\t\\\n+if ((a) != (b)) {\t\t\t\t\t\t\t\\\n+\tstd::cout << #a \" != \" #b << \" (line \" << __LINE__ << \")\"\t\\\n+\t\t << std::endl;\t\t\t\t\t\t\\\n+\treturn TestFail;\t\t\t\t\t\t\\\n+}\n+\n+class VectorTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tVector<double, 3> v1{ 0.0 };\n+\n+\t\tASSERT_EQ(v1[0], 0.0);\n+\t\tASSERT_EQ(v1[1], 0.0);\n+\t\tASSERT_EQ(v1[2], 0.0);\n+\n+\t\tASSERT_EQ(v1.length(), 0.0);\n+\t\tASSERT_EQ(v1.length2(), 0.0);\n+\n+\t\tVector<double, 3> v2{{ 1.0, 4.0, 8.0 }};\n+\n+\t\tASSERT_EQ(v2[0], 1.0);\n+\t\tASSERT_EQ(v2[1], 4.0);\n+\t\tASSERT_EQ(v2[2], 8.0);\n+\n+\t\tASSERT_EQ(v2.x(), 1.0);\n+\t\tASSERT_EQ(v2.y(), 4.0);\n+\t\tASSERT_EQ(v2.z(), 8.0);\n+\n+\t\tASSERT_EQ(v2.r(), 1.0);\n+\t\tASSERT_EQ(v2.g(), 4.0);\n+\t\tASSERT_EQ(v2.b(), 8.0);\n+\n+\t\tASSERT_EQ(v2.length2(), 81.0);\n+\t\tASSERT_EQ(v2.length(), 9.0);\n+\t\tASSERT_EQ(v2.sum(), 13.0);\n+\n+\t\tVector<double, 3> v3{ v2 };\n+\n+\t\tASSERT_EQ(v2, v3);\n+\n+\t\tv3 = Vector<double, 3>{{ 4.0, 4.0, 4.0 }};\n+\n+\t\tASSERT_EQ(v2 + v3, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tASSERT_EQ(v2 + 4.0, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tASSERT_EQ(v2 - v3, (Vector<double, 3>{{ -3.0, 0.0, 4.0 }}));\n+\t\tASSERT_EQ(v2 - 4.0, (Vector<double, 3>{{ -3.0, 0.0, 4.0 }}));\n+\t\tASSERT_EQ(v2 * v3, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tASSERT_EQ(v2 * 4.0, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tASSERT_EQ(v2 / v3, (Vector<double, 3>{{ 0.25, 1.0, 2.0 }}));\n+\t\tASSERT_EQ(v2 / 4.0, (Vector<double, 3>{{ 0.25, 1.0, 2.0 }}));\n+\n+\t\tASSERT_EQ(v2.min(v3), (Vector<double, 3>{{ 1.0, 4.0, 4.0 }}));\n+\t\tASSERT_EQ(v2.min(4.0), (Vector<double, 3>{{ 1.0, 4.0, 4.0 }}));\n+\t\tASSERT_EQ(v2.max(v3), (Vector<double, 3>{{ 4.0, 4.0, 8.0 }}));\n+\t\tASSERT_EQ(v2.max(4.0), (Vector<double, 3>{{ 4.0, 4.0, 8.0 }}));\n+\n+\t\tASSERT_EQ(v2.dot(v3), 52.0);\n+\n+\t\tv2 += v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tv2 -= v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\t\tv2 *= v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tv2 /= v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\n+\t\tv2 += 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tv2 -= 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\t\tv2 *= 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tv2 /= 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(VectorTest)\n", "prefixes": [ "v4", "11/17" ] }