From patchwork Fri Jun 13 10:09:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23557 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4106FBDE6B for ; Fri, 13 Jun 2025 10:10:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9A1FA68DC2; Fri, 13 Jun 2025 12:10:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FJ8owSot"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B70368DC2 for ; Fri, 13 Jun 2025 12:10:06 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:37bc:6352:9b26:2f94]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 93F7DED; Fri, 13 Jun 2025 12:09:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1749809396; bh=bnwYQ2ouadNBlVO+t9nIbUtzf7z3iToY/oARe4JhTis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJ8owSotn3+lf/1t4kWDZaUa2YOHxBs+4On5hSXTR68w0t1308dmrI5OELI55l9ji bDkqofoM3FHyzVFpLZTFccplOSOVCU1jvr3qBFzV8opwl8wfjmKbno93SFn+dFt1Cv pasVASAxzg/P2ri4zG2N/3zozAy6lc/qTiMq5TWI= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham Subject: [PATCH v2 1/4] test: ipa: Add basic Pwl test Date: Fri, 13 Jun 2025 12:09:36 +0200 Message-ID: <20250613100947.589875-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250613100947.589875-1-stefan.klug@ideasonboard.com> References: <20250613100947.589875-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a basic test for the Pwl class. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- Changes in v2: - Changed test to also test extrapolation --- test/ipa/libipa/meson.build | 1 + test/ipa/libipa/pwl.cpp | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/ipa/libipa/pwl.cpp diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build index 8c63ebd8e2f7..b2cc4b7461c1 100644 --- a/test/ipa/libipa/meson.build +++ b/test/ipa/libipa/meson.build @@ -4,6 +4,7 @@ libipa_test = [ {'name': 'fixedpoint', 'sources': ['fixedpoint.cpp']}, {'name': 'histogram', 'sources': ['histogram.cpp']}, {'name': 'interpolator', 'sources': ['interpolator.cpp']}, + {'name': 'pwl', 'sources': ['pwl.cpp']}, ] foreach test : libipa_test diff --git a/test/ipa/libipa/pwl.cpp b/test/ipa/libipa/pwl.cpp new file mode 100644 index 000000000000..d41a290a0e84 --- /dev/null +++ b/test/ipa/libipa/pwl.cpp @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2025, Ideas on Board Oy + * + * PWL tests + */ + +#include "../src/ipa/libipa/pwl.h" + +#include +#include +#include +#include +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; +using namespace ipa; + +#define ASSERT_EQ(a, b) \ + if ((a) != (b)) { \ + std::cout << #a " != " #b " (" << a << " ," << b << ")" \ + << std::endl; \ + return TestFail; \ + } + +class PwlTest : public Test +{ +protected: + int run() + { + Pwl pwl; + pwl.append(0, 0); + pwl.append(1, 1); + + ASSERT_EQ(pwl.eval(-1), -1); + ASSERT_EQ(pwl.eval(0), 0); + ASSERT_EQ(pwl.eval(0.5), 0.5); + ASSERT_EQ(pwl.eval(1), 1); + ASSERT_EQ(pwl.eval(2), 2); + + ASSERT_EQ(pwl.size(), 2); + + return TestPass; + } +}; + +TEST_REGISTER(PwlTest)