From patchwork Mon Oct 12 11:06:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 28437 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 E5680BDCB2 for ; Mon, 12 Oct 2026 11:06:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EFEE7689E2; Mon, 12 Oct 2026 13:06:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AAAuofp6"; 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 76155689E2 for ; Mon, 12 Oct 2026 13:06:38 +0200 (CEST) Received: from pb-laptop.local (185.221.143.22.nat.pool.zt.hu [185.221.143.22]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AB27E230 for ; Mon, 12 Oct 2026 13:04:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1791803077; bh=LfowHNqwzF5bU9F3p6wfm1IHOcq2HFAs4XfWObIw5ss=; h=From:To:Subject:Date:From; b=AAAuofp68ZMj3iaewB120dQMSzv+hYNmPLlbwAINGh/611WQhqHuq2CkEV9QJqG1C Xwwqw30SbhGfae58k3dXh4BoS4hcBwu9GewZ21ndl93s/nc592Cs0uFLOf/uu59g9A XyybPoeg15Rkx2TwsQQvDUNZtTC48AaWw9BxNsmc= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] test: Work around x87 floating point comparison issues Date: Mon, 12 Oct 2026 13:06:35 +0200 Message-ID: <20261012110635.482661-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.0 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" A few tests compare floating point values using the built-in equality operators. This is not ideal at all, but bringing in nuance filled floating point comparison does not appear too appealing either, especially just for a couple tests. So instead work around these comparison failures by using numbers that are exactly representable in base 2, and which ensure that the operations will be exact as well. This is of course far from the best approach, but seems acceptable given that the changes are very simple and only tests are affected in the first place. Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/348 Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- test/controls/control_value.cpp | 8 +++++--- test/ipa/libipa/histogram.cpp | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp index c2f9fc4826..399f4b2bb1 100644 --- a/test/controls/control_value.cpp +++ b/test/controls/control_value.cpp @@ -272,19 +272,21 @@ protected: /* * Float type. */ - value.set(-0.42f); + constexpr float fValue = -0.75; + + value.set(fValue); if (value.isNone() || value.isArray() || value.type() != ControlTypeFloat) { cerr << "Control type mismatch after setting to float" << endl; return TestFail; } - if (value.get() != -0.42f) { + if (value.get() != fValue) { cerr << "Control value mismatch after setting to float" << endl; return TestFail; } - if (value.toString() != "-0.420000") { + if (value.toString() != "-0.750000") { cerr << "Control string mismatch after setting to float" << endl; return TestFail; } diff --git a/test/ipa/libipa/histogram.cpp b/test/ipa/libipa/histogram.cpp index 77ff31a6db..504c9ed319 100644 --- a/test/ipa/libipa/histogram.cpp +++ b/test/ipa/libipa/histogram.cpp @@ -46,7 +46,7 @@ protected: ASSERT_EQ(hist.quantile(0.75), 1.5); /* Test quantile smaller than the smallest histogram step. */ - ASSERT_EQ(hist.quantile(0.001), 0.002); + ASSERT_EQ(hist.quantile(0.125), 0.25); ASSERT_EQ(hist.interQuantileMean(0.0, 1.0), 1.0); ASSERT_EQ(hist.interQuantileMean(0.0, 0.5), 0.5); @@ -56,8 +56,8 @@ protected: ASSERT_EQ(hist.interQuantileMean(0.25, 0.75), 1.0); /* Test small ranges at the borders of the histogram. */ - ASSERT_EQ(hist.interQuantileMean(0.0, 0.1), 0.1); - ASSERT_EQ(hist.interQuantileMean(0.9, 1.0), 1.9); + ASSERT_EQ(hist.interQuantileMean(0.0, 0.125), 0.125); + ASSERT_EQ(hist.interQuantileMean(0.875, 1.0), 1.875); return TestPass; }