Skip to content

Commit c311ad7

Browse files
Fix tests
1 parent bc73de0 commit c311ad7

File tree

16 files changed

+65
-56
lines changed

16 files changed

+65
-56
lines changed

libcxx/src/stacktrace/trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ _LIBCPP_EXPORTED_FROM_ABI ostream& _Trace::write_to(std::ostream& __os) const {
3939

4040
// printf-style format to a small buffer, to avoid messing with stream (with `setw` etc.)
4141
char index_str[21];
42-
snprintf(index_str, sizeof(index_str), "%3lu", __i + 1);
42+
snprintf(index_str, sizeof(index_str), "%3zu", __i + 1);
4343
__os << " frame " << index_str << ": " << entry;
4444
}
4545
}

libcxx/test/std/diagnostics/stacktrace/basic.cmp/equality.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
// Call chain is: main -> c -> b -> a -> stacktrace::current;
2323
// we're only checking a, b, c in the returned stacktrace, so use max_depth of 3.
24-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a(size_t skip = 0) { return std::stacktrace::current(skip, 3); }
25-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b(size_t skip = 0) { return a(skip); }
26-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c(size_t skip = 0) { return b(skip); }
24+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a(size_t skip = 0) { return std::stacktrace::current(skip, 3); }
25+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b(size_t skip = 0) { return a(skip); }
26+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c(size_t skip = 0) { return b(skip); }
2727

2828
int main(int, char**) {
2929
std::stacktrace st0;

libcxx/test/std/diagnostics/stacktrace/basic.cmp/strong_ordering.pass.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cassert>
2222
#include <cstdint>
2323
#include <stacktrace>
24+
#include <vector>
2425

2526
namespace {
2627

@@ -40,22 +41,20 @@ std::stacktrace fake_trace(std::vector<uintptr_t> const& addrs) {
4041
} // namespace
4142

4243
int main(int, char**) {
43-
using vec = std::vector<uintptr_t>;
44-
4544
auto lt = std::strong_ordering::less;
4645
auto eq = std::strong_ordering::equal;
4746
auto gt = std::strong_ordering::greater;
4847

49-
assert(lt == (fake_trace(vec{}) <=> fake_trace(vec{100})));
50-
assert(lt == (fake_trace(vec{99}) <=> fake_trace(vec{100})));
51-
assert(lt == (fake_trace(vec{100}) <=> fake_trace(vec{100, 200})));
48+
assert(lt == (fake_trace({}) <=> fake_trace({100})));
49+
assert(lt == (fake_trace({99}) <=> fake_trace({100})));
50+
assert(lt == (fake_trace({100}) <=> fake_trace({100, 200})));
5251

53-
assert(eq == (fake_trace(vec{}) <=> fake_trace(vec{})));
54-
assert(eq == (fake_trace(vec{100}) <=> fake_trace(vec{100})));
52+
assert(eq == (fake_trace({}) <=> fake_trace({})));
53+
assert(eq == (fake_trace({100}) <=> fake_trace({100})));
5554

56-
assert(gt == (fake_trace(vec{100}) <=> fake_trace(vec{})));
57-
assert(gt == (fake_trace(vec{100}) <=> fake_trace(vec{99})));
58-
assert(gt == (fake_trace(vec{100, 200}) <=> fake_trace(vec{100})));
55+
assert(gt == (fake_trace({100}) <=> fake_trace({})));
56+
assert(gt == (fake_trace({100}) <=> fake_trace({99})));
57+
assert(gt == (fake_trace({100, 200}) <=> fake_trace({100})));
5958

6059
return 0;
6160
}

libcxx/test/std/diagnostics/stacktrace/basic.cons/current.pass.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@
2727
#include <cassert>
2828
#include <cstdint>
2929
#include <stacktrace>
30+
#include <vector>
31+
3032
#include "test_macros.h"
3133

3234
// These let us produce dummy functions with distinct addresses to build test stacks.
3335
// `main` calls `c`, which calls `b`, which calls `a`, which calls `current`;
3436
// therefore the stacktrace built in `a` should contain, starting at the top,
3537
// `a`, `b`, `c` (followed by `main`, `_start` on some platforms, and so on).
3638

37-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a(size_t skip = 0, size_t max_depth = 99) {
39+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a(size_t skip = 0, size_t max_depth = 99) {
3840
return std::stacktrace::current(skip, max_depth);
3941
}
40-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b(size_t skip = 0, size_t max_depth = 99) {
42+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b(size_t skip = 0, size_t max_depth = 99) {
4143
return a(skip, max_depth);
4244
}
43-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c(size_t skip = 0, size_t max_depth = 99) {
45+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c(size_t skip = 0, size_t max_depth = 99) {
4446
return b(skip, max_depth);
4547
}
4648

@@ -60,8 +62,6 @@ void expect_trace(const std::stacktrace& st, std::vector<uintptr_t> const& expec
6062
}
6163

6264
int main(int, char**) {
63-
using vec = std::vector<uintptr_t>;
64-
6565
// All overloads are noexcept
6666
static_assert(noexcept(std::stacktrace::current()));
6767
static_assert(noexcept(std::stacktrace::current({})));
@@ -72,17 +72,17 @@ int main(int, char**) {
7272
// skip == 0 yields top frames a, b, c (we ignore other frames).
7373
// skip removes that many top frames; max_depth caps the number of frames returned.
7474

75-
expect_trace(c(0, 3), vec{_a, _b, _c});
76-
expect_trace(c(0, 2), vec{_a, _b});
77-
expect_trace(c(0, 1), vec{_a});
78-
expect_trace(c(0, 0), vec{});
75+
expect_trace(c(0, 3), {_a, _b, _c});
76+
expect_trace(c(0, 2), {_a, _b});
77+
expect_trace(c(0, 1), {_a});
78+
expect_trace(c(0, 0), {});
7979

80-
expect_trace(c(1, 2), vec{_b, _c});
81-
expect_trace(c(1, 1), vec{_b});
82-
expect_trace(c(1, 0), vec{});
80+
expect_trace(c(1, 2), {_b, _c});
81+
expect_trace(c(1, 1), {_b});
82+
expect_trace(c(1, 0), {});
8383

84-
expect_trace(c(2, 1), vec{_c});
85-
expect_trace(c(2, 0), vec{});
84+
expect_trace(c(2, 1), {_c});
85+
expect_trace(c(2, 0), {});
8686

8787
return 0;
8888
}

libcxx/test/std/diagnostics/stacktrace/basic.obs/at.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include "test_macros.h"
1919

2020
// Call chain is: main -> c -> b -> a -> stacktrace::current
21-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a() { return std::stacktrace::current(); }
22-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b() { return a(); }
23-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c() { return b(); }
21+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a() { return std::stacktrace::current(); }
22+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b() { return a(); }
23+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c() { return b(); }
2424

2525
int main(int, char**) {
2626
auto const st = c();

libcxx/test/std/diagnostics/stacktrace/basic.obs/begin_end.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "test_macros.h"
2121

2222
// Call chain is: main -> c -> b -> a -> stacktrace::current
23-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a() { return std::stacktrace::current(); }
24-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b() { return a(); }
25-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c() { return b(); }
23+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a() { return std::stacktrace::current(); }
24+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b() { return a(); }
25+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c() { return b(); }
2626

2727
int main(int, char**) {
2828
{

libcxx/test/std/diagnostics/stacktrace/basic.obs/cbegin_cend.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "test_macros.h"
2121

2222
// Call chain is: main -> c -> b -> a -> stacktrace::current
23-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a() { return std::stacktrace::current(); }
24-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b() { return a(); }
25-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c() { return b(); }
23+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a() { return std::stacktrace::current(); }
24+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b() { return a(); }
25+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c() { return b(); }
2626

2727
int main(int, char**) {
2828
{

libcxx/test/std/diagnostics/stacktrace/basic.obs/crbegin_crend.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "test_macros.h"
2121

2222
// Call chain is: main -> c -> b -> a -> stacktrace::current
23-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a() { return std::stacktrace::current(); }
24-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b() { return a(); }
25-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c() { return b(); }
23+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a() { return std::stacktrace::current(); }
24+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b() { return a(); }
25+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c() { return b(); }
2626

2727
int main(int, char**) {
2828
{

libcxx/test/std/diagnostics/stacktrace/basic.obs/empty.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "test_macros.h"
2121

2222
// Call chain is: main -> c -> b -> a -> stacktrace::current
23-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace a() { return std::stacktrace::current(); }
24-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace b() { return a(); }
25-
TEST_NOINLINE TEST_NO_TAIL_CALLS std::stacktrace c() { return b(); }
23+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace a() { return std::stacktrace::current(); }
24+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace b() { return a(); }
25+
TEST_NO_TAIL_CALLS TEST_NOINLINE std::stacktrace c() { return b(); }
2626

2727
int main(int, char**) {
2828
std::stacktrace st;

0 commit comments

Comments
 (0)