Skip to content

Commit ec574f5

Browse files
committed
[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
1 parent 3af250f commit ec574f5

File tree

7 files changed

+73
-102
lines changed

7 files changed

+73
-102
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// test <stdlib.h>
10+
// ::aligned_alloc
11+
12+
// UNSUPPORTED: c++03, c++11, c++14
13+
14+
// ::aligned_alloc is provided by the C library, but it's marked as unavailable
15+
// until macOS 10.15
16+
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
17+
18+
// ::aligned_alloc is not implemented on Windows
19+
// XFAIL: target={{.+}}-pc-windows-{{.+}}
20+
21+
#include <stdlib.h>
22+
#include <type_traits>
23+
24+
static_assert(std::is_same<decltype(aligned_alloc(1, 0)), void*>::value, "");

libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
// test <stdlib.h>
1010

11-
// ::aligned_alloc is provided by the C library, but it's marked as unavailable
12-
// until macOS 10.15
13-
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
14-
15-
// ::aligned_alloc is not implemented on Windows
16-
// XFAIL: target={{.+}}-pc-windows-{{.+}}
17-
1811
#include <stdlib.h>
1912
#include <type_traits>
2013
#include <cassert>
@@ -139,9 +132,7 @@ int main(int, char**)
139132
static_assert((std::is_same<decltype(rand()), int>::value), "");
140133
static_assert((std::is_same<decltype(srand(0)), void>::value), "");
141134

142-
#if TEST_STD_VER > 14
143-
static_assert((std::is_same<decltype(aligned_alloc(1, 0)), void*>::value), "");
144-
#endif
135+
// aligned_alloc tested in stdlib_h.aligned_alloc.compile.pass.cpp
145136

146137
void* pv = 0;
147138
void (*handler)() = 0;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// test <cstdlib>
10+
// std::aligned_alloc
11+
12+
// UNSUPPORTED: c++03, c++11, c++14
13+
14+
// ::aligned_alloc is provided by the C library, but it's marked as unavailable
15+
// until macOS 10.15
16+
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
17+
18+
// ::aligned_alloc is not implemented on Windows
19+
// XFAIL: target={{.+}}-pc-windows-{{.+}}
20+
21+
#include <cstdlib>
22+
#include <type_traits>
23+
24+
static_assert(std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value, "");

libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
// test <cstdlib>
1010

11-
// ::aligned_alloc is provided by the C library, but it's marked as unavailable
12-
// until macOS 10.15
13-
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
14-
15-
// ::aligned_alloc is not implemented on Windows
16-
// XFAIL: target={{.+}}-pc-windows-{{.+}}
17-
1811
#include <cstdlib>
1912
#include <type_traits>
2013
#include <cassert>
@@ -126,9 +119,7 @@ int main(int, char**)
126119
static_assert((std::is_same<decltype(std::rand()), int>::value), "");
127120
static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
128121

129-
#if TEST_STD_VER > 14
130-
static_assert((std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value), "");
131-
#endif
122+
// std::aligned_alloc tested in cstdlib.aligned_alloc.compile.pass.cpp
132123

133124
void* pv = 0;
134125
void (*handler)() = 0;

libcxx/test/std/language.support/support.runtime/ctime.pass.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
// test <ctime>
1010

11-
// ::timespec_get is provided by the C library, but it's marked as
12-
// unavailable until macOS 10.15
13-
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
14-
1511
#include <ctime>
1612
#include <type_traits>
1713
#include "test_macros.h"
@@ -36,10 +32,7 @@ int main(int, char**)
3632
std::size_t s = 0;
3733
std::time_t t = 0;
3834
std::tm tm = {};
39-
#if TEST_STD_VER > 14
40-
std::timespec tmspec = {};
41-
((void)tmspec); // Prevent unused warning
42-
#endif
35+
// std::timespec and std::timespec_get tested in ctime.timespec.compile.pass.cpp
4336
((void)c); // Prevent unused warning
4437
((void)s); // Prevent unused warning
4538
((void)t); // Prevent unused warning
@@ -48,9 +41,6 @@ int main(int, char**)
4841
static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
4942
static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
5043
static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
51-
#if TEST_STD_VER > 14
52-
static_assert((std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value), "");
53-
#endif
5444
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
5545
static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
5646
static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// test <ctime>
10+
// std::timespec and std::timespec_get
11+
12+
// UNSUPPORTED: c++03, c++11, c++14
13+
14+
// ::timespec_get is provided by the C library, but it's marked as
15+
// unavailable until macOS 10.15
16+
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
17+
18+
#include <ctime>
19+
#include <type_traits>
20+
21+
std::timespec tmspec = {};
22+
static_assert(std::is_same<decltype(std::timespec_get(&tmspec, 0)), int>::value, "");

libcxx/test/std/utilities/time/date.time/ctime.pass.cpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)