[libc-commits] [PATCH] D95650: [libc] small fixes to FEnv tests

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jan 28 16:40:51 PST 2021


michaelrj created this revision.
michaelrj added a reviewer: sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
michaelrj requested review of this revision.

previously the fenv tests were assuming that FE_ALL_EXCEPT was the same
as the list of exceptions defined by LLVM-libc. This isn't always true,
as a libc that LLVM-libc is being mixed with could potentially define
one of its own, for example the Denormal Operand exception defined in
"Intel 64 and IA-32 Architectures Software Developer's Manual, Vol 1"
section 8.1.5.


Repository:
  rG LLVM Github Monorepo

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
@@ -111,5 +111,8 @@
   int r = __llvm_libc::feraiseexcept(FE_ALL_EXCEPT);
   ASSERT_EQ(r, 0);
   int s = __llvm_libc::fetestexcept(FE_ALL_EXCEPT);
-  ASSERT_EQ(s, FE_ALL_EXCEPT);
+  // ASSERT_EQ(s, FE_ALL_EXCEPT);
+  for (int e : excepts) {
+    ASSERT_NE(s & e, 0);
+  }
 }
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,9 @@
   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) {
     ASSERT_DEATH(
         [=] {
@@ -36,7 +39,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.319997.patch
Type: text/x-patch
Size: 1417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210129/cbab3e3f/attachment.bin>


More information about the libc-commits mailing list