From fd4dd29f602c1365f8fb0102eaf57b89e93f251f Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 2 Apr 2016 00:01:39 +0300 Subject: [PATCH] Migrated SplitListMap unit test to gtest framework --- projects/Win/vc14/gtest-map.vcxproj | 78 ++++++ projects/Win/vc14/gtest-map.vcxproj.filters | 45 ++++ test/unit/map/CMakeLists.txt | 13 + test/unit/map/split_lazy_dhp.cpp | 235 +++++++++++++++++ test/unit/map/split_lazy_hp.cpp | 236 +++++++++++++++++ test/unit/map/split_lazy_nogc.cpp | 220 ++++++++++++++++ test/unit/map/split_lazy_rcu_gpb.cpp | 41 +++ test/unit/map/split_lazy_rcu_gpi.cpp | 41 +++ test/unit/map/split_lazy_rcu_gpt.cpp | 41 +++ test/unit/map/split_lazy_rcu_shb.cpp | 45 ++++ test/unit/map/split_lazy_rcu_sht.cpp | 45 ++++ test/unit/map/split_michael_rcu_gpb.cpp | 41 +++ test/unit/map/split_michael_rcu_gpi.cpp | 41 +++ test/unit/map/split_michael_rcu_gpt.cpp | 41 +++ test/unit/map/split_michael_rcu_shb.cpp | 45 ++++ test/unit/map/split_michael_rcu_sht.cpp | 45 ++++ test/unit/map/test_split_lazy_rcu.h | 278 ++++++++++++++++++++ test/unit/map/test_split_michael_rcu.h | 249 ++++++++++++++++++ 18 files changed, 1780 insertions(+) create mode 100644 test/unit/map/split_lazy_dhp.cpp create mode 100644 test/unit/map/split_lazy_hp.cpp create mode 100644 test/unit/map/split_lazy_nogc.cpp create mode 100644 test/unit/map/split_lazy_rcu_gpb.cpp create mode 100644 test/unit/map/split_lazy_rcu_gpi.cpp create mode 100644 test/unit/map/split_lazy_rcu_gpt.cpp create mode 100644 test/unit/map/split_lazy_rcu_shb.cpp create mode 100644 test/unit/map/split_lazy_rcu_sht.cpp create mode 100644 test/unit/map/split_michael_rcu_gpb.cpp create mode 100644 test/unit/map/split_michael_rcu_gpi.cpp create mode 100644 test/unit/map/split_michael_rcu_gpt.cpp create mode 100644 test/unit/map/split_michael_rcu_shb.cpp create mode 100644 test/unit/map/split_michael_rcu_sht.cpp create mode 100644 test/unit/map/test_split_lazy_rcu.h create mode 100644 test/unit/map/test_split_michael_rcu.h diff --git a/projects/Win/vc14/gtest-map.vcxproj b/projects/Win/vc14/gtest-map.vcxproj index 04ee4b66..1d1b6d8e 100644 --- a/projects/Win/vc14/gtest-map.vcxproj +++ b/projects/Win/vc14/gtest-map.vcxproj @@ -65,6 +65,56 @@ + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 4503 @@ -89,6 +139,32 @@ 4503 4503 + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + @@ -97,6 +173,8 @@ + + {42B7E892-DDDA-4D00-9AB7-378E0E7E9433} diff --git a/projects/Win/vc14/gtest-map.vcxproj.filters b/projects/Win/vc14/gtest-map.vcxproj.filters index a33c56be..d09f3f90 100644 --- a/projects/Win/vc14/gtest-map.vcxproj.filters +++ b/projects/Win/vc14/gtest-map.vcxproj.filters @@ -81,6 +81,45 @@ Source Files\SplitListMap + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + + + Source Files\SplitListMap + @@ -101,5 +140,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/test/unit/map/CMakeLists.txt b/test/unit/map/CMakeLists.txt index bfda3c16..c1b9a80b 100644 --- a/test/unit/map/CMakeLists.txt +++ b/test/unit/map/CMakeLists.txt @@ -18,9 +18,22 @@ set(CDSGTEST_MAP_SOURCES michael_michael_rcu_gpt.cpp michael_michael_rcu_shb.cpp michael_michael_rcu_sht.cpp + split_lazy_hp.cpp + split_lazy_dhp.cpp + split_lazy_nogc.cpp + split_lazy_rcu_gpb.cpp + split_lazy_rcu_gpi.cpp + split_lazy_rcu_gpt.cpp + split_lazy_rcu_shb.cpp + split_lazy_rcu_sht.cpp split_michael_hp.cpp split_michael_dhp.cpp split_michael_nogc.cpp + split_michael_rcu_gpb.cpp + split_michael_rcu_gpi.cpp + split_michael_rcu_gpt.cpp + split_michael_rcu_shb.cpp + split_michael_rcu_sht.cpp ) include_directories( diff --git a/test/unit/map/split_lazy_dhp.cpp b/test/unit/map/split_lazy_dhp.cpp new file mode 100644 index 00000000..70a31243 --- /dev/null +++ b/test/unit/map/split_lazy_dhp.cpp @@ -0,0 +1,235 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_map_hp.h" + +#include +#include + +namespace { + namespace cc = cds::container; + typedef cds::gc::DHP gc_type; + + class SplitListLazyMap_DHP : public cds_test::container_map_hp + { + protected: + typedef cds_test::container_map_hp base_class; + + void SetUp() + { + struct map_traits: public cc::split_list::traits { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + cds::gc::dhp::GarbageCollector::Construct( 16, map_type::c_nHazardPtrCount ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::dhp::GarbageCollector::Destruct(); + } + }; + + TEST_F( SplitListLazyMap_DHP, compare ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::compare< cmp > + >::type + > + >::type + > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_DHP, less ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< less > + >::type + > + >::type + > map_type; + + map_type m( kSize, 1 ); + test( m ); + } + + TEST_F( SplitListLazyMap_DHP, cmpmix ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< less > + , cds::opt::compare< cmp > + >::type + > + >::type + > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_DHP, item_counting ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + + TEST_F( SplitListLazyMap_DHP, stat ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cc::split_list::stat<> stat; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef base_class::less less; + typedef cds::opt::v::sequential_consistent memory_model; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_DHP, back_off ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 3 ); + test( m ); + } + + TEST_F( SplitListLazyMap_DHP, mutex ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::pause back_off; + typedef std::mutex lock_type; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + struct set_static_traits: public cc::split_list::traits + { + static bool const dynamic_bucket_table = false; + }; + + TEST_F( SplitListLazyMap_DHP, static_bucket_table ) + { + struct map_traits: public set_static_traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + +} // namespace diff --git a/test/unit/map/split_lazy_hp.cpp b/test/unit/map/split_lazy_hp.cpp new file mode 100644 index 00000000..dc76e662 --- /dev/null +++ b/test/unit/map/split_lazy_hp.cpp @@ -0,0 +1,236 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_map_hp.h" + +#include +#include + +namespace { + namespace cc = cds::container; + typedef cds::gc::HP gc_type; + + class SplitListLazyMap_HP : public cds_test::container_map_hp + { + protected: + typedef cds_test::container_map_hp base_class; + + void SetUp() + { + struct map_traits: public cc::split_list::traits { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + // +1 - for guarded_ptr + cds::gc::hp::GarbageCollector::Construct( map_type::c_nHazardPtrCount + 1, 1, 16 ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::hp::GarbageCollector::Destruct( true ); + } + }; + + TEST_F( SplitListLazyMap_HP, compare ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::compare< cmp > + >::type + > + >::type + > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_HP, less ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< less > + >::type + > + >::type + > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_HP, cmpmix ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< less > + , cds::opt::compare< cmp > + >::type + > + >::type + > map_type; + + map_type m( kSize, 3 ); + test( m ); + } + + TEST_F( SplitListLazyMap_HP, item_counting ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + + TEST_F( SplitListLazyMap_HP, stat ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cc::split_list::stat<> stat; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef base_class::less less; + typedef cds::opt::v::sequential_consistent memory_model; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_HP, back_off ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + + TEST_F( SplitListLazyMap_HP, mutex ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::pause back_off; + typedef std::mutex lock_type; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + struct set_static_traits: public cc::split_list::traits + { + static bool const dynamic_bucket_table = false; + }; + + TEST_F( SplitListLazyMap_HP, static_bucket_table ) + { + struct map_traits: public set_static_traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + +} // namespace diff --git a/test/unit/map/split_lazy_nogc.cpp b/test/unit/map/split_lazy_nogc.cpp new file mode 100644 index 00000000..a8b89980 --- /dev/null +++ b/test/unit/map/split_lazy_nogc.cpp @@ -0,0 +1,220 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_map_nogc.h" + +#include +#include + +namespace { + namespace cc = cds::container; + typedef cds::gc::nogc gc_type; + + class SplitListLazyMap_NoGC : public cds_test::container_map_nogc + { + protected: + typedef cds_test::container_map_nogc base_class; + + //void SetUp() + //{} + + //void TearDown() + //{} + }; + + TEST_F( SplitListLazyMap_NoGC, compare ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::compare< cmp > + >::type + > + >::type + > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_NoGC, less ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< less > + >::type + > + >::type + > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_NoGC, cmpmix ) + { + typedef cc::SplitListMap< gc_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< less > + , cds::opt::compare< cmp > + >::type + > + >::type + > map_type; + + map_type m( kSize, 1 ); + test( m ); + } + + TEST_F( SplitListLazyMap_NoGC, item_counting ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 3 ); + test( m ); + } + + TEST_F( SplitListLazyMap_NoGC, stat ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cc::split_list::stat<> stat; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef base_class::less less; + typedef cds::opt::v::sequential_consistent memory_model; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + + TEST_F( SplitListLazyMap_NoGC, back_off ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 2 ); + test( m ); + } + + TEST_F( SplitListLazyMap_NoGC, mutex ) + { + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::pause back_off; + typedef std::mutex lock_type; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 3 ); + test( m ); + } + + struct set_static_traits: public cc::split_list::traits + { + static bool const dynamic_bucket_table = false; + }; + + TEST_F( SplitListLazyMap_NoGC, static_bucket_table ) + { + struct map_traits: public set_static_traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type; + + map_type m( kSize, 4 ); + test( m ); + } + + +} // namespace diff --git a/test/unit/map/split_lazy_rcu_gpb.cpp b/test/unit/map/split_lazy_rcu_gpb.cpp new file mode 100644 index 00000000..6b9f0bed --- /dev/null +++ b/test/unit/map/split_lazy_rcu_gpb.cpp @@ -0,0 +1,41 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "test_split_lazy_rcu.h" + +namespace { + + typedef cds::urcu::general_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPB, SplitListLazyMap, rcu_implementation ); diff --git a/test/unit/map/split_lazy_rcu_gpi.cpp b/test/unit/map/split_lazy_rcu_gpi.cpp new file mode 100644 index 00000000..38238e80 --- /dev/null +++ b/test/unit/map/split_lazy_rcu_gpi.cpp @@ -0,0 +1,41 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "test_split_lazy_rcu.h" + +namespace { + + typedef cds::urcu::general_instant<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPI, SplitListLazyMap, rcu_implementation ); diff --git a/test/unit/map/split_lazy_rcu_gpt.cpp b/test/unit/map/split_lazy_rcu_gpt.cpp new file mode 100644 index 00000000..3df469d9 --- /dev/null +++ b/test/unit/map/split_lazy_rcu_gpt.cpp @@ -0,0 +1,41 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "test_split_lazy_rcu.h" + +namespace { + + typedef cds::urcu::general_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPT, SplitListLazyMap, rcu_implementation ); diff --git a/test/unit/map/split_lazy_rcu_shb.cpp b/test/unit/map/split_lazy_rcu_shb.cpp new file mode 100644 index 00000000..1868c578 --- /dev/null +++ b/test/unit/map/split_lazy_rcu_shb.cpp @@ -0,0 +1,45 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + +#include "test_split_lazy_rcu.h" + +namespace { + + typedef cds::urcu::signal_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHB, SplitListLazyMap, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/map/split_lazy_rcu_sht.cpp b/test/unit/map/split_lazy_rcu_sht.cpp new file mode 100644 index 00000000..5fba1635 --- /dev/null +++ b/test/unit/map/split_lazy_rcu_sht.cpp @@ -0,0 +1,45 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + +#include "test_split_lazy_rcu.h" + +namespace { + + typedef cds::urcu::signal_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHT, SplitListLazyMap, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/map/split_michael_rcu_gpb.cpp b/test/unit/map/split_michael_rcu_gpb.cpp new file mode 100644 index 00000000..b4db11c4 --- /dev/null +++ b/test/unit/map/split_michael_rcu_gpb.cpp @@ -0,0 +1,41 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "test_split_michael_rcu.h" + +namespace { + + typedef cds::urcu::general_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPB, SplitListMichaelMap, rcu_implementation ); diff --git a/test/unit/map/split_michael_rcu_gpi.cpp b/test/unit/map/split_michael_rcu_gpi.cpp new file mode 100644 index 00000000..ee44fdfa --- /dev/null +++ b/test/unit/map/split_michael_rcu_gpi.cpp @@ -0,0 +1,41 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "test_split_michael_rcu.h" + +namespace { + + typedef cds::urcu::general_instant<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPI, SplitListMichaelMap, rcu_implementation ); diff --git a/test/unit/map/split_michael_rcu_gpt.cpp b/test/unit/map/split_michael_rcu_gpt.cpp new file mode 100644 index 00000000..00001496 --- /dev/null +++ b/test/unit/map/split_michael_rcu_gpt.cpp @@ -0,0 +1,41 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "test_split_michael_rcu.h" + +namespace { + + typedef cds::urcu::general_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPT, SplitListMichaelMap, rcu_implementation ); diff --git a/test/unit/map/split_michael_rcu_shb.cpp b/test/unit/map/split_michael_rcu_shb.cpp new file mode 100644 index 00000000..2c1ff106 --- /dev/null +++ b/test/unit/map/split_michael_rcu_shb.cpp @@ -0,0 +1,45 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + +#include "test_split_michael_rcu.h" + +namespace { + + typedef cds::urcu::signal_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHB, SplitListMichaelMap, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/map/split_michael_rcu_sht.cpp b/test/unit/map/split_michael_rcu_sht.cpp new file mode 100644 index 00000000..97d925bc --- /dev/null +++ b/test/unit/map/split_michael_rcu_sht.cpp @@ -0,0 +1,45 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + +#include "test_split_michael_rcu.h" + +namespace { + + typedef cds::urcu::signal_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHT, SplitListMichaelMap, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/map/test_split_lazy_rcu.h b/test/unit/map/test_split_lazy_rcu.h new file mode 100644 index 00000000..cd2ee04a --- /dev/null +++ b/test/unit/map/test_split_lazy_rcu.h @@ -0,0 +1,278 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef CDSUNIT_MAP_TEST_SPLIT_LIST_LAZY_RCU_H +#define CDSUNIT_MAP_TEST_SPLIT_LIST_LAZY_RCU_H + +#include "test_map_rcu.h" +#include +#include + +namespace cc = cds::container; + +template +class SplitListLazyMap: public cds_test::container_map_rcu +{ + typedef cds_test::container_map_rcu base_class; +public: + typedef cds::urcu::gc rcu_type; + +protected: + void SetUp() + { + RCU::Construct(); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + RCU::Destruct(); + } +}; + +TYPED_TEST_CASE_P( SplitListLazyMap ); + +//TYPED_TEST_P( SplitListLazyMap, compare ) +TYPED_TEST_P( SplitListLazyMap, compare ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + typedef cc::SplitListMap< rcu_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::compare< typename TestFixture::cmp > + >::type + > + >::type + > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListLazyMap, less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + typedef cc::SplitListMap< rcu_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< typename TestFixture::less > + >::type + > + >::type + > map_type; + + map_type m( TestFixture::kSize, 4 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListLazyMap, cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + typedef cc::SplitListMap< rcu_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::lazy_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::lazy_list::make_traits< + cds::opt::less< typename TestFixture::less > + , cds::opt::compare< typename TestFixture::cmp > + >::type + > + >::type + > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListLazyMap, item_counting ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef typename TestFixture::cmp compare; + typedef typename TestFixture::less less; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 1 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListLazyMap, stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cc::split_list::stat<> stat; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef typename TestFixture::less less; + typedef cds::opt::v::sequential_consistent memory_model; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 3 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListLazyMap, back_off ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef typename TestFixture::cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListLazyMap, mutex ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef typename TestFixture::cmp compare; + typedef cds::backoff::pause back_off; + typedef std::mutex lock_type; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +namespace { + struct set_static_traits: public cc::split_list::traits + { + static bool const dynamic_bucket_table = false; + }; +} + +TYPED_TEST_P( SplitListLazyMap, static_bucket_table ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public set_static_traits + { + typedef cc::lazy_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::lazy_list::traits + { + typedef typename TestFixture::cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 4 ); + this->test( m ); +} + +REGISTER_TYPED_TEST_CASE_P( SplitListLazyMap, + compare, less, cmpmix, item_counting, stat, back_off, mutex, static_bucket_table +); + + +#endif // CDSUNIT_MAP_TEST_SPLIT_LIST_LAZY_RCU_H + \ No newline at end of file diff --git a/test/unit/map/test_split_michael_rcu.h b/test/unit/map/test_split_michael_rcu.h new file mode 100644 index 00000000..c73bf5f5 --- /dev/null +++ b/test/unit/map/test_split_michael_rcu.h @@ -0,0 +1,249 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef CDSUNIT_MAP_TEST_SPLIT_LIST_MICHAEL_RCU_H +#define CDSUNIT_MAP_TEST_SPLIT_LIST_MICHAEL_RCU_H + +#include "test_map_rcu.h" +#include +#include + +namespace cc = cds::container; + +template +class SplitListMichaelMap: public cds_test::container_map_rcu +{ + typedef cds_test::container_map_rcu base_class; +public: + typedef cds::urcu::gc rcu_type; + +protected: + void SetUp() + { + RCU::Construct(); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + RCU::Destruct(); + } +}; + +TYPED_TEST_CASE_P( SplitListMichaelMap ); + +TYPED_TEST_P( SplitListMichaelMap, compare ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + typedef cc::SplitListMap< rcu_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::michael_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::michael_list::make_traits< + cds::opt::compare< typename TestFixture::cmp > + >::type + > + >::type + > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListMichaelMap, less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + typedef cc::SplitListMap< rcu_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::michael_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::michael_list::make_traits< + cds::opt::less< typename TestFixture::less > + >::type + > + >::type + > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListMichaelMap, cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + typedef cc::SplitListMap< rcu_type, key_type, value_type, + typename cc::split_list::make_traits< + cc::split_list::ordered_list< cc::michael_list_tag > + , cds::opt::hash< hash1 > + , cc::split_list::ordered_list_traits< + typename cc::michael_list::make_traits< + cds::opt::less< typename TestFixture::less > + , cds::opt::compare< typename TestFixture::cmp > + >::type + > + >::type + > map_type; + + map_type m( TestFixture::kSize, 3 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListMichaelMap, item_counting ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::michael_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::michael_list::traits + { + typedef typename TestFixture::cmp compare; + typedef typename TestFixture::less less; + typedef cds::backoff::empty back_off; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 8 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListMichaelMap, stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::michael_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cc::split_list::stat<> stat; + + struct ordered_list_traits: public cc::michael_list::traits + { + typedef typename TestFixture::less less; + typedef cds::opt::v::sequential_consistent memory_model; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 4 ); + this->test( m ); +} + +TYPED_TEST_P( SplitListMichaelMap, back_off ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public cc::split_list::traits + { + typedef cc::michael_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cds::opt::v::sequential_consistent memory_model; + + struct ordered_list_traits: public cc::michael_list::traits + { + typedef typename TestFixture::cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 2 ); + this->test( m ); +} + +namespace { + struct set_static_traits: public cc::split_list::traits + { + static bool const dynamic_bucket_table = false; + }; +} + +TYPED_TEST_P( SplitListMichaelMap, static_bucket_table ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::key_type key_type; + typedef typename TestFixture::value_type value_type; + typedef typename TestFixture::hash1 hash1; + + struct map_traits: public set_static_traits + { + typedef cc::michael_list_tag ordered_list; + typedef hash1 hash; + typedef cds::atomicity::item_counter item_counter; + + struct ordered_list_traits: public cc::michael_list::traits + { + typedef typename TestFixture::cmp compare; + typedef cds::backoff::pause back_off; + }; + }; + typedef cc::SplitListMap< rcu_type, key_type, value_type, map_traits > map_type; + + map_type m( TestFixture::kSize, 4 ); + this->test( m ); +} + +REGISTER_TYPED_TEST_CASE_P( SplitListMichaelMap, + compare, less, cmpmix, item_counting, stat, back_off, static_bucket_table +); + + +#endif // CDSUNIT_MAP_TEST_SPLIT_LIST_MICHAEL_RCU_H + \ No newline at end of file -- 2.34.1