From 50b80c36fab3baae5b51182c7a799cc8eb17bfdd Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 27 Oct 2016 21:25:12 +0000 Subject: [PATCH] [PATCH] D25483: [libcxx] [test] Fix non-Standard assumptions about how many elements are allocated llvm-svn: 285346 --- .../test/std/containers/sequences/deque/deque.cons/size.pass.cpp | 2 +- .../containers/sequences/deque/deque.cons/size_value.pass.cpp | 2 +- .../containers/sequences/list/list.cons/input_iterator.pass.cpp | 3 ++- .../std/containers/sequences/list/list.cons/size_type.pass.cpp | 3 ++- .../sequences/list/list.cons/size_value_alloc.pass.cpp | 3 ++- .../containers/sequences/vector/vector.capacity/reserve.pass.cpp | 3 ++- .../sequences/vector/vector.capacity/resize_size.pass.cpp | 6 ++++-- .../sequences/vector/vector.capacity/resize_size_value.pass.cpp | 3 ++- .../sequences/vector/vector.cons/construct_iter_iter.pass.cpp | 9 +++++---- .../sequences/vector/vector.cons/construct_size_value.pass.cpp | 3 ++- .../sequences/vector/vector.modifiers/push_back.pass.cpp | 5 ++++- .../sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp | 5 ++++- 12 files changed, 31 insertions(+), 16 deletions(-) diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp index 5b963be..e766b45 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp @@ -98,7 +98,7 @@ int main() test >(4096); test >(4097); - test1 >(4095); + LIBCPP_ONLY(test1 >(4095)); #if TEST_STD_VER >= 11 test >(4095); diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp index 626f3e9..e46a731 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp @@ -44,7 +44,7 @@ int main() test >(4095, 78); test >(4096, 1165); test >(4097, 157); - test >(4095, 90); + LIBCPP_ONLY(test >(4095, 90)); #if TEST_STD_VER >= 11 test >(4095, 90); #endif diff --git a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp index aff1385..3b3c2f7 100644 --- a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp @@ -43,7 +43,8 @@ int main() } { int a[] = {0, 1, 2, 3}; - std::list > l(input_iterator(a), + // Add 2 for implementations that dynamically allocate a sentinel node and container proxy. + std::list > l(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); assert(l.size() == sizeof(a)/sizeof(a[0])); assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0])); diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp index 4b298bd..317be0b 100644 --- a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp @@ -48,7 +48,8 @@ int main() assert(*i == 0); } { - std::list > l(3); + // Add 2 for implementations that dynamically allocate a sentinel node and container proxy. + std::list > l(3); assert(l.size() == 3); assert(std::distance(l.begin(), l.end()) == 3); std::list::const_iterator i = l.begin(); diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp index c989d58..d590626 100644 --- a/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp @@ -42,7 +42,8 @@ int main() assert(*i == 2); } { - std::list > l(3, 2); + // Add 2 for implementations that dynamically allocate a sentinel node and container proxy. + std::list > l(3, 2); assert(l.size() == 3); assert(std::distance(l.begin(), l.end()) == 3); std::list::const_iterator i = l.begin(); diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp index e49210b..abaa709 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp @@ -37,7 +37,8 @@ int main() assert(is_contiguous_container_asan_correct(v)); } { - std::vector > v(100); + // Add 1 for implementations that dynamically allocate a container proxy. + std::vector > v(100); assert(v.capacity() == 100); v.reserve(50); assert(v.size() == 100); diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp index 4f32705..6409aca 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp @@ -33,7 +33,8 @@ int main() assert(is_contiguous_container_asan_correct(v)); } { - std::vector > v(100); + // Add 1 for implementations that dynamically allocate a container proxy. + std::vector > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -56,7 +57,8 @@ int main() assert(is_contiguous_container_asan_correct(v)); } { - std::vector > v(100); + // Add 1 for implementations that dynamically allocate a container proxy. + std::vector > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp index 2225595..0bb9097 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp @@ -35,7 +35,8 @@ int main() assert(v[i] == 1); } { - std::vector > v(100); + // Add 1 for implementations that dynamically allocate a container proxy. + std::vector > v(100); v.resize(50, 1); assert(v.size() == 50); assert(v.capacity() == 100); diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index b0c4270..6b823e6 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -43,10 +43,11 @@ int main() test >(a, an); test > >(input_iterator(a), input_iterator(an)); - test > >(forward_iterator(a), forward_iterator(an)); - test > >(bidirectional_iterator(a), bidirectional_iterator(an)); - test > >(random_access_iterator(a), random_access_iterator(an)); - test > >(a, an); + // Add 1 for implementations that dynamically allocate a container proxy. + test > >(forward_iterator(a), forward_iterator(an)); + test > >(bidirectional_iterator(a), bidirectional_iterator(an)); + test > >(random_access_iterator(a), random_access_iterator(an)); + test > >(a, an); #if TEST_STD_VER >= 11 test> >(input_iterator(a), input_iterator(an)); test> >(forward_iterator(a), forward_iterator(an)); diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp index 2dbd23d..dcaaa2c 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp @@ -34,7 +34,8 @@ test(typename C::size_type n, const typename C::value_type& x) int main() { test >(50, 3); - test > >(50, 5); + // Add 1 for implementations that dynamically allocate a container proxy. + test > >(50, 5); #if TEST_STD_VER >= 11 test> >(50, 3); #endif diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp index aa4f83f..9a828ce 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp @@ -48,7 +48,10 @@ int main() assert(c[j] == j); } { - std::vector > c; + // libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8). + // Use 17 for implementations that dynamically allocate a container proxy + // and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6). + std::vector > c; c.push_back(0); assert(c.size() == 1); assert(is_contiguous_container_asan_correct(c)); diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp index c4bc837..eb9e7b5 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp @@ -50,7 +50,10 @@ int main() assert(c[j] == MoveOnly(j)); } { - std::vector > c; + // libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8). + // Use 17 for implementations that dynamically allocate a container proxy + // and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6). + std::vector > c; c.push_back(MoveOnly(0)); assert(c.size() == 1); assert(is_contiguous_container_asan_correct(c)); -- 2.7.4