aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCalum Macdonald <calum.macdonald@arm.com>2024-03-20 14:10:34 +0000
committerDichenZhang1 <140119224+DichenZhang1@users.noreply.github.com>2024-04-23 15:48:01 -0700
commit345fd05cefa83ed77a09f6723c1217d94dccf1f8 (patch)
tree541cf9dfdd2fb1ee592097636921df368189d9c4 /tests
parent8dde998f6d7195c02da562a3eb1dc3361de0a8f5 (diff)
downloadlibultrahdr-345fd05cefa83ed77a09f6723c1217d94dccf1f8.tar.gz
Increase tolerance in EXPECT_YUV_BETWEEN
Increase tolerance in EXPECT_YUV_BETWEEN test macro. This is to allow the necessary comparison delta when compiling with -ffp-contract=fast. -ffp-contract=fast is explictly enable in the top level CMakeLists file. Previously the SampleP010 test would fail when building with gcc-12.3 with optimizations set to -O3 on aarch64 platforms. This is due to the max and min values being equal and the test-code/tested-code using a different number of fused floating-point operations. This is caused GCC and Clang enable -ffp-contract=fast by default. Change-Id: I2b3abc4b14fa9150bfc13180f3823e4ff9782ba2
Diffstat (limited to 'tests')
-rw-r--r--tests/gainmapmath_test.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/gainmapmath_test.cpp b/tests/gainmapmath_test.cpp
index 625d454..a602801 100644
--- a/tests/gainmapmath_test.cpp
+++ b/tests/gainmapmath_test.cpp
@@ -326,10 +326,15 @@ void GainMapMathTest::TearDown() {}
EXPECT_NEAR((e1).u, (e2).u, ComparisonEpsilon()); \
EXPECT_NEAR((e1).v, (e2).v, ComparisonEpsilon())
+// Due to -ffp-contract=fast being enabled by default with GCC, allow some
+// margin when comparing fused and unfused floating-point operations.
#define EXPECT_YUV_BETWEEN(e, min, max) \
- EXPECT_THAT((e).y, testing::AllOf(testing::Ge((min).y), testing::Le((max).y))); \
- EXPECT_THAT((e).u, testing::AllOf(testing::Ge((min).u), testing::Le((max).u))); \
- EXPECT_THAT((e).v, testing::AllOf(testing::Ge((min).v), testing::Le((max).v)))
+ EXPECT_THAT((e).y, testing::AllOf(testing::Ge((min).y - ComparisonEpsilon()), \
+ testing::Le((max).y + ComparisonEpsilon()))); \
+ EXPECT_THAT((e).u, testing::AllOf(testing::Ge((min).u - ComparisonEpsilon()), \
+ testing::Le((max).u + ComparisonEpsilon()))); \
+ EXPECT_THAT((e).v, testing::AllOf(testing::Ge((min).v - ComparisonEpsilon()), \
+ testing::Le((max).v + ComparisonEpsilon())))
// TODO: a bunch of these tests can be parameterized.