Skip to content

[libcxx] [test] Use ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS in more places #144339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libcxx/test/std/containers/sequences/vector/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ struct throwing_iterator {
};

inline void check_new_delete_called() {
assert(globalMemCounter.new_called == globalMemCounter.delete_called);
assert(globalMemCounter.new_array_called == globalMemCounter.delete_array_called);
assert(globalMemCounter.aligned_new_called == globalMemCounter.aligned_delete_called);
assert(globalMemCounter.aligned_new_array_called == globalMemCounter.aligned_delete_array_called);
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.new_called == globalMemCounter.delete_called);
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.new_array_called == globalMemCounter.delete_array_called);
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.aligned_new_called == globalMemCounter.aligned_delete_called);
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.aligned_new_array_called == globalMemCounter.aligned_delete_array_called);
}

template <class T, typename Alloc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
// These tests require locale for non-char paths
// UNSUPPORTED: no-localization

// In MinGW mode, with optimizations enabled with a DLL, the number of counted
// allocations mismatches, as some ctor/dtor calls are generated in the
// calling code, and some are called from the DLL.
// ADDITIONAL_COMPILE_FLAGS: -DALLOW_MISMATCHING_LIBRRARY_INTERNAL_ALLOCATIONS

// <filesystem>

// class path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
// These tests require locale for non-char paths
// UNSUPPORTED: no-localization

// In MinGW mode, with optimizations enabled with a DLL, the number of counted
// allocations mismatches, as some ctor/dtor calls are generated in the
// calling code, and some are called from the DLL.
// ADDITIONAL_COMPILE_FLAGS: -DALLOW_MISMATCHING_LIBRRARY_INTERNAL_ALLOCATIONS

// <filesystem>

// class path
Expand Down
4 changes: 4 additions & 0 deletions libcxx/test/support/count_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,11 @@ struct RequireAllocationGuard {
void requireExactly(std::size_t N) { m_req_alloc = N; m_exactly = true; }

~RequireAllocationGuard() {
#ifdef ALLOW_MISMATCHING_LIBRRARY_INTERNAL_ALLOCATIONS
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkOutstandingNewEq(static_cast<int>(m_outstanding_new_on_init)));
#else
assert(globalMemCounter.checkOutstandingNewEq(static_cast<int>(m_outstanding_new_on_init)));
#endif
std::size_t Expect = m_new_count_on_init + m_req_alloc;
assert(globalMemCounter.checkNewCalledEq(static_cast<int>(Expect)) ||
(!m_exactly && globalMemCounter.checkNewCalledGreaterThan(static_cast<int>(Expect))));
Expand Down
Loading