aboutsummaryrefslogtreecommitdiff
path: root/libcxx
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2021-08-18 08:31:40 -0400
committerLouis Dionne <ldionne.2@gmail.com>2021-08-18 11:57:20 -0400
commit404024f9adc1b0bb4b88e687472fc0c44cc6f6a2 (patch)
treeb8ba9d3ee8c9c195147c7092fcf37ae1d7cac4a4 /libcxx
parentc40c3bfa9a879510af230b75252c904a9af40f77 (diff)
downloadllvm-404024f9adc1b0bb4b88e687472fc0c44cc6f6a2.zip
llvm-404024f9adc1b0bb4b88e687472fc0c44cc6f6a2.tar.gz
llvm-404024f9adc1b0bb4b88e687472fc0c44cc6f6a2.tar.bz2
[libc++] Split off tests for aligned_alloc & friends into separate test files
This allows testing the rest of those headers on most platforms, instead of XFAILing the whole test just because of a few functions. As a fly-by fix, remove std/utilities/time/date.time/ctime.pass.cpp, which was a duplicate of std/language.support/support.runtime/ctime.pass.cpp. Differential Revision: https://reviews.llvm.org/D108295 (cherry picked from commit ec574f5da463d303a3771597c233e52d2429db67)
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/test/std/depr/depr.c.headers/stdlib_h.aligned_alloc.compile.pass.cpp24
-rw-r--r--libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp11
-rw-r--r--libcxx/test/std/language.support/support.runtime/cstdlib.aligned_alloc.compile.pass.cpp24
-rw-r--r--libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp11
-rw-r--r--libcxx/test/std/language.support/support.runtime/ctime.pass.cpp12
-rw-r--r--libcxx/test/std/language.support/support.runtime/ctime.timespec.compile.pass.cpp22
-rw-r--r--libcxx/test/std/utilities/time/date.time/ctime.pass.cpp71
7 files changed, 73 insertions, 102 deletions
diff --git a/libcxx/test/std/depr/depr.c.headers/stdlib_h.aligned_alloc.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdlib_h.aligned_alloc.compile.pass.cpp
new file mode 100644
index 0000000..9dfe3af
--- /dev/null
+++ b/libcxx/test/std/depr/depr.c.headers/stdlib_h.aligned_alloc.compile.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdlib.h>
+// ::aligned_alloc
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// ::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>
+
+static_assert(std::is_same<decltype(aligned_alloc(1, 0)), void*>::value, "");
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 7dcae5a..83d1710 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,13 +8,6 @@
// 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>
@@ -139,9 +132,7 @@ 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
- static_assert((std::is_same<decltype(aligned_alloc(1, 0)), void*>::value), "");
-#endif
+ // aligned_alloc tested in stdlib_h.aligned_alloc.compile.pass.cpp
void* pv = 0;
void (*handler)() = 0;
diff --git a/libcxx/test/std/language.support/support.runtime/cstdlib.aligned_alloc.compile.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdlib.aligned_alloc.compile.pass.cpp
new file mode 100644
index 0000000..f8af337
--- /dev/null
+++ b/libcxx/test/std/language.support/support.runtime/cstdlib.aligned_alloc.compile.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdlib>
+// std::aligned_alloc
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// ::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>
+
+static_assert(std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value, "");
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 6cf58be..19d0750 100644
--- a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp
@@ -8,13 +8,6 @@
// 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>
@@ -126,9 +119,7 @@ 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
- static_assert((std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value), "");
-#endif
+ // std::aligned_alloc tested in cstdlib.aligned_alloc.compile.pass.cpp
void* pv = 0;
void (*handler)() = 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 fd5cad3..6c3f366 100644
--- a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
@@ -8,10 +8,6 @@
// 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"
@@ -36,10 +32,7 @@ int main(int, char**)
std::size_t s = 0;
std::time_t t = 0;
std::tm tm = {};
-#if TEST_STD_VER > 14
- std::timespec tmspec = {};
- ((void)tmspec); // Prevent unused warning
-#endif
+ // std::timespec and std::timespec_get tested in ctime.timespec.compile.pass.cpp
((void)c); // Prevent unused warning
((void)s); // Prevent unused warning
((void)t); // Prevent unused warning
@@ -48,9 +41,6 @@ int main(int, char**)
static_assert((std::is_same<decltype(std::difftime(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
- static_assert((std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value), "");
-#endif
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
diff --git a/libcxx/test/std/language.support/support.runtime/ctime.timespec.compile.pass.cpp b/libcxx/test/std/language.support/support.runtime/ctime.timespec.compile.pass.cpp
new file mode 100644
index 0000000..b8a4460
--- /dev/null
+++ b/libcxx/test/std/language.support/support.runtime/ctime.timespec.compile.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// test <ctime>
+// std::timespec and std::timespec_get
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// ::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>
+
+std::timespec tmspec = {};
+static_assert(std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value, "");
diff --git a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
deleted file mode 100644
index 8987a4c..0000000
--- a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
+++ /dev/null
@@ -1,71 +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
-//
-//===----------------------------------------------------------------------===//
-
-// 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"
-
-#ifndef NULL
-#error NULL not defined
-#endif
-
-#ifndef CLOCKS_PER_SEC
-#error CLOCKS_PER_SEC not defined
-#endif
-
-#if TEST_STD_VER > 14
-#ifndef TIME_UTC
-#error TIME_UTC not defined
-#endif
-#endif
-
-#if defined(__GNUC__)
-#pragma GCC diagnostic ignored "-Wformat-zero-length"
-#endif
-
-int main(int, char**)
-{
- std::clock_t c = 0;
- std::size_t s = 0;
- std::time_t t = 0;
- std::tm tm = {};
- char str[3];
- ((void)c); // Prevent unused warning
- ((void)s); // Prevent unused warning
- ((void)t); // Prevent unused warning
- ((void)tm); // Prevent unused warning
- ((void)str); // Prevent unused warning
-#if TEST_STD_VER > 14
- std::timespec tmspec = {};
- ((void)tmspec); // Prevent unused warning
-#endif
-
- static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
- static_assert((std::is_same<decltype(std::difftime(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
- static_assert((std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value), "");
-#endif
-#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
- static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
- static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
- static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
- static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
-#endif
- static_assert((std::is_same<decltype(std::strftime(str,s,"",&tm)), std::size_t>::value), "");
-
- return 0;
-}