[libc-commits] [PATCH] D95650: [libc] Small adjustments to fenv tests

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 1 10:40:46 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb2e2d506814: [libc] Small adjustments to fenv tests (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95650/new/

https://reviews.llvm.org/D95650

Files:
  libc/test/src/fenv/enabled_exceptions_test.cpp
  libc/test/src/fenv/exception_status_test.cpp


Index: libc/test/src/fenv/exception_status_test.cpp
===================================================================
--- libc/test/src/fenv/exception_status_test.cpp
+++ libc/test/src/fenv/exception_status_test.cpp
@@ -24,6 +24,10 @@
 
   int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
                    FE_UNDERFLOW};
+
+  constexpr int allExcepts =
+      FE_DIVBYZERO | FE_INVALID | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW;
+
   for (int e : excepts) {
     int r = __llvm_libc::feraiseexcept(e);
     ASSERT_EQ(r, 0);
@@ -108,8 +112,8 @@
     }
   }
 
-  int r = __llvm_libc::feraiseexcept(FE_ALL_EXCEPT);
+  int r = __llvm_libc::feraiseexcept(allExcepts);
   ASSERT_EQ(r, 0);
-  int s = __llvm_libc::fetestexcept(FE_ALL_EXCEPT);
-  ASSERT_EQ(s, FE_ALL_EXCEPT);
+  int s = __llvm_libc::fetestexcept(allExcepts);
+  ASSERT_EQ(s, allExcepts);
 }
Index: libc/test/src/fenv/enabled_exceptions_test.cpp
===================================================================
--- libc/test/src/fenv/enabled_exceptions_test.cpp
+++ libc/test/src/fenv/enabled_exceptions_test.cpp
@@ -27,6 +27,12 @@
   int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
                    FE_UNDERFLOW};
 
+  // We '|' the individual exception flags instead of using FE_ALL_EXCEPT
+  // as it can include non-standard extensions. Note that we should be able
+  // to compile this file with headers from other libcs as well.
+  constexpr int allExcepts =
+      FE_DIVBYZERO | FE_INVALID | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW;
+
   for (int e : excepts) {
     ASSERT_DEATH(
         [=] {
@@ -36,7 +42,7 @@
           // Raising all exceptions except |e| should not call the
           // SIGFPE handler. They should set the exception flag though,
           // so we verify that.
-          int others = FE_ALL_EXCEPT & ~e;
+          int others = allExcepts & ~e;
           ASSERT_EQ(__llvm_libc::feraiseexcept(others), 0);
           ASSERT_EQ(__llvm_libc::fetestexcept(others), others);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95650.320520.patch
Type: text/x-patch
Size: 2017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210201/9346e186/attachment.bin>


More information about the libc-commits mailing list