diff options
Diffstat (limited to 'libs/interprocess/test')
31 files changed, 143 insertions, 547 deletions
diff --git a/libs/interprocess/test/allocator_v1.hpp b/libs/interprocess/test/allocator_v1.hpp index e073aef79..d68ef9f40 100644 --- a/libs/interprocess/test/allocator_v1.hpp +++ b/libs/interprocess/test/allocator_v1.hpp @@ -23,12 +23,8 @@ #include <boost/interprocess/interprocess_fwd.hpp> #include <boost/interprocess/containers/allocation_type.hpp> #include <boost/interprocess/detail/utilities.hpp> -#include <boost/interprocess/containers/version_type.hpp> #include <boost/interprocess/exceptions.hpp> -#include <memory> -#include <algorithm> -#include <cstddef> -#include <stdexcept> +#include <boost/move/adl_move_swap.hpp> #include <boost/static_assert.hpp> //!\file @@ -146,7 +142,7 @@ class allocator_v1 //!Swap segment manager. Does not throw. If each allocator_v1 is placed in //!different memory segments, the result is undefined. friend void swap(self_t &alloc1, self_t &alloc2) - { ipcdetail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } + { ::boost::adl_move_swap(alloc1.mp_mngr, alloc2.mp_mngr); } }; //!Equality test for same type of allocator_v1 diff --git a/libs/interprocess/test/allocexcept_test.cpp b/libs/interprocess/test/allocexcept_test.cpp index 2482f6f13..696b27973 100644 --- a/libs/interprocess/test/allocexcept_test.cpp +++ b/libs/interprocess/test/allocexcept_test.cpp @@ -14,7 +14,6 @@ #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/containers/list.hpp> #include <iostream> -#include <algorithm> #include <functional> #include "print_container.hpp" #include <string> diff --git a/libs/interprocess/test/check_equal_containers.hpp b/libs/interprocess/test/check_equal_containers.hpp index 97df4d53f..80fe93f02 100644 --- a/libs/interprocess/test/check_equal_containers.hpp +++ b/libs/interprocess/test/check_equal_containers.hpp @@ -12,9 +12,8 @@ #define BOOST_INTERPROCESS_TEST_CHECK_EQUAL_CONTAINERS_HPP #include <boost/interprocess/detail/config_begin.hpp> -#include <functional> -#include <iostream> -#include <algorithm> +// container/detail +#include <boost/container/detail/iterator.hpp> #include <boost/container/detail/pair.hpp> namespace boost{ @@ -50,7 +49,8 @@ bool CheckEqualContainers(MyShmCont *shmcont, MyStdCont *stdcont) typename MyShmCont::iterator itshm(shmcont->begin()), itshmend(shmcont->end()); typename MyStdCont::iterator itstd(stdcont->begin()); - typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itshm, itshmend); + typename MyStdCont::size_type dist = + typename MyStdCont::size_type(boost::container::iterator_distance(itshm, itshmend)); if(dist != shmcont->size()){ return false; } diff --git a/libs/interprocess/test/data_test.cpp b/libs/interprocess/test/data_test.cpp index 7c4e58bc7..450031b26 100644 --- a/libs/interprocess/test/data_test.cpp +++ b/libs/interprocess/test/data_test.cpp @@ -13,8 +13,6 @@ #include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/containers/list.hpp> -#include <iostream> -#include <algorithm> #include <functional> #include <string> #include "print_container.hpp" diff --git a/libs/interprocess/test/deque_test.cpp b/libs/interprocess/test/deque_test.cpp index 6d2e36d4f..4b3ee3cd1 100644 --- a/libs/interprocess/test/deque_test.cpp +++ b/libs/interprocess/test/deque_test.cpp @@ -9,11 +9,9 @@ ////////////////////////////////////////////////////////////////////////////// #include <boost/interprocess/detail/config_begin.hpp> -#include <algorithm> #include <memory> #include <deque> #include <iostream> -#include <functional> #include <list> #include <boost/interprocess/managed_shared_memory.hpp> diff --git a/libs/interprocess/test/dummy_test_allocator.hpp b/libs/interprocess/test/dummy_test_allocator.hpp index 56cae66f4..42e5403ef 100644 --- a/libs/interprocess/test/dummy_test_allocator.hpp +++ b/libs/interprocess/test/dummy_test_allocator.hpp @@ -20,15 +20,10 @@ #include <boost/interprocess/interprocess_fwd.hpp> #include <boost/interprocess/containers/allocation_type.hpp> -#include <boost/assert.hpp> #include <boost/interprocess/detail/utilities.hpp> #include <boost/interprocess/containers/version_type.hpp> #include <boost/interprocess/exceptions.hpp> -#include <memory> -#include <algorithm> #include <cstddef> -#include <stdexcept> -#include <cassert> //!\file //!Describes an allocator to test expand capabilities @@ -110,12 +105,9 @@ class dummy_test_allocator //Experimental version 2 dummy_test_allocator functions - std::pair<pointer, bool> - allocation_command(boost::interprocess::allocation_type, - size_type, - size_type, - size_type &, const pointer & = 0) - { return std::pair<pointer, bool>(pointer(0), true); } + pointer allocation_command(boost::interprocess::allocation_type, + size_type, size_type &, pointer &) + { return pointer(); } //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. @@ -126,7 +118,7 @@ class dummy_test_allocator //!must be deallocated only with deallocate_one(). //!Throws boost::interprocess::bad_alloc if there is no enough memory pointer allocate_one() - { return pointer(0); } + { return pointer(); } //!Deallocates memory previously allocated with allocate_one(). //!You should never use deallocate_one to deallocate memory allocated diff --git a/libs/interprocess/test/emplace_test.hpp b/libs/interprocess/test/emplace_test.hpp index f1ce88691..3557c6f17 100644 --- a/libs/interprocess/test/emplace_test.hpp +++ b/libs/interprocess/test/emplace_test.hpp @@ -17,7 +17,7 @@ #include <boost/interprocess/detail/mpl.hpp> #include <boost/move/utility_core.hpp> #include <boost/interprocess/detail/utilities.hpp> -#include <boost/aligned_storage.hpp> +#include <boost/move/detail/type_traits.hpp> //make_unsigned, alignment_of namespace boost{ namespace interprocess{ @@ -142,7 +142,7 @@ bool test_expected_container(const Container &ec, const std::pair<EmplaceInt, Em static EmplaceInt expected [10]; typedef std::pair<EmplaceInt, EmplaceInt> EmplaceIntPair; -static boost::aligned_storage<sizeof(EmplaceIntPair)*10>::type pair_storage; +static boost::container::container_detail::aligned_storage<sizeof(EmplaceIntPair)*10>::type pair_storage; static EmplaceIntPair* initialize_emplace_int_pair() { diff --git a/libs/interprocess/test/enable_shared_from_this_test.cpp b/libs/interprocess/test/enable_shared_from_this_test.cpp index 2b90adc97..342e0a7ed 100644 --- a/libs/interprocess/test/enable_shared_from_this_test.cpp +++ b/libs/interprocess/test/enable_shared_from_this_test.cpp @@ -15,7 +15,7 @@ #include <boost/interprocess/smart_ptr/enable_shared_from_this.hpp> #include <boost/interprocess/smart_ptr/shared_ptr.hpp> -#include <boost/detail/lightweight_test.hpp> +#include <boost/core/lightweight_test.hpp> #include <boost/interprocess/managed_shared_memory.hpp> #include "get_process_id_name.hpp" diff --git a/libs/interprocess/test/expand_bwd_test_allocator.hpp b/libs/interprocess/test/expand_bwd_test_allocator.hpp index 371a31f93..de59ccae8 100644 --- a/libs/interprocess/test/expand_bwd_test_allocator.hpp +++ b/libs/interprocess/test/expand_bwd_test_allocator.hpp @@ -24,11 +24,11 @@ #include <boost/interprocess/detail/utilities.hpp> #include <boost/interprocess/containers/version_type.hpp> #include <boost/interprocess/exceptions.hpp> +#include <boost/move/adl_move_swap.hpp> #include <memory> -#include <algorithm> #include <cstddef> -#include <stdexcept> #include <cassert> +#include <new> //!\file //!Describes an allocator to test expand capabilities @@ -113,38 +113,34 @@ class expand_bwd_test_allocator friend void swap(self_t &alloc1, self_t &alloc2) { - ipcdetail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer); - ipcdetail::do_swap(alloc1.m_size, alloc2.m_size); - ipcdetail::do_swap(alloc1.m_offset, alloc2.m_offset); + ::boost::adl_move_swap(alloc1.mp_buffer, alloc2.mp_buffer); + ::boost::adl_move_swap(alloc1.m_size, alloc2.m_size); + ::boost::adl_move_swap(alloc1.m_offset, alloc2.m_offset); } //Experimental version 2 expand_bwd_test_allocator functions - std::pair<pointer, bool> - allocation_command(boost::interprocess::allocation_type command, - size_type limit_size, - size_type preferred_size, - size_type &received_size, const pointer &reuse = 0) + pointer allocation_command(boost::interprocess::allocation_type command, + size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse) { - (void)preferred_size; (void)reuse; (void)command; + (void)reuse; (void)command; //This allocator only expands backwards! assert(m_allocations == 0 || (command & boost::interprocess::expand_bwd)); - - received_size = limit_size; + prefer_in_recvd_out_size = limit_size; if(m_allocations == 0){ if((m_offset + limit_size) > m_size){ assert(0); } ++m_allocations; - return std::pair<pointer, bool>(mp_buffer + m_offset, false); + return mp_buffer + m_offset; } else if(m_allocations == 1){ if(limit_size > m_size){ assert(0); } ++m_allocations; - return std::pair<pointer, bool>(mp_buffer, true); + return mp_buffer; } else{ assert(0); diff --git a/libs/interprocess/test/expand_bwd_test_template.hpp b/libs/interprocess/test/expand_bwd_test_template.hpp index 25c70c9ab..91d1146b9 100644 --- a/libs/interprocess/test/expand_bwd_test_template.hpp +++ b/libs/interprocess/test/expand_bwd_test_template.hpp @@ -12,10 +12,11 @@ #define BOOST_INTERPROCESS_TEST_ALLOCATION_TEST_TEMPLATE_HEADER #include <boost/interprocess/detail/config_begin.hpp> -#include <vector> #include "expand_bwd_test_allocator.hpp" -#include <algorithm> -#include <boost/type_traits/remove_volatile.hpp> +#include <boost/interprocess/detail/type_traits.hpp> +#include <algorithm> //std::equal +#include <vector> +#include <iostream> namespace boost { namespace interprocess { namespace test { @@ -108,7 +109,7 @@ template<class VectorWithExpandBwdAllocator> bool test_insert_with_expand_bwd() { typedef typename VectorWithExpandBwdAllocator::value_type value_type; - typedef typename boost::remove_volatile<value_type>::type non_volatile_value_type; + typedef typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type non_volatile_value_type; typedef std::vector<non_volatile_value_type> Vect; const int MemorySize = 1000; @@ -180,7 +181,7 @@ template<class VectorWithExpandBwdAllocator> bool test_assign_with_expand_bwd() { typedef typename VectorWithExpandBwdAllocator::value_type value_type; - typedef typename boost::remove_volatile<value_type>::type non_volatile_value_type; + typedef typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type non_volatile_value_type; const int MemorySize = 200; const int Offset[] = { 50, 50, 50}; @@ -226,10 +227,10 @@ bool test_assign_with_expand_bwd() } } catch(...){ - delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory)); + delete [](const_cast<typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type*>(memory)); throw; } - delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory)); + delete [](const_cast<typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type*>(memory)); } return true; diff --git a/libs/interprocess/test/heap_allocator_v1.hpp b/libs/interprocess/test/heap_allocator_v1.hpp index 58f604a98..2867f8da6 100644 --- a/libs/interprocess/test/heap_allocator_v1.hpp +++ b/libs/interprocess/test/heap_allocator_v1.hpp @@ -25,10 +25,7 @@ #include <boost/interprocess/detail/utilities.hpp> #include <boost/interprocess/containers/version_type.hpp> #include <boost/interprocess/exceptions.hpp> -#include <memory> -#include <algorithm> -#include <cstddef> -#include <stdexcept> +#include <boost/move/adl_move_swap.hpp> //!\file //!Describes an heap_allocator_v1 that allocates portions of fixed size @@ -141,7 +138,7 @@ class heap_allocator_v1 //!Swap segment manager. Does not throw. If each heap_allocator_v1 is placed in //!different memory segments, the result is undefined. friend void swap(self_t &alloc1, self_t &alloc2) - { ipcdetail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } + { ::boost::adl_move_swap(alloc1.mp_mngr, alloc2.mp_mngr); } }; //!Equality test for same type of heap_allocator_v1 diff --git a/libs/interprocess/test/intersegment_ptr_test.cpp b/libs/interprocess/test/intersegment_ptr_test.cpp deleted file mode 100644 index cacdbbd37..000000000 --- a/libs/interprocess/test/intersegment_ptr_test.cpp +++ /dev/null @@ -1,401 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/interprocess for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include <boost/interprocess/detail/config_begin.hpp> -#include <boost/interprocess/detail/intersegment_ptr.hpp> -#include <boost/interprocess/detail/type_traits.hpp> -#include <boost/interprocess/mapped_region.hpp> //mapped_region -#include <boost/interprocess/anonymous_shared_memory.hpp> //anonymous_shared_memory -#include <boost/interprocess/detail/managed_multi_shared_memory.hpp> //managed_multi_shared_memory -#include <boost/static_assert.hpp> //static_assert -#include <cstddef> //std::size_t - - -using namespace boost::interprocess; - -bool test_types_and_convertions() -{ - typedef intersegment_ptr<int> pint_t; - typedef intersegment_ptr<const int> pcint_t; - typedef intersegment_ptr<volatile int> pvint_t; - typedef intersegment_ptr<const volatile int> pcvint_t; - - BOOST_STATIC_ASSERT((ipcdetail::is_same<pint_t::value_type, int>::value)); - BOOST_STATIC_ASSERT((ipcdetail::is_same<pcint_t::value_type, const int>::value)); - BOOST_STATIC_ASSERT((ipcdetail::is_same<pvint_t::value_type, volatile int>::value)); - BOOST_STATIC_ASSERT((ipcdetail::is_same<pcvint_t::value_type, const volatile int>::value)); - int dummy_int = 9; - - { pint_t pint(&dummy_int); pcint_t pcint(pint); - if(pcint.get() != &dummy_int) return false; } - { pint_t pint(&dummy_int); pvint_t pvint(pint); - if(pvint.get() != &dummy_int) return false; } - { pint_t pint(&dummy_int); pcvint_t pcvint(pint); - if(pcvint.get() != &dummy_int) return false; } - { pcint_t pcint(&dummy_int); pcvint_t pcvint(pcint); - if(pcvint.get() != &dummy_int) return false; } - { pvint_t pvint(&dummy_int); pcvint_t pcvint(pvint); - if(pcvint.get() != &dummy_int) return false; } - - pint_t pint(0); - pcint_t pcint(0); - pvint_t pvint(0); - pcvint_t pcvint(0); - - pint = &dummy_int; - pcint = &dummy_int; - pvint = &dummy_int; - pcvint = &dummy_int; - - { pcint = pint; if(pcint.get() != &dummy_int) return false; } - { pvint = pint; if(pvint.get() != &dummy_int) return false; } - { pcvint = pint; if(pcvint.get() != &dummy_int) return false; } - { pcvint = pcint; if(pcvint.get() != &dummy_int) return false; } - { pcvint = pvint; if(pcvint.get() != &dummy_int) return false; } - - if(!pint) - return false; - - pint = 0; - if(pint) - return false; - - return true; -} - -bool test_arithmetic() -{ - typedef intersegment_ptr<int> pint_t; - const int NumValues = 5; - int values[NumValues]; - - //Initialize p - pint_t p = values; - if(p.get() != values) - return false; - - //Initialize p + NumValues - pint_t pe = &values[NumValues]; - if(pe == p) - return false; - if(pe.get() != &values[NumValues]) - return false; - - //ptr - ptr - if((pe - p) != NumValues) - return false; - //ptr - integer - if((pe - NumValues) != p) - return false; - //ptr + integer - if((p + NumValues) != pe) - return false; - //integer + ptr - if((NumValues + p) != pe) - return false; - //indexing - if(pint_t(&p[NumValues]) != pe) - return false; - if(pint_t(&pe[-NumValues]) != p) - return false; - - //ptr -= integer - pint_t p0 = pe; - p0-= NumValues; - if(p != p0) - return false; - //ptr += integer - pint_t penew = p0; - penew += NumValues; - if(penew != pe) - return false; - - //++ptr - penew = p0; - for(int j = 0; j != NumValues; ++j, ++penew); - if(penew != pe) - return false; - //--ptr - p0 = pe; - for(int j = 0; j != NumValues; ++j, --p0); - if(p != p0) - return false; - //ptr++ - penew = p0; - for(int j = 0; j != NumValues; ++j){ - pint_t pnew_copy = penew; - if(pnew_copy != penew++) - return false; - } - //ptr-- - p0 = pe; - for(int j = 0; j != NumValues; ++j){ - pint_t p0_copy = p0; - if(p0_copy != p0--) - return false; - } - - return true; -} - -bool test_comparison() -{ - typedef intersegment_ptr<int> pint_t; - const int NumValues = 5; - int values[NumValues]; - - //Initialize p - pint_t p = values; - if(p.get() != values) - return false; - - //Initialize p + NumValues - pint_t pe = &values[NumValues]; - if(pe == p) - return false; - if(pe.get() != &values[NumValues]) - return false; - - //operators - if(p == pe) - return false; - if(p != p) - return false; - if(!(p < pe)) - return false; - if(!(p <= pe)) - return false; - if(!(pe > p)) - return false; - if(!(pe >= p)) - return false; - - return true; -} - -struct segment_data -{ - int int0; - int int1; - intersegment_ptr<int> ptr0; - int int2; - int int3; -}; - -bool test_basic_comparisons() -{ - //Create aligned sections - const std::size_t PageSize = mapped_region::get_page_size(); - mapped_region reg_0_0(anonymous_shared_memory(PageSize)); - mapped_region reg_0_1(anonymous_shared_memory(PageSize)); - mapped_region reg_1_0(anonymous_shared_memory(PageSize)); - mapped_region reg_1_1(anonymous_shared_memory(PageSize)); - - if(sizeof(segment_data) > mapped_region::get_page_size()) - return false; - - segment_data &seg_0_0 = *static_cast<segment_data *>(reg_0_0.get_address()); - segment_data &seg_0_1 = *static_cast<segment_data *>(reg_0_1.get_address()); - segment_data &seg_1_0 = *static_cast<segment_data *>(reg_1_0.get_address()); - segment_data &seg_1_1 = *static_cast<segment_data *>(reg_1_1.get_address()); - - //Some dummy multi_segment_services - multi_segment_services *services0 = static_cast<multi_segment_services *>(0); - multi_segment_services *services1 = reinterpret_cast<multi_segment_services *>(1); - - const intersegment_ptr<int>::segment_group_id group_0_id = - intersegment_ptr<int>::new_segment_group(services0); - const intersegment_ptr<int>::segment_group_id group_1_id = - intersegment_ptr<int>::new_segment_group(services1); - - { - - //Now register the segments in the segment data-base - intersegment_ptr<int>::insert_mapping(group_0_id, &seg_0_0, PageSize); - intersegment_ptr<int>::insert_mapping(group_0_id, &seg_0_1, PageSize); - intersegment_ptr<int>::insert_mapping(group_1_id, &seg_1_0, PageSize); - intersegment_ptr<int>::insert_mapping(group_1_id, &seg_1_1, PageSize); - } - - //Now do some testing... - { - //Same segment - seg_0_0.ptr0 = &seg_0_0.int0; - seg_0_1.ptr0 = &seg_0_1.int0; - - if(seg_0_0.ptr0.get() != &seg_0_0.int0) - return false; - if(seg_0_1.ptr0.get() != &seg_0_1.int0) - return false; - - //Try it again to make use of the already established relative addressing - seg_0_0.ptr0 = &seg_0_0.int1; - seg_0_1.ptr0 = &seg_0_1.int1; - - if(seg_0_0.ptr0.get() != &seg_0_0.int1) - return false; - if(seg_0_1.ptr0.get() != &seg_0_1.int1) - return false; - - //Set to null and try again - seg_0_0.ptr0 = 0; - seg_0_1.ptr0 = 0; - - seg_0_0.ptr0 = &seg_0_0.int1; - seg_0_1.ptr0 = &seg_0_1.int1; - - if(seg_0_0.ptr0.get() != &seg_0_0.int1) - return false; - if(seg_0_1.ptr0.get() != &seg_0_1.int1) - return false; - - //Set to null and try again - int stack_int; - seg_0_0.ptr0 = &stack_int; - seg_0_1.ptr0 = &stack_int; - - if(seg_0_0.ptr0.get() != &stack_int) - return false; - if(seg_0_1.ptr0.get() != &stack_int) - return false; - } - - { - //Now use stack variables - intersegment_ptr<int> stack_0 = &seg_0_0.int2; - intersegment_ptr<int> stack_1 = &seg_1_1.int2; - - if(stack_0.get() != &seg_0_0.int2) - return false; - if(stack_1.get() != &seg_1_1.int2) - return false; - - //Now reuse stack variables knowing that there are on stack - stack_0 = &seg_0_0.int3; - stack_1 = &seg_1_1.int3; - - if(stack_0.get() != &seg_0_0.int3) - return false; - if(stack_1.get() != &seg_1_1.int3) - return false; - - //Now set to null and try it again - stack_0 = 0; - stack_1 = 0; - - stack_0 = &seg_0_0.int3; - stack_1 = &seg_1_1.int3; - - if(stack_0.get() != &seg_0_0.int3) - return false; - if(stack_1.get() != &seg_1_1.int3) - return false; - } - { - //Different segments in the same group - seg_0_0.ptr0 = &seg_0_1.int0; - seg_0_1.ptr0 = &seg_0_0.int0; - - if(seg_0_0.ptr0.get() != &seg_0_1.int0) - return false; - if(seg_0_1.ptr0.get() != &seg_0_0.int0) - return false; - - //Try it again to make use of the already established segmented addressing - seg_0_0.ptr0 = &seg_0_1.int1; - seg_0_1.ptr0 = &seg_0_0.int1; - - if(seg_0_0.ptr0.get() != &seg_0_1.int1) - return false; - if(seg_0_1.ptr0.get() != &seg_0_0.int1) - return false; - - //Set to null and try it again - seg_0_0.ptr0 = 0; - seg_0_1.ptr0 = 0; - - seg_0_0.ptr0 = &seg_0_1.int1; - seg_0_1.ptr0 = &seg_0_0.int1; - - if(seg_0_0.ptr0.get() != &seg_0_1.int1) - return false; - if(seg_0_1.ptr0.get() != &seg_0_0.int1) - return false; - } - - { - //Different groups - seg_0_0.ptr0 = &seg_1_0.int0; - seg_0_1.ptr0 = &seg_1_1.int0; - - if(seg_0_0.ptr0.get() != &seg_1_0.int0) - return false; - if(seg_0_1.ptr0.get() != &seg_1_1.int0) - return false; - - //Try it again - seg_0_0.ptr0 = &seg_1_0.int1; - seg_0_1.ptr0 = &seg_1_1.int1; - - if(seg_0_0.ptr0.get() != &seg_1_0.int1) - return false; - if(seg_0_1.ptr0.get() != &seg_1_1.int1) - return false; - - //Set null and try it again - seg_0_0.ptr0 = 0; - seg_0_1.ptr0 = 0; - - seg_0_0.ptr0 = &seg_1_0.int1; - seg_0_1.ptr0 = &seg_1_1.int1; - - if(seg_0_0.ptr0.get() != &seg_1_0.int1) - return false; - if(seg_0_1.ptr0.get() != &seg_1_1.int1) - return false; - } - - { - //Erase mappings - intersegment_ptr<int>::delete_group(group_0_id); - intersegment_ptr<int>::delete_group(group_1_id); - } - return true; -} - -bool test_multi_segment_shared_memory() -{ - { - shared_memory_object::remove("kk0"); - managed_multi_shared_memory mshm(create_only, "kk", 4096); - } - - shared_memory_object::remove("kk0"); - return true; -} - -int main() -{/* - if(!test_types_and_convertions()) - return 1; - if(!test_arithmetic()) - return 1; - if(!test_comparison()) - return 1; - if(!test_basic_comparisons()) - return 1; - - if(!test_multi_segment_shared_memory()) - return 1; -*/ - return 0; -} - -#include <boost/interprocess/detail/config_end.hpp> diff --git a/libs/interprocess/test/intrusive_ptr_test.cpp b/libs/interprocess/test/intrusive_ptr_test.cpp index d3fb0a1cf..d5293a3ad 100644 --- a/libs/interprocess/test/intrusive_ptr_test.cpp +++ b/libs/interprocess/test/intrusive_ptr_test.cpp @@ -14,9 +14,9 @@ #include <boost/interprocess/smart_ptr/intrusive_ptr.hpp> #include <boost/interprocess/managed_shared_memory.hpp> -#include <boost/detail/lightweight_test.hpp> +#include <boost/core/lightweight_test.hpp> #include <boost/config.hpp> -#include <algorithm> +#include <boost/move/adl_move_swap.hpp> #include <functional> typedef boost::interprocess::offset_ptr<void> VP; @@ -283,8 +283,7 @@ void test() BOOST_TEST(px.get() == 0); BOOST_TEST(px2.get() == 0); - using std::swap; - swap(px, px2); + ::boost::adl_move_swap(px, px2); BOOST_TEST(px.get() == 0); BOOST_TEST(px2.get() == 0); @@ -304,8 +303,7 @@ void test() BOOST_TEST(px3.get() == p); BOOST_TEST(px3->use_count() == 2); - using std::swap; - swap(px, px2); + ::boost::adl_move_swap(px, px2); BOOST_TEST(px.get() == 0); BOOST_TEST(px2.get() == p); @@ -330,8 +328,7 @@ void test() BOOST_TEST(px3.get() == p2); BOOST_TEST(px3->use_count() == 2); - using std::swap; - swap(px, px2); + ::boost::adl_move_swap(px, px2); BOOST_TEST(px.get() == p1); BOOST_TEST(px->use_count() == 1); diff --git a/libs/interprocess/test/managed_mapped_file_test.cpp b/libs/interprocess/test/managed_mapped_file_test.cpp index 90f0f0034..1b8375987 100644 --- a/libs/interprocess/test/managed_mapped_file_test.cpp +++ b/libs/interprocess/test/managed_mapped_file_test.cpp @@ -8,6 +8,8 @@ // ////////////////////////////////////////////////////////////////////////////// +#if defined(BOOST_INTERPROCESS_MAPPED_FILES) + #include <boost/interprocess/detail/config_begin.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/containers/vector.hpp> @@ -224,3 +226,12 @@ int main () } #include <boost/interprocess/detail/config_end.hpp> + +#else //#if defined(BOOST_INTERPROCESS_MAPPED_FILES) + +int main() +{ + return 0; +} + +#endif//#if defined(BOOST_INTERPROCESS_MAPPED_FILES) diff --git a/libs/interprocess/test/map_test.hpp b/libs/interprocess/test/map_test.hpp index d1166677a..dd77670de 100644 --- a/libs/interprocess/test/map_test.hpp +++ b/libs/interprocess/test/map_test.hpp @@ -14,12 +14,18 @@ #include <boost/interprocess/detail/config_begin.hpp> #include "check_equal_containers.hpp" #include <map> -#include <functional> -#include <utility> -#include "print_container.hpp" -#include <boost/interprocess/detail/utilities.hpp> + +// interprocess #include <boost/interprocess/containers/pair.hpp> +// interprocess/detail +#include <boost/interprocess/detail/utilities.hpp> +// intrusive/detail +#include <boost/intrusive/detail/minimal_pair_header.hpp> +#include <boost/intrusive/detail/minimal_less_equal_header.hpp> +// std #include <string> + +#include "print_container.hpp" #include "get_process_id_name.hpp" template<class T1, class T2, class T3, class T4> diff --git a/libs/interprocess/test/mapped_file_test.cpp b/libs/interprocess/test/mapped_file_test.cpp index ed3257a12..9d19977aa 100644 --- a/libs/interprocess/test/mapped_file_test.cpp +++ b/libs/interprocess/test/mapped_file_test.cpp @@ -7,6 +7,7 @@ // See http://www.boost.org/libs/interprocess for documentation. // ////////////////////////////////////////////////////////////////////////////// +#if defined(BOOST_INTERPROCESS_MAPPED_FILES) #include <boost/interprocess/detail/config_begin.hpp> #include <boost/interprocess/allocators/allocator.hpp> @@ -88,3 +89,12 @@ int main () } #include <boost/interprocess/detail/config_end.hpp> + +#else //#if !defined(BOOST_INTERPROCESS_MAPPED_FILES) + +int main() +{ + return 0; +} + +#endif//#if !defined(BOOST_INTERPROCESS_MAPPED_FILES) diff --git a/libs/interprocess/test/memory_algorithm_test.cpp b/libs/interprocess/test/memory_algorithm_test.cpp index f893540bd..4e3c6e4d6 100644 --- a/libs/interprocess/test/memory_algorithm_test.cpp +++ b/libs/interprocess/test/memory_algorithm_test.cpp @@ -15,7 +15,7 @@ #include <boost/interprocess/indexes/null_index.hpp> #include <boost/interprocess/sync/mutex_family.hpp> #include <boost/interprocess/detail/type_traits.hpp> -#include <boost/type_traits/alignment_of.hpp> +#include <boost/move/detail/type_traits.hpp> //make_unsigned, alignment_of #include "memory_algorithm_test_template.hpp" #include <iostream> #include <string> @@ -69,7 +69,7 @@ int test_rbtree_best_fit() int main () { - const std::size_t void_ptr_align = ::boost::alignment_of<offset_ptr<void> >::value; + const std::size_t void_ptr_align = ::boost::container::container_detail::alignment_of<offset_ptr<void> >::value; if(test_simple_seq_fit()){ return 1; diff --git a/libs/interprocess/test/memory_algorithm_test_template.hpp b/libs/interprocess/test/memory_algorithm_test_template.hpp index 1a861a71e..10e880e7f 100644 --- a/libs/interprocess/test/memory_algorithm_test_template.hpp +++ b/libs/interprocess/test/memory_algorithm_test_template.hpp @@ -12,12 +12,13 @@ #define BOOST_INTERPROCESS_TEST_MEMORY_ALGORITHM_TEST_TEMPLATE_HEADER #include <boost/interprocess/detail/config_begin.hpp> + +#include <boost/interprocess/containers/vector.hpp> + #include <vector> #include <iostream> -#include <new> -#include <utility> +#include <new> //std::nothrow #include <cstring> //std::memset -#include <boost/interprocess/containers/vector.hpp> namespace boost { namespace interprocess { namespace test { @@ -32,7 +33,7 @@ bool test_allocation(Allocator &a) ; t != EndDeallocationType ; t = (deallocation_type)((int)t + 1)){ std::vector<void*> buffers; - typename Allocator::size_type free_memory = a.get_free_memory(); + typename Allocator::size_type free_memory = a.get_free_memory(); for(int i = 0; true; ++i){ void *ptr = a.allocate(i, std::nothrow); @@ -106,9 +107,10 @@ bool test_allocation_shrink(Allocator &a) ;i < max ; ++i){ typename Allocator::size_type received_size; + char *reuse = static_cast<char*>(buffers[i]); if(a.template allocation_command<char> ( boost::interprocess::shrink_in_place | boost::interprocess::nothrow_allocation, i*2 - , i, received_size, static_cast<char*>(buffers[i])).first){ + , received_size = i, reuse)){ if(received_size > std::size_t(i*2)){ return false; } @@ -158,9 +160,10 @@ bool test_allocation_expand(Allocator &a) std::size_t preferred_size = i*2; preferred_size = min_size > preferred_size ? min_size : preferred_size; + char *reuse = static_cast<char*>(buffers[i]); while(a.template allocation_command<char> ( boost::interprocess::expand_fwd | boost::interprocess::nothrow_allocation, min_size - , preferred_size, received_size, static_cast<char*>(buffers[i])).first){ + , received_size = preferred_size, reuse)){ //Check received size is bigger than minimum if(received_size < min_size){ return false; @@ -196,11 +199,12 @@ bool test_allocation_shrink_and_expand(Allocator &a) //Allocate buffers wand store received sizes for(int i = 0; true; ++i){ typename Allocator::size_type received_size; + char *reuse = 0; void *ptr = a.template allocation_command<char> - ( boost::interprocess::allocate_new | boost::interprocess::nothrow_allocation, i, i*2, received_size).first; + ( boost::interprocess::allocate_new | boost::interprocess::nothrow_allocation, i, received_size = i*2, reuse); if(!ptr){ ptr = a.template allocation_command<char> - ( boost::interprocess::allocate_new | boost::interprocess::nothrow_allocation, 1, i*2, received_size).first; + ( boost::interprocess::allocate_new | boost::interprocess::nothrow_allocation, 1, received_size = i*2, reuse); if(!ptr) break; } @@ -213,9 +217,10 @@ bool test_allocation_shrink_and_expand(Allocator &a) ; i < max ; ++i){ typename Allocator::size_type received_size; + char *reuse = static_cast<char*>(buffers[i]); if(a.template allocation_command<char> ( boost::interprocess::shrink_in_place | boost::interprocess::nothrow_allocation, received_sizes[i] - , i, received_size, static_cast<char*>(buffers[i])).first){ + , received_size = i, reuse)){ if(received_size > std::size_t(received_sizes[i])){ return false; } @@ -232,9 +237,10 @@ bool test_allocation_shrink_and_expand(Allocator &a) ;++i){ typename Allocator::size_type received_size; std::size_t request_size = received_sizes[i]; + char *reuse = static_cast<char*>(buffers[i]); if(a.template allocation_command<char> ( boost::interprocess::expand_fwd | boost::interprocess::nothrow_allocation, request_size - , request_size, received_size, static_cast<char*>(buffers[i])).first){ + , received_size = request_size, reuse)){ if(received_size != received_sizes[i]){ return false; } @@ -297,9 +303,10 @@ bool test_allocation_deallocation_expand(Allocator &a) std::size_t preferred_size = i*2; preferred_size = min_size > preferred_size ? min_size : preferred_size; + char *reuse = static_cast<char*>(buffers[i]); while(a.template allocation_command<char> ( boost::interprocess::expand_fwd | boost::interprocess::nothrow_allocation, min_size - , preferred_size, received_size, static_cast<char*>(buffers[i])).first){ + , received_size = preferred_size, reuse)){ //Check received size is bigger than minimum if(received_size < min_size){ return false; @@ -367,17 +374,18 @@ bool test_allocation_with_reuse(Allocator &a) for(int i = 0; true; ++i){ std::size_t min_size = (received_size + 1); std::size_t prf_size = (received_size + (i+1)*2); - std::pair<void*, bool> ret = a.raw_allocation_command + void *reuse = ptr; + void *ret = a.raw_allocation_command ( boost::interprocess::expand_bwd | boost::interprocess::nothrow_allocation, min_size - , prf_size, received_size, static_cast<char*>(ptr), sizeof_object); - if(!ret.first) + , received_size = prf_size, reuse, sizeof_object); + if(!ret) break; //If we have memory, this must be a buffer reuse - if(!ret.second) + if(!reuse) return 1; if(received_size < min_size) return 1; - ptr = ret.first; + ptr = ret; } //There is only a single block so deallocate it a.deallocate(ptr); diff --git a/libs/interprocess/test/message_queue_test.cpp b/libs/interprocess/test/message_queue_test.cpp index afb23016b..c4a9233e1 100644 --- a/libs/interprocess/test/message_queue_test.cpp +++ b/libs/interprocess/test/message_queue_test.cpp @@ -16,12 +16,17 @@ #include <boost/interprocess/containers/set.hpp> #include <boost/interprocess/allocators/node_allocator.hpp> #include <boost/interprocess/detail/os_thread_functions.hpp> -#include <vector> -#include <iostream> +// intrusive/detail +#include <boost/intrusive/detail/minimal_pair_header.hpp> +#include <boost/intrusive/detail/minimal_less_equal_header.hpp> + #include <cstddef> -#include <limits> #include <memory> -#include <string> +#include <iostream> +#include <vector> +#include <stdexcept> +#include <limits> + #include "get_process_id_name.hpp" //////////////////////////////////////////////////////////////////////////////// diff --git a/libs/interprocess/test/named_allocation_test_template.hpp b/libs/interprocess/test/named_allocation_test_template.hpp index b3f15077f..ca796349f 100644 --- a/libs/interprocess/test/named_allocation_test_template.hpp +++ b/libs/interprocess/test/named_allocation_test_template.hpp @@ -12,18 +12,23 @@ #define BOOST_INTERPROCESS_NAMED_ALLOCATION_TEST_TEMPLATE_HEADER #include <boost/interprocess/detail/config_begin.hpp> + +// interprocess #include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/mem_algo/rbtree_best_fit.hpp> -#include <boost/interprocess/sync/mutex_family.hpp> #include <boost/interprocess/streams/bufferstream.hpp> -#include <vector> -#include <iostream> +#include <boost/interprocess/sync/mutex_family.hpp> +// container +#include <boost/container/detail/iterator.hpp> +#include <boost/container/detail/minimal_char_traits_header.hpp> //char_traits +// std #include <cstdio> +#include <iostream> #include <new> -#include <utility> -#include <iterator> #include <set> -#include <string> +#include <vector> + +// local #include "get_process_id_name.hpp" namespace boost { namespace interprocess { namespace test { @@ -128,7 +133,7 @@ bool test_named_iterators(ManagedMemory &m) const_named_iterator named_beg = m.named_begin(); const_named_iterator named_end = m.named_end(); - if((std::size_t)std::distance(named_beg, named_end) != (std::size_t)buffers.size()){ + if((std::size_t)boost::container::iterator_distance(named_beg, named_end) != (std::size_t)buffers.size()){ return 1; } @@ -488,4 +493,3 @@ bool test_named_allocation() #include <boost/interprocess/detail/config_end.hpp> #endif //BOOST_INTERPROCESS_NAMED_ALLOCATION_TEST_TEMPLATE_HEADER - diff --git a/libs/interprocess/test/named_construct_test.cpp b/libs/interprocess/test/named_construct_test.cpp index acdd9b7bd..834a993f5 100644 --- a/libs/interprocess/test/named_construct_test.cpp +++ b/libs/interprocess/test/named_construct_test.cpp @@ -10,7 +10,8 @@ #include <boost/interprocess/detail/config_begin.hpp> #include <boost/interprocess/detail/workaround.hpp> #include <boost/interprocess/managed_shared_memory.hpp> -#include <utility> +// intrusive/detail +#include <boost/intrusive/detail/minimal_pair_header.hpp> typedef std::pair<double, int> simple_pair; diff --git a/libs/interprocess/test/print_container.hpp b/libs/interprocess/test/print_container.hpp index eefc6baeb..b045bb42e 100644 --- a/libs/interprocess/test/print_container.hpp +++ b/libs/interprocess/test/print_container.hpp @@ -12,33 +12,25 @@ #define BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP #include <boost/interprocess/detail/config_begin.hpp> -#include <functional> #include <iostream> -#include <algorithm> namespace boost{ namespace interprocess{ namespace test{ -struct PrintValues : public std::unary_function<int, void> -{ - void operator() (int value) const - { - std::cout << value << " "; - } -}; - template<class Container> void PrintContents(const Container &cont, const char *contName) { std::cout<< "Printing contents of " << contName << std::endl; - std::for_each(cont.begin(), cont.end(), PrintValues()); + typename Container::iterator b(cont.begin()), e(cont.end()); + for(; b != e; ++b){ + std::cout << *b << " "; + } std::cout<< std::endl << std::endl; } //Function to dump data -template<class MyShmCont - ,class MyStdCont> +template<class MyShmCont, class MyStdCont> void PrintContainers(MyShmCont *shmcont, MyStdCont *stdcont) { typename MyShmCont::iterator itshm = shmcont->begin(), itshmend = shmcont->end(); diff --git a/libs/interprocess/test/segment_manager_test.cpp b/libs/interprocess/test/segment_manager_test.cpp index bc4663899..1b42c8c5f 100644 --- a/libs/interprocess/test/segment_manager_test.cpp +++ b/libs/interprocess/test/segment_manager_test.cpp @@ -33,6 +33,9 @@ struct atomic_func_test { object = rsm.template find<int>("atomic_func_find_object").first; } + private: + atomic_func_test operator=(const atomic_func_test&); + atomic_func_test(const atomic_func_test&); }; template <class SegmentManager> @@ -213,7 +216,7 @@ bool test_segment_manager() const char *const object2_name = "object2"; int const int_array_values[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - for(std::size_t i = 0; i != 4; ++i){ + for(std::size_t i = 0; i != 1/*4*/; ++i){ if(seg_mgr->template find<unsigned int>(object1_name).first) return false; //Single element construction diff --git a/libs/interprocess/test/set_test.hpp b/libs/interprocess/test/set_test.hpp index 4fecfc05b..1d49061c4 100644 --- a/libs/interprocess/test/set_test.hpp +++ b/libs/interprocess/test/set_test.hpp @@ -13,14 +13,12 @@ #include <boost/interprocess/detail/config_begin.hpp> #include "check_equal_containers.hpp" -#include <memory> -#include <set> -#include <functional> #include "print_container.hpp" #include <boost/move/utility_core.hpp> -#include <string> #include "get_process_id_name.hpp" +#include <functional> + namespace boost{ namespace interprocess{ namespace test{ diff --git a/libs/interprocess/test/shared_ptr_test.cpp b/libs/interprocess/test/shared_ptr_test.cpp index 3e9c61a9e..5bdfd93cd 100644 --- a/libs/interprocess/test/shared_ptr_test.cpp +++ b/libs/interprocess/test/shared_ptr_test.cpp @@ -21,7 +21,7 @@ #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/smart_ptr/deleter.hpp> #include <boost/interprocess/smart_ptr/scoped_ptr.hpp> -#include <boost/detail/lightweight_test.hpp> +#include <boost/core/lightweight_test.hpp> #include <string> #include "get_process_id_name.hpp" diff --git a/libs/interprocess/test/stable_vector_test.cpp b/libs/interprocess/test/stable_vector_test.cpp index cb2a1bbc6..b341bc0a0 100644 --- a/libs/interprocess/test/stable_vector_test.cpp +++ b/libs/interprocess/test/stable_vector_test.cpp @@ -9,12 +9,6 @@ ////////////////////////////////////////////////////////////////////////////// #include <boost/interprocess/detail/config_begin.hpp> -#include <algorithm> -#include <memory> -#include <vector> -#include <iostream> -#include <functional> - #include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/containers/stable_vector.hpp> #include <boost/interprocess/allocators/allocator.hpp> diff --git a/libs/interprocess/test/string_test.cpp b/libs/interprocess/test/string_test.cpp index 9cc8e7c6c..15399be83 100644 --- a/libs/interprocess/test/string_test.cpp +++ b/libs/interprocess/test/string_test.cpp @@ -15,18 +15,17 @@ #include <boost/interprocess/containers/string.hpp> #include <boost/interprocess/offset_ptr.hpp> #include <string> -#include <vector> #include <algorithm> #include <cstring> #include <cstdio> #include <cstddef> -#include <new> #include "dummy_test_allocator.hpp" #include "check_equal_containers.hpp" #include "expand_bwd_test_allocator.hpp" #include "expand_bwd_test_template.hpp" #include "allocator_v1.hpp" #include "get_process_id_name.hpp" +#include <new> //std::nothrow using namespace boost::interprocess; diff --git a/libs/interprocess/test/user_buffer_test.cpp b/libs/interprocess/test/user_buffer_test.cpp index 9299d0b8f..8adfcc9c5 100644 --- a/libs/interprocess/test/user_buffer_test.cpp +++ b/libs/interprocess/test/user_buffer_test.cpp @@ -18,8 +18,8 @@ #include <boost/interprocess/managed_heap_memory.hpp> #include <boost/interprocess/containers/list.hpp> #include <boost/interprocess/detail/type_traits.hpp> +#include <boost/move/detail/type_traits.hpp> #include <boost/interprocess/allocators/node_allocator.hpp> -#include <boost/type_traits/type_with_alignment.hpp> #include "print_container.hpp" /******************************************************************************/ @@ -53,9 +53,9 @@ bool CheckEqual(MyUserList *userlist, MyStdList *stdlist, MyHeapList *heaplist) int main () { //Create the user memory who will store all objects - const int size_aligner = sizeof(::boost::detail::max_align); + const int size_aligner = sizeof(::boost::container::container_detail::max_align_t); const int memsize = 65536/size_aligner*size_aligner; - static ::boost::detail::max_align static_buffer[memsize/size_aligner]; + static ::boost::container::container_detail::max_align_t static_buffer[memsize/size_aligner]; { //Now test move semantics diff --git a/libs/interprocess/test/util.hpp b/libs/interprocess/test/util.hpp index 84203ab17..c4e8229f2 100644 --- a/libs/interprocess/test/util.hpp +++ b/libs/interprocess/test/util.hpp @@ -26,8 +26,6 @@ #include <boost/interprocess/detail/os_thread_functions.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> -#include <algorithm> -#include <iostream> #include <boost/version.hpp> namespace boost { diff --git a/libs/interprocess/test/vector_test.cpp b/libs/interprocess/test/vector_test.cpp index ed3aed521..6a3931c24 100644 --- a/libs/interprocess/test/vector_test.cpp +++ b/libs/interprocess/test/vector_test.cpp @@ -9,12 +9,6 @@ ////////////////////////////////////////////////////////////////////////////// #include <boost/interprocess/detail/config_begin.hpp> -#include <algorithm> -#include <memory> -#include <vector> -#include <iostream> -#include <functional> - #include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/allocators/allocator.hpp> diff --git a/libs/interprocess/test/vector_test.hpp b/libs/interprocess/test/vector_test.hpp index 1bddbb5a8..4875b3361 100644 --- a/libs/interprocess/test/vector_test.hpp +++ b/libs/interprocess/test/vector_test.hpp @@ -12,12 +12,6 @@ #define BOOST_INTERPROCESS_TEST_VECTOR_TEST_HEADER #include <boost/interprocess/detail/config_begin.hpp> -#include <algorithm> -#include <memory> -#include <vector> -#include <iostream> -#include <functional> -#include <list> #include <boost/interprocess/exceptions.hpp> #include <boost/move/utility_core.hpp> @@ -25,11 +19,17 @@ #include "print_container.hpp" #include "check_equal_containers.hpp" #include "movable_int.hpp" -#include <string> -#include <vector> + #include "get_process_id_name.hpp" #include "emplace_test.hpp" +#include <vector> +#include <list> +#include <string> +#include <iostream> +#include <cstddef> + + namespace boost{ namespace interprocess{ namespace test{ |
