[libc][math] Fix floating point exception testing macros in FPMatcher.h for
authorTue Ly <lntue@google.com>
Fri, 24 Feb 2023 18:35:52 +0000 (13:35 -0500)
committerTue Ly <lntue@google.com>
Fri, 24 Feb 2023 18:43:33 +0000 (13:43 -0500)
aarch64.

libc/test/UnitTest/FPMatcher.h

index 4d2d128..f804b65 100644 (file)
@@ -124,14 +124,16 @@ FPMatcher<T, C> getMatcher(T expectedValue) {
 #define EXPECT_FP_EXCEPTION(expected)                                          \
   do {                                                                         \
     if (math_errhandling & MATH_ERREXCEPT) {                                   \
-      EXPECT_EQ(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT), expected);    \
+      EXPECT_GE(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT) & expected,    \
+                expected);                                                     \
     }                                                                          \
   } while (0)
 
 #define ASSERT_FP_EXCEPTION(expected)                                          \
   do {                                                                         \
     if (math_errhandling & MATH_ERREXCEPT) {                                   \
-      ASSERT_EQ(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT), expected);    \
+      ASSERT_GE(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT) & expected,    \
+                expected);                                                     \
     }                                                                          \
   } while (0)
 
@@ -140,7 +142,8 @@ FPMatcher<T, C> getMatcher(T expectedValue) {
     __llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);                          \
     EXPECT_FP_EQ(expected_val, actual_val);                                    \
     if (math_errhandling & MATH_ERREXCEPT) {                                   \
-      EXPECT_EQ(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT),               \
+      EXPECT_GE(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT) &              \
+                    expected_except,                                           \
                 expected_except);                                              \
       __llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);                        \
     }                                                                          \
@@ -151,7 +154,8 @@ FPMatcher<T, C> getMatcher(T expectedValue) {
     __llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);                          \
     EXPECT_FP_IS_NAN(actual_val);                                              \
     if (math_errhandling & MATH_ERREXCEPT) {                                   \
-      EXPECT_EQ(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT),               \
+      EXPECT_GE(__llvm_libc::fputil::test_except(FE_ALL_EXCEPT) &              \
+                    expected_except,                                           \
                 expected_except);                                              \
       __llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);                        \
     }                                                                          \