[libcxx-commits] [libcxx] [libc++] tests with picolibc: add has-complete-fenv feature (PR #74610)

Dominik Wójt via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 12 04:31:27 PST 2023


https://github.com/domin144 updated https://github.com/llvm/llvm-project/pull/74610

>From 9e7ec18c170250e85bcada3867ef0dd463db679e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <dominik.wojt at arm.com>
Date: Tue, 24 Oct 2023 12:12:27 +0200
Subject: [PATCH 1/2] [libc++] tests with picolibc: add has-compolete-fenv
 feature

The FE_* macros checked for in cfenv.pass.cpp are not required to be
defined, if the relevant options are available. Picolibc happens not to
provide these on some platforms.
Added a test in features.py to skip fenv test automatically.
---
 .../depr.c.headers/fenv_h.compile.pass.cpp    |  2 +-
 .../numerics/cfenv/cfenv.syn/cfenv.pass.cpp   |  2 +-
 libcxx/utils/libcxx/test/features.py          | 29 +++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp
index dcc97573d60733..a896f5e03c3af7 100644
--- a/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // Floating point exceptions are required for the FE_... macros to be defined.
-// XFAIL: LIBCXX-PICOLIBC-FIXME
+// REQUIRES: has-compolete-fenv
 
 // <fenv.h>
 
diff --git a/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp b/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
index 7b3b490eba273a..5a39003d00d0f5 100644
--- a/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
+++ b/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // Floating point exceptions are required for the FE_... macros to be defined.
-// XFAIL: LIBCXX-PICOLIBC-FIXME
+// REQUIRES: has-compolete-fenv
 
 // <cfenv>
 
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 5e854917e6ef45..81e03fdc7418c6 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -224,6 +224,35 @@ def _getAndroidDeviceApi(cfg):
           """,
         ),
     ),
+    # Some platform do not provide complete floating point environment.
+    Feature(
+        name="has-compolete-fenv",
+        when=lambda cfg: sourceBuilds(
+            cfg,
+            """
+            #include <fenv.h>
+
+            #if !( \
+                defined FE_DIVBYZERO \
+                && defined FE_INEXACT \
+                && defined FE_INVALID \
+                && defined FE_INEXACT \
+                && defined FE_OVERFLOW \
+                && defined FE_UNDERFLOW \
+                && defined FE_ALL_EXCEPT \
+                && defined FE_DOWNWARD \
+                && defined FE_TONEAREST \
+                && defined FE_TOWARDZERO \
+                && defined FE_UPWARD \
+                && defined FE_DFL_ENV \
+                && defined FE_INEXACT)
+            #error Floating point environment not complete
+            #endif
+
+            int main(int, char**) { return 0; }
+          """,
+        ),
+    ),
     # Check for a Windows UCRT bug (fixed in UCRT/Windows 10.0.20348.0):
     # https://developercommunity.visualstudio.com/t/utf-8-locales-break-ctype-functions-for-wchar-type/1653678
     Feature(

>From 2ae1b7debea8513af0c223965f8ea2586f7062dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <dominik.wojt at arm.com>
Date: Tue, 12 Dec 2023 13:26:15 +0100
Subject: [PATCH 2/2] Remove the new feature. Mark the tests as UNSUPPORTED

---
 .../depr.c.headers/fenv_h.compile.pass.cpp    |  5 ++--
 .../numerics/cfenv/cfenv.syn/cfenv.pass.cpp   |  5 ++--
 libcxx/utils/libcxx/test/features.py          | 29 -------------------
 3 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp
index a896f5e03c3af7..289a3d1e5c63d1 100644
--- a/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp
@@ -6,8 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// Floating point exceptions are required for the FE_... macros to be defined.
-// REQUIRES: has-compolete-fenv
+// Picolibc does not define some of the floating point environment macros for
+// arm platforms without hardware floating point support.
+// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
 
 // <fenv.h>
 
diff --git a/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp b/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
index 5a39003d00d0f5..e6244c745549cd 100644
--- a/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
+++ b/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
@@ -6,8 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// Floating point exceptions are required for the FE_... macros to be defined.
-// REQUIRES: has-compolete-fenv
+// Picolibc does not define some of the floating point environment macros for
+// arm platforms without hardware floating point support.
+// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
 
 // <cfenv>
 
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 81e03fdc7418c6..5e854917e6ef45 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -224,35 +224,6 @@ def _getAndroidDeviceApi(cfg):
           """,
         ),
     ),
-    # Some platform do not provide complete floating point environment.
-    Feature(
-        name="has-compolete-fenv",
-        when=lambda cfg: sourceBuilds(
-            cfg,
-            """
-            #include <fenv.h>
-
-            #if !( \
-                defined FE_DIVBYZERO \
-                && defined FE_INEXACT \
-                && defined FE_INVALID \
-                && defined FE_INEXACT \
-                && defined FE_OVERFLOW \
-                && defined FE_UNDERFLOW \
-                && defined FE_ALL_EXCEPT \
-                && defined FE_DOWNWARD \
-                && defined FE_TONEAREST \
-                && defined FE_TOWARDZERO \
-                && defined FE_UPWARD \
-                && defined FE_DFL_ENV \
-                && defined FE_INEXACT)
-            #error Floating point environment not complete
-            #endif
-
-            int main(int, char**) { return 0; }
-          """,
-        ),
-    ),
     # Check for a Windows UCRT bug (fixed in UCRT/Windows 10.0.20348.0):
     # https://developercommunity.visualstudio.com/t/utf-8-locales-break-ctype-functions-for-wchar-type/1653678
     Feature(



More information about the libcxx-commits mailing list