[libc-commits] [libc] [libc] Make a couple of math smoke tests more robust. (PR #120808)

via libc-commits libc-commits at lists.llvm.org
Fri Dec 20 15:42:50 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/120808.diff


2 Files Affected:

- (modified) libc/test/src/math/smoke/CanonicalizeTest.h (+1) 
- (modified) libc/test/src/math/smoke/FModTest.h (+1) 


``````````diff
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);                                     \

``````````

</details>


https://github.com/llvm/llvm-project/pull/120808


More information about the libc-commits mailing list