Skip to content

Commit 94ef9a3

Browse files
committed
Test improvements
1 parent 189cdc1 commit 94ef9a3

22 files changed

+84
-56
lines changed

libcxx/src/log_error.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
namespace {
2525

2626
void log_security_failure(const char* message) noexcept {
27+
// Always log the message to `stderr` in case the platform-specific system calls fail.
28+
fprintf(stderr, "%s", message);
29+
2730
// On Apple platforms, use the `os_fault_with_payload` OS function that simulates a crash.
2831
#if defined(__APPLE__) && __has_include(<os/reason_private.h>)
2932
os_fault_with_payload(
@@ -42,9 +45,6 @@ void log_security_failure(const char* message) noexcept {
4245
openlog("libc++", 0, 0);
4346
syslog(LOG_CRIT, "%s", message);
4447
closelog();
45-
46-
#else
47-
fprintf(stderr, "%s", message);
4848
#endif
4949
}
5050

libcxx/test/libcxx/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,27 @@ int main(int, char**) {
4343
}
4444
// mismatch of static extent
4545
{
46-
TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents<int, D, 5> e1(std::array{1000, 3}); }()),
47-
"extents construction: mismatch of provided arguments with static extents.");
46+
TEST_LIBCPP_ASSERT_FAILURE(
47+
([] {
48+
[[maybe_unused]] std::extents<int, D, 5> e1(std::array{1000, 3});
49+
}()),
50+
"extents construction: mismatch of provided arguments with static extents.");
4851
}
4952
// value out of range
5053
{
51-
TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents<signed char, D, 5> e1(std::array{1000, 5}); }()),
52-
"extents ctor: arguments must be representable as index_type and nonnegative");
54+
TEST_LIBCPP_ASSERT_FAILURE(
55+
([] {
56+
[[maybe_unused]] std::extents<signed char, D, 5> e1(std::array{1000, 5});
57+
}()),
58+
"extents ctor: arguments must be representable as index_type and nonnegative");
5359
}
5460
// negative value
5561
{
56-
TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents<signed char, D, 5> e1(std::array{-1, 5}); }()),
57-
"extents ctor: arguments must be representable as index_type and nonnegative");
62+
TEST_LIBCPP_ASSERT_FAILURE(
63+
([] {
64+
[[maybe_unused]] std::extents<signed char, D, 5> e1(std::array{-1, 5});
65+
}()),
66+
"extents ctor: arguments must be representable as index_type and nonnegative");
5867
}
5968
return 0;
6069
}

libcxx/test/libcxx/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ int main(int, char**) {
4545
}
4646
// mismatch of static extent
4747
{
48-
TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents<int, D, 5> e1(1000, 3); }()),
48+
TEST_LIBCPP_ASSERT_FAILURE(([] { [[maybe_unused]] std::extents<int, D, 5> e1(1000, 3); }()),
4949
"extents construction: mismatch of provided arguments with static extents.");
5050
}
5151
// value out of range
5252
{
53-
TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents<signed char, D, 5> e1(1000, 5); }()),
53+
TEST_LIBCPP_ASSERT_FAILURE(([] { [[maybe_unused]] std::extents<signed char, D, 5> e1(1000, 5); }()),
5454
"extents ctor: arguments must be representable as index_type and nonnegative");
5555
}
5656
// negative value
5757
{
58-
TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents<signed char, D, 5> e1(-1, 5); }()),
58+
TEST_LIBCPP_ASSERT_FAILURE(([] { [[maybe_unused]] std::extents<signed char, D, 5> e1(-1, 5); }()),
5959
"extents ctor: arguments must be representable as index_type and nonnegative");
6060
}
6161
return 0;

libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.conversion.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main(int, char**) {
4444
{
4545
TEST_LIBCPP_ASSERT_FAILURE(
4646
([=] {
47-
std::layout_left::mapping<std::extents<signed char, D>> m(
47+
[[maybe_unused]] std::layout_left::mapping<std::extents<signed char, D>> m(
4848
std::layout_left::mapping<std::extents<int, D>>(std::extents<int, D>(500)));
4949
}()),
5050
"extents ctor: arguments must be representable as index_type and nonnegative");
@@ -55,7 +55,7 @@ int main(int, char**) {
5555
[[maybe_unused]] std::extents<signed char, D, 5> e(arg_exts);
5656
// but the product is not, so we can't use it for layout_left
5757
TEST_LIBCPP_ASSERT_FAILURE(
58-
([=] { std::layout_left::mapping<std::extents<signed char, D, 5>> m(arg); }()),
58+
([=] { [[maybe_unused]] std::layout_left::mapping<std::extents<signed char, D, 5>> m(arg); }()),
5959
"layout_left::mapping converting ctor: other.required_span_size() must be representable as index_type.");
6060
}
6161
return 0;

libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ int main(int, char**) {
3131
{
3232
// the extents are representable but the product is not, so we can't use it for layout_left
3333
TEST_LIBCPP_ASSERT_FAILURE(
34-
([=] { std::layout_left::mapping<std::extents<signed char, D, 5>> m(std::extents<signed char, D, 5>(100)); }()),
34+
([=] {
35+
[[maybe_unused]] std::layout_left::mapping<std::extents<signed char, D, 5>> m(
36+
std::extents<signed char, D, 5>(100));
37+
}()),
3538
"layout_left::mapping extents ctor: product of extents must be representable as index_type.");
3639
}
3740
return 0;

libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ int main(int, char**) {
3939
}
4040
// mismatch of static extent
4141
{
42-
TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_left::mapping<std::extents<int, 3>> m(arg); }()),
42+
TEST_LIBCPP_ASSERT_FAILURE(([=] { [[maybe_unused]] std::layout_left::mapping<std::extents<int, 3>> m(arg); }()),
4343
"extents construction: mismatch of provided arguments with static extents.");
4444
}
4545
// non-representability of extents itself
4646
{
4747
TEST_LIBCPP_ASSERT_FAILURE(
4848
([=] {
49-
std::layout_left::mapping<std::extents<signed char, D>> m(
49+
[[maybe_unused]] std::layout_left::mapping<std::extents<signed char, D>> m(
5050
std::layout_right::mapping<std::extents<int, D>>(std::extents<int, D>(500)));
5151
}()),
5252
"extents ctor: arguments must be representable as index_type and nonnegative");

libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.conversion.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ int main(int, char**) {
3737
}
3838
// mismatch of static extent
3939
{
40-
TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_right::mapping<std::extents<int, D, 3>> m(arg); }()),
40+
TEST_LIBCPP_ASSERT_FAILURE(([=] { [[maybe_unused]] std::layout_right::mapping<std::extents<int, D, 3>> m(arg); }()),
4141
"extents construction: mismatch of provided arguments with static extents.");
4242
}
4343
// non-representability of extents itself
4444
{
4545
TEST_LIBCPP_ASSERT_FAILURE(
4646
([=] {
47-
std::layout_right::mapping<std::extents<signed char, D>> m(
47+
[[maybe_unused]] std::layout_right::mapping<std::extents<signed char, D>> m(
4848
std::layout_right::mapping<std::extents<int, D>>(std::extents<int, D>(500)));
4949
}()),
5050
"extents ctor: arguments must be representable as index_type and nonnegative");
@@ -55,7 +55,7 @@ int main(int, char**) {
5555
[[maybe_unused]] std::extents<signed char, D, 5> e(arg_exts);
5656
// but the product is not, so we can't use it for layout_right
5757
TEST_LIBCPP_ASSERT_FAILURE(
58-
([=] { std::layout_right::mapping<std::extents<signed char, D, 5>> m(arg); }()),
58+
([=] { [[maybe_unused]] std::layout_right::mapping<std::extents<signed char, D, 5>> m(arg); }()),
5959
"layout_right::mapping converting ctor: other.required_span_size() must be representable as index_type.");
6060
}
6161
return 0;

libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ int main(int, char**) {
3232
// the extents are representable but the product is not, so we can't use it for layout_right
3333
TEST_LIBCPP_ASSERT_FAILURE(
3434
([=] {
35-
std::layout_right::mapping<std::extents<signed char, D, 5>> m(std::extents<signed char, D, 5>(100));
35+
[[maybe_unused]] std::layout_right::mapping<std::extents<signed char, D, 5>> m(
36+
std::extents<signed char, D, 5>(100));
3637
}()),
3738
"layout_right::mapping extents ctor: product of extents must be representable as index_type.");
3839
}

libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ int main(int, char**) {
3939
}
4040
// mismatch of static extent
4141
{
42-
TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_right::mapping<std::extents<int, 3>> m(arg); }()),
42+
TEST_LIBCPP_ASSERT_FAILURE(([=] { [[maybe_unused]] std::layout_right::mapping<std::extents<int, 3>> m(arg); }()),
4343
"extents construction: mismatch of provided arguments with static extents.");
4444
}
4545
// non-representability of extents itself
4646
{
4747
TEST_LIBCPP_ASSERT_FAILURE(
4848
([=] {
49-
std::layout_right::mapping<std::extents<signed char, D>> m(
49+
[[maybe_unused]] std::layout_right::mapping<std::extents<signed char, D>> m(
5050
std::layout_left::mapping<std::extents<int, D>>(std::extents<int, D>(500)));
5151
}()),
5252
"extents ctor: arguments must be representable as index_type and nonnegative");

libcxx/test/libcxx/containers/views/mdspan/layout_stride/assert.conversion.pass.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,24 @@ int main(int, char**) {
5858
{
5959
std::extents<int, D, D> arg_exts{100, 5};
6060
std::layout_stride::mapping<std::extents<int, D, D>> arg(arg_exts, std::array<int, 2>{1, 100});
61-
TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_stride::mapping<std::extents<int, D, 3>> m(arg); }()),
61+
TEST_LIBCPP_ASSERT_FAILURE(([=] { [[maybe_unused]] std::layout_stride::mapping<std::extents<int, D, 3>> m(arg); }()),
6262
"extents construction: mismatch of provided arguments with static extents.");
6363
}
6464
// non-representability of extents itself
6565
{
6666
TEST_LIBCPP_ASSERT_FAILURE(
6767
([=] {
68-
std::layout_stride::mapping<std::extents<signed char, D>> m(
68+
[[maybe_unused]] std::layout_stride::mapping<std::extents<signed char, D>> m(
6969
std::layout_stride::mapping<std::extents<int, D>>(std::extents<int, D>(500), std::array<int, 1>{1}));
7070
}()),
7171
"extents ctor: arguments must be representable as index_type and nonnegative");
7272
}
7373
// all strides must be larger than zero
7474
{
7575
always_convertible_layout::mapping<std::dextents<int, 2>> offset_map(std::dextents<int, 2>{10, 10}, 100, -1);
76-
TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_stride::mapping<std::extents<signed char, D, D>> m(offset_map); }()),
77-
"layout_stride::mapping converting ctor: all strides must be greater than 0");
76+
TEST_LIBCPP_ASSERT_FAILURE(
77+
([=] { [[maybe_unused]] std::layout_stride::mapping<std::extents<signed char, D, D>> m(offset_map); }()),
78+
"layout_stride::mapping converting ctor: all strides must be greater than 0");
7879
}
7980
// required_span_size not representable, while individual extents are
8081
{
@@ -84,7 +85,7 @@ int main(int, char**) {
8485
[[maybe_unused]] std::extents<signed char, D, 5> e(arg_exts);
8586
// but the product is not, so we can't use it for layout_stride
8687
TEST_LIBCPP_ASSERT_FAILURE(
87-
([=] { std::layout_stride::mapping<std::extents<signed char, D, 5>> m(arg); }()),
88+
([=] { [[maybe_unused]] std::layout_stride::mapping<std::extents<signed char, D, 5>> m(arg); }()),
8889
"layout_stride::mapping converting ctor: other.required_span_size() must be representable as index_type.");
8990
}
9091
// required_span_size not representable, while individual extents are, edge case
@@ -98,14 +99,15 @@ int main(int, char**) {
9899
[[maybe_unused]] std::extents<signed char, D, 10> e(arg_exts);
99100
// but the product is not, so we can't use it for layout_stride
100101
TEST_LIBCPP_ASSERT_FAILURE(
101-
([=] { std::layout_stride::mapping<std::extents<signed char, D, 10>> m(arg); }()),
102+
([=] { [[maybe_unused]] std::layout_stride::mapping<std::extents<signed char, D, 10>> m(arg); }()),
102103
"layout_stride::mapping converting ctor: other.required_span_size() must be representable as index_type.");
103104
}
104105
// base offset must be 0 (i.e. mapping(0,...,0)==0) for a strided layout with positive strides
105106
{
106107
always_convertible_layout::mapping<std::dextents<int, 2>> offset_map(std::dextents<int, 2>{10, 10}, 3);
107-
TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_stride::mapping<std::extents<signed char, D, D>> m(offset_map); }()),
108-
"layout_stride::mapping converting ctor: base offset of mapping must be zero.");
108+
TEST_LIBCPP_ASSERT_FAILURE(
109+
([=] { [[maybe_unused]] std::layout_stride::mapping<std::extents<signed char, D, D>> m(offset_map); }()),
110+
"layout_stride::mapping converting ctor: base offset of mapping must be zero.");
109111
}
110112
return 0;
111113
}

0 commit comments

Comments
 (0)