Skip to content

[libc++] tests with picolibc: mark fenv tests as unsupported #74610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2023

Conversation

domin144
Copy link
Contributor

@domin144 domin144 commented Dec 6, 2023

The FE_* macros checked for in cfenv.pass.cpp are not required to be defined, if the relevant options are not available. Picolibc happens not to provide these on some platforms.

@domin144 domin144 requested a review from a team as a code owner December 6, 2023 15:43
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Dec 6, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 6, 2023

@llvm/pr-subscribers-libcxx

Author: Dominik Wójt (domin144)

Changes

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.


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

3 Files Affected:

  • (modified) libcxx/test/std/depr/depr.c.headers/fenv_h.compile.pass.cpp (+1-1)
  • (modified) libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp (+1-1)
  • (modified) libcxx/utils/libcxx/test/features.py (+29)
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 dcc97573d6073..a896f5e03c3af 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 7b3b490eba273..5a39003d00d0f 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 ccabb48833f10..f5b12f90c0510 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -212,6 +212,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(

@domin144
Copy link
Contributor Author

domin144 commented Dec 6, 2023

@ldionne @jroelofs

@ldionne ldionne changed the title [libc++] tests with picolibc: add has-compolete-fenv feature [libc++] tests with picolibc: add has-complete-fenv feature Dec 7, 2023
#include <fenv.h>

#if !( \
defined FE_DIVBYZERO \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit like a maintenance burden, if C adds new macros this need to be updated too.
Since we have not needed this before now I don't feel this solves a generic.
How about adding a comment and an // UNSUPPORTED: pico-lib identifier in these two tests instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to make sense to me, as I am doing tests on more configurations of picolibc and some of them do provide all the necessary macros (e.g. armv7m with fpu). Now, I realize this is not that useful for libc++ itself, as only one configuration is tested in CI here.

Yet, still I will switch from XFAIL to UNSUPPORTED to cater the configurations, where this test would pass.

@EricWF
Copy link
Member

EricWF commented Dec 9, 2023 via email

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.
@domin144 domin144 force-pushed the libcxx_picolibc_complete_fenv branch from 58abdbb to 2ae1b7d Compare December 12, 2023 12:31
@domin144 domin144 changed the title [libc++] tests with picolibc: add has-complete-fenv feature [libc++] tests with picolibc: mark fenv tests as unsupported Dec 12, 2023
@domin144 domin144 requested a review from mordante December 12, 2023 12:49
Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in this form -- I agree with other reviewers that adding the FE_foo checking in features.py was kind of iffy.

@ldionne ldionne merged commit ae85b39 into llvm:main Dec 12, 2023
@domin144 domin144 deleted the libcxx_picolibc_complete_fenv branch December 14, 2023 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants