[libc-commits] [libc] [libc] Make a couple of math smoke tests more robust. (PR #120808)
Alexey Samsonov via libc-commits
libc-commits at lists.llvm.org
Fri Dec 20 15:58:10 PST 2024
https://github.com/vonosmas updated https://github.com/llvm/llvm-project/pull/120808
>From 7f435b77b6a21c2a028bfdd9d08ab5e81d958750 Mon Sep 17 00:00:00 2001
From: Alexey Samsonov <vonosmas at gmail.com>
Date: Fri, 20 Dec 2024 15:38:21 -0800
Subject: [PATCH 1/2] [libc] Make a couple of math smoke tests more robust.
Make sure to clear out all FE_ALL_EXCEPT bits both before and after
invoking function under test -- otherwise the very first check for
the exception bits in the unit test may fail due to bits set prior
to test invocation.
---
libc/test/src/math/smoke/CanonicalizeTest.h | 1 +
libc/test/src/math/smoke/FModTest.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/libc/test/src/math/smoke/CanonicalizeTest.h b/libc/test/src/math/smoke/CanonicalizeTest.h
index ef75f568b8275b..e500bc38f98524 100644
--- a/libc/test/src/math/smoke/CanonicalizeTest.h
+++ b/libc/test/src/math/smoke/CanonicalizeTest.h
@@ -19,6 +19,7 @@
#include "hdr/math_macros.h"
#define TEST_SPECIAL(x, y, expected, expected_exception) \
+ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
EXPECT_EQ(expected, f(&x, &y)); \
EXPECT_FP_EXCEPTION(expected_exception); \
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT)
diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h
index ad9688fc01e7c1..387ed29b350c55 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -18,6 +18,7 @@
#include "hdr/fenv_macros.h"
#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
+ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
EXPECT_FP_EQ(expected, f(x, y)); \
EXPECT_MATH_ERRNO((dom_err) ? EDOM : 0); \
EXPECT_FP_EXCEPTION(expected_exception); \
>From ffbea084bba9db896b87742032847d60baa1613b Mon Sep 17 00:00:00 2001
From: Alexey Samsonov <vonosmas at gmail.com>
Date: Fri, 20 Dec 2024 15:57:50 -0800
Subject: [PATCH 2/2] (fix formatting)
---
libc/test/src/math/smoke/FModTest.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h
index 387ed29b350c55..8fbcc2a276542c 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -18,7 +18,7 @@
#include "hdr/fenv_macros.h"
#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
- LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
+ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
EXPECT_FP_EQ(expected, f(x, y)); \
EXPECT_MATH_ERRNO((dom_err) ? EDOM : 0); \
EXPECT_FP_EXCEPTION(expected_exception); \
More information about the libc-commits
mailing list