[llvm-branch-commits] [libcxx] c40c3bf - [libc++] Convert test-suite workarounds for some C11 features to XFAILs

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 18 09:03:00 PDT 2021


Author: Louis Dionne
Date: 2021-08-18T11:57:16-04:00
New Revision: c40c3bfa9a879510af230b75252c904a9af40f77

URL: https://github.com/llvm/llvm-project/commit/c40c3bfa9a879510af230b75252c904a9af40f77
DIFF: https://github.com/llvm/llvm-project/commit/c40c3bfa9a879510af230b75252c904a9af40f77.diff

LOG: [libc++] Convert test-suite workarounds for some C11 features to XFAILs

Instead of trying to sniff out what features are supported by the
library being tested, the way we normally handle these things is with
Lit annotations. This should not be treated differently.

Differential Revision: https://reviews.llvm.org/D108209

(cherry picked from commit ed7c81d1726c7ecd03d1bc13eeb8d23fdffa5751)

Added: 
    

Modified: 
    libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
    libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp
    libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
    libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
    libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
    libcxx/test/support/test_macros.h

Removed: 
    libcxx/test/libcxx/language.support/has_aligned_alloc.compile.pass.cpp
    libcxx/test/libcxx/language.support/has_quick_exit.compile.pass.cpp
    libcxx/test/libcxx/language.support/has_timespec_get.compile.pass.cpp
    libcxx/test/std/language.support/support.start.term/at_quick_exit.compile.fail.cpp
    libcxx/test/std/language.support/support.start.term/quick_exit.compile.fail.cpp


################################################################################
diff  --git a/libcxx/test/libcxx/language.support/has_aligned_alloc.compile.pass.cpp b/libcxx/test/libcxx/language.support/has_aligned_alloc.compile.pass.cpp
deleted file mode 100644
index d1b41de5dc1a9..0000000000000
--- a/libcxx/test/libcxx/language.support/has_aligned_alloc.compile.pass.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03, c++11, c++14
-
-// Make sure TEST_HAS_ALIGNED_ALLOC (defined by the test suite) and
-// _LIBCPP_HAS_ALIGNED_ALLOC (defined by libc++) stay in sync.
-
-#include <__config>
-#include "test_macros.h"
-
-#if defined(TEST_HAS_ALIGNED_ALLOC) != defined(_LIBCPP_HAS_ALIGNED_ALLOC)
-#   error "TEST_HAS_ALIGNED_ALLOC and _LIBCPP_HAS_ALIGNED_ALLOC are out of sync"
-#endif

diff  --git a/libcxx/test/libcxx/language.support/has_quick_exit.compile.pass.cpp b/libcxx/test/libcxx/language.support/has_quick_exit.compile.pass.cpp
deleted file mode 100644
index ad0fe6fb18fd1..0000000000000
--- a/libcxx/test/libcxx/language.support/has_quick_exit.compile.pass.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03, c++11, c++14
-
-// Make sure TEST_HAS_QUICK_EXIT (defined by the test suite) and
-// _LIBCPP_HAS_QUICK_EXIT (defined by libc++) stay in sync.
-
-#include <__config>
-#include "test_macros.h"
-
-#if defined(TEST_HAS_QUICK_EXIT) != defined(_LIBCPP_HAS_QUICK_EXIT)
-#   error "TEST_HAS_QUICK_EXIT and _LIBCPP_HAS_QUICK_EXIT are out of sync"
-#endif

diff  --git a/libcxx/test/libcxx/language.support/has_timespec_get.compile.pass.cpp b/libcxx/test/libcxx/language.support/has_timespec_get.compile.pass.cpp
deleted file mode 100644
index 8b86a5ef97195..0000000000000
--- a/libcxx/test/libcxx/language.support/has_timespec_get.compile.pass.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03, c++11, c++14
-
-// Make sure TEST_HAS_TIMESPEC_GET (defined by the test suite) and
-// _LIBCPP_HAS_TIMESPEC_GET (defined by libc++) stay in sync.
-
-#include <__config>
-#include "test_macros.h"
-
-#if defined(TEST_HAS_TIMESPEC_GET) != defined(_LIBCPP_HAS_TIMESPEC_GET)
-#   error "TEST_HAS_TIMESPEC_GET and _LIBCPP_HAS_TIMESPEC_GET are out of sync"
-#endif

diff  --git a/libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
index 295f51807d41f..7dcae5aa5f485 100644
--- a/libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
@@ -8,6 +8,13 @@
 
 // test <stdlib.h>
 
+// ::aligned_alloc is provided by the C library, but it's marked as unavailable
+// until macOS 10.15
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
+
+// ::aligned_alloc is not implemented on Windows
+// XFAIL: target={{.+}}-pc-windows-{{.+}}
+
 #include <stdlib.h>
 #include <type_traits>
 #include <cassert>
@@ -132,9 +139,8 @@ int main(int, char**)
     static_assert((std::is_same<decltype(rand()), int>::value), "");
     static_assert((std::is_same<decltype(srand(0)), void>::value), "");
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_ALIGNED_ALLOC)
-    static_assert((std::is_same<decltype(aligned_alloc(1, 0)), void*>::value),
-                  "");
+#if TEST_STD_VER > 14
+    static_assert((std::is_same<decltype(aligned_alloc(1, 0)), void*>::value), "");
 #endif
 
     void* pv = 0;

diff  --git a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp
index 668213f84838c..6cf58be9e8f87 100644
--- a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp
@@ -8,6 +8,13 @@
 
 // test <cstdlib>
 
+// ::aligned_alloc is provided by the C library, but it's marked as unavailable
+// until macOS 10.15
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
+
+// ::aligned_alloc is not implemented on Windows
+// XFAIL: target={{.+}}-pc-windows-{{.+}}
+
 #include <cstdlib>
 #include <type_traits>
 #include <cassert>
@@ -119,9 +126,8 @@ int main(int, char**)
     static_assert((std::is_same<decltype(std::rand()), int>::value), "");
     static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_ALIGNED_ALLOC)
-    static_assert(
-        (std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value), "");
+#if TEST_STD_VER > 14
+    static_assert((std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value), "");
 #endif
 
     void* pv = 0;

diff  --git a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
index df827793a1282..fd5cad3460e25 100644
--- a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
@@ -8,6 +8,10 @@
 
 // test <ctime>
 
+// ::timespec_get is provided by the C library, but it's marked as
+// unavailable until macOS 10.15
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
+
 #include <ctime>
 #include <type_traits>
 #include "test_macros.h"
@@ -20,7 +24,7 @@
 #error CLOCKS_PER_SEC not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
+#if TEST_STD_VER > 14
 #ifndef TIME_UTC
 #error TIME_UTC not defined
 #endif
@@ -32,7 +36,7 @@ int main(int, char**)
     std::size_t s = 0;
     std::time_t t = 0;
     std::tm tm = {};
-#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
+#if TEST_STD_VER > 14
     std::timespec tmspec = {};
     ((void)tmspec); // Prevent unused warning
 #endif
@@ -44,7 +48,7 @@ int main(int, char**)
     static_assert((std::is_same<decltype(std::
diff time(t,t)), double>::value), "");
     static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
     static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
+#if TEST_STD_VER > 14
     static_assert((std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS

diff  --git a/libcxx/test/std/language.support/support.start.term/at_quick_exit.compile.fail.cpp b/libcxx/test/std/language.support/support.start.term/at_quick_exit.compile.fail.cpp
deleted file mode 100644
index 79051fb5167d4..0000000000000
--- a/libcxx/test/std/language.support/support.start.term/at_quick_exit.compile.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03
-
-// test that referencing at_quick_exit when TEST_HAS_QUICK_EXIT is not defined
-// results in a compile error.
-
-#include <cstdlib>
-
-#include "test_macros.h"
-
-void f() { }
-
-int main(int, char**) {
-#if !defined(TEST_HAS_QUICK_EXIT)
-    std::at_quick_exit(f);
-#else
-#   error
-#endif
-    return 0;
-}

diff  --git a/libcxx/test/std/language.support/support.start.term/quick_exit.compile.fail.cpp b/libcxx/test/std/language.support/support.start.term/quick_exit.compile.fail.cpp
deleted file mode 100644
index f9c5bdc835694..0000000000000
--- a/libcxx/test/std/language.support/support.start.term/quick_exit.compile.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03
-
-// test that referencing quick_exit when TEST_HAS_QUICK_EXIT is not defined
-// results in a compile error.
-
-#include <cstdlib>
-
-#include "test_macros.h"
-
-int main(int, char**) {
-#if !defined(TEST_HAS_QUICK_EXIT)
-    std::quick_exit(0);
-#else
-#   error
-#endif
-    return 0;
-}

diff  --git a/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp b/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
index 16f68d435640c..83ff44a4f6dc7 100644
--- a/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
+++ b/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
@@ -5,22 +5,23 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+
 // UNSUPPORTED: c++03
 
+// ::quick_exit and ::at_quick_exit are not implemented on macOS.
+// TODO: We should never be using `darwin` as the triple, but LLVM's config.guess script
+//       guesses the host triple to be darwin instead of macosx when on macOS.
+// XFAIL: target={{.+}}-apple-macosx{{.+}}
+// XFAIL: target={{.+}}-apple-darwin{{.+}}
+
 // test quick_exit and at_quick_exit
 
 #include <cstdlib>
 
-#include "test_macros.h"
-
 void f() {}
 
-int main(int, char**)
-{
-#ifdef TEST_HAS_QUICK_EXIT
+int main(int, char**) {
     std::at_quick_exit(f);
     std::quick_exit(0);
-#endif
-
-  return 0;
+    return 0;
 }

diff  --git a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
index 8ad3cca4758e0..8987a4ceb5f69 100644
--- a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
+++ b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
@@ -6,6 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+// test <ctime>
+
+// ::timespec_get is provided by the C library, but it's marked as
+// unavailable until macOS 10.15
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
+
 #include <ctime>
 #include <type_traits>
 
@@ -19,7 +25,7 @@
 #error CLOCKS_PER_SEC not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
+#if TEST_STD_VER > 14
 #ifndef TIME_UTC
 #error TIME_UTC not defined
 #endif
@@ -41,7 +47,7 @@ int main(int, char**)
     ((void)t); // Prevent unused warning
     ((void)tm); // Prevent unused warning
     ((void)str); // Prevent unused warning
-#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
+#if TEST_STD_VER > 14
     std::timespec tmspec = {};
     ((void)tmspec); // Prevent unused warning
 #endif
@@ -50,7 +56,7 @@ int main(int, char**)
     static_assert((std::is_same<decltype(std::
diff time(t,t)), double>::value), "");
     static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
     static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
+#if TEST_STD_VER > 14
     static_assert((std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS

diff  --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 96c6965ec65d4..bd08ddfabfc60 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -163,67 +163,6 @@
 # define TEST_CONSTEXPR_CXX20
 #endif
 
-// Sniff out to see if the underlying C library has C11 features
-// This is cribbed from __config; but lives here as well because we can't assume libc++
-#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) ||                 \
-    TEST_STD_VER >= 11
-#  if defined(__FreeBSD__)
-#    if __FreeBSD_version >= 1300064 || \
-       (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
-#      define TEST_HAS_TIMESPEC_GET
-#    endif
-#    define TEST_HAS_ALIGNED_ALLOC
-#    define TEST_HAS_QUICK_EXIT
-#  elif defined(__BIONIC__)
-#    if __ANDROID_API__ >= 21
-#      define TEST_HAS_QUICK_EXIT
-#    endif
-#    if __ANDROID_API__ >= 28
-#      define TEST_HAS_ALIGNED_ALLOC
-#    endif
-#    if __ANDROID_API__ >= 29
-#      define TEST_HAS_TIMESPEC_GET
-#    endif
-#  elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
-#    define TEST_HAS_QUICK_EXIT
-#    define TEST_HAS_ALIGNED_ALLOC
-#    define TEST_HAS_TIMESPEC_GET
-#  elif defined(__linux__)
-// This block preserves the old behavior used by include/__config:
-// _LIBCPP_GLIBC_PREREQ would be defined to 0 if __GLIBC_PREREQ was not
-// available. The configuration here may be too vague though, as Bionic, uClibc,
-// newlib, etc may all support these features but need to be configured.
-#    if defined(TEST_GLIBC_PREREQ)
-#      if TEST_GLIBC_PREREQ(2, 15)
-#        define TEST_HAS_QUICK_EXIT
-#      endif
-#      if TEST_GLIBC_PREREQ(2, 17)
-#        define TEST_HAS_ALIGNED_ALLOC
-#        define TEST_HAS_TIMESPEC_GET
-#      endif
-#    elif defined(_LIBCPP_HAS_MUSL_LIBC)
-#      define TEST_HAS_QUICK_EXIT
-#      define TEST_HAS_ALIGNED_ALLOC
-#      define TEST_HAS_TIMESPEC_GET
-#    endif
-#  elif defined(_WIN32)
-#    if defined(_MSC_VER) && !defined(__MINGW32__)
-#      define TEST_HAS_QUICK_EXIT
-#      define TEST_HAS_TIMESPEC_GET
-#    endif
-#  elif defined(__APPLE__)
-     // timespec_get and aligned_alloc were introduced in macOS 10.15 and
-     // aligned releases
-#    if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
-         (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
-         (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
-         (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
-#      define TEST_HAS_ALIGNED_ALLOC
-#      define TEST_HAS_TIMESPEC_GET
-#    endif
-#  endif // __APPLE__
-#endif
-
 /* Features that were introduced in C++14 */
 #if TEST_STD_VER >= 14
 #define TEST_HAS_EXTENDED_CONSTEXPR


        


More information about the llvm-branch-commits mailing list