From 590fda256bbd98fc11c4ba753e8da8083150119d Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 13 Mar 2016 21:21:47 +0300 Subject: [PATCH] Migrated intrusive SkipList unit test to gtest framework --- projects/Win/vc14/gtest-set.vcxproj | 16 ++ projects/Win/vc14/gtest-set.vcxproj.filters | 30 +++ test/unit/set/CMakeLists.txt | 8 + test/unit/set/intrusive_skiplist_dhp.cpp | 200 +++++++++++++++ test/unit/set/intrusive_skiplist_hp.cpp | 201 +++++++++++++++ test/unit/set/intrusive_skiplist_nogc.cpp | 186 ++++++++++++++ test/unit/set/intrusive_skiplist_rcu_gpb.cpp | 41 +++ test/unit/set/intrusive_skiplist_rcu_gpi.cpp | 41 +++ test/unit/set/intrusive_skiplist_rcu_gpt.cpp | 41 +++ test/unit/set/intrusive_skiplist_rcu_shb.cpp | 45 ++++ test/unit/set/intrusive_skiplist_rcu_sht.cpp | 45 ++++ test/unit/set/test_intrusive_skiplist_rcu.h | 248 +++++++++++++++++++ 12 files changed, 1102 insertions(+) create mode 100644 test/unit/set/intrusive_skiplist_dhp.cpp create mode 100644 test/unit/set/intrusive_skiplist_hp.cpp create mode 100644 test/unit/set/intrusive_skiplist_nogc.cpp create mode 100644 test/unit/set/intrusive_skiplist_rcu_gpb.cpp create mode 100644 test/unit/set/intrusive_skiplist_rcu_gpi.cpp create mode 100644 test/unit/set/intrusive_skiplist_rcu_gpt.cpp create mode 100644 test/unit/set/intrusive_skiplist_rcu_shb.cpp create mode 100644 test/unit/set/intrusive_skiplist_rcu_sht.cpp create mode 100644 test/unit/set/test_intrusive_skiplist_rcu.h diff --git a/projects/Win/vc14/gtest-set.vcxproj b/projects/Win/vc14/gtest-set.vcxproj index 5ad899a5..59826150 100644 --- a/projects/Win/vc14/gtest-set.vcxproj +++ b/projects/Win/vc14/gtest-set.vcxproj @@ -72,6 +72,21 @@ + + + + + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 4503 @@ -180,6 +195,7 @@ + diff --git a/projects/Win/vc14/gtest-set.vcxproj.filters b/projects/Win/vc14/gtest-set.vcxproj.filters index d3a3a55d..82af08ec 100644 --- a/projects/Win/vc14/gtest-set.vcxproj.filters +++ b/projects/Win/vc14/gtest-set.vcxproj.filters @@ -19,6 +19,9 @@ {619a4db2-c9a0-44eb-bbcf-842ed42d4172} + + {9c07e86e-bd5b-4ae1-a730-c768234ba9f0} + @@ -120,6 +123,30 @@ Source Files\intrusive:SplitList + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + + + Source Files\intrusive::SkipList + @@ -146,5 +173,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/test/unit/set/CMakeLists.txt b/test/unit/set/CMakeLists.txt index 9f9616a2..50464827 100644 --- a/test/unit/set/CMakeLists.txt +++ b/test/unit/set/CMakeLists.txt @@ -20,6 +20,14 @@ set(CDSGTEST_SET_SOURCES intrusive_michael_michael_rcu_gpt.cpp intrusive_michael_michael_rcu_shb.cpp intrusive_michael_michael_rcu_sht.cpp + intrusive_skiplist_hp.cpp + intrusive_skiplist_dhp.cpp + intrusive_skiplist_nogc.cpp + intrusive_skiplist_rcu_gpb.cpp + intrusive_skiplist_rcu_gpi.cpp + intrusive_skiplist_rcu_gpt.cpp + intrusive_skiplist_rcu_shb.cpp + intrusive_skiplist_rcu_sht.cpp intrusive_split_lazy_hp.cpp intrusive_split_lazy_dhp.cpp intrusive_split_lazy_nogc.cpp diff --git a/test/unit/set/intrusive_skiplist_dhp.cpp b/test/unit/set/intrusive_skiplist_dhp.cpp new file mode 100644 index 00000000..555e5958 --- /dev/null +++ b/test/unit/set/intrusive_skiplist_dhp.cpp @@ -0,0 +1,200 @@ +/* + 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_intrusive_set_hp.h" + +#include + +namespace { + namespace ci = cds::intrusive; + typedef cds::gc::DHP gc_type; + + class IntrusiveSkipListSet_DHP : public cds_test::intrusive_set_hp + { + protected: + typedef cds_test::intrusive_set_hp base_class; + + protected: + typedef typename base_class::base_int_item< ci::skip_list::node< gc_type>> base_item_type; + typedef typename base_class::member_int_item< ci::skip_list::node< gc_type>> member_item_type; + + void SetUp() + { + typedef ci::SkipListSet< gc_type, base_item_type, + typename ci::skip_list::make_traits< + ci::opt::hook>> + ,ci::opt::disposer + ,ci::opt::compare + >::type + > set_type; + + cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::dhp::GarbageCollector::Destruct(); + } + }; + + + TEST_F( IntrusiveSkipListSet_DHP, base_cmp ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_DHP, base_less ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_DHP, base_cmpmix ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef base_class::less less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_DHP, base_xorshift ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + + TEST_F( IntrusiveSkipListSet_DHP, member_cmp ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_DHP, member_less ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef ci::opt::v::sequential_consistent memory_model; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_DHP, member_cmpmix ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef base_class::less less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_DHP, member_xorshift ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + +} // namespace diff --git a/test/unit/set/intrusive_skiplist_hp.cpp b/test/unit/set/intrusive_skiplist_hp.cpp new file mode 100644 index 00000000..c3f40e2d --- /dev/null +++ b/test/unit/set/intrusive_skiplist_hp.cpp @@ -0,0 +1,201 @@ +/* + 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_intrusive_set_hp.h" + +#include + +namespace { + namespace ci = cds::intrusive; + typedef cds::gc::HP gc_type; + + class IntrusiveSkipListSet_HP : public cds_test::intrusive_set_hp + { + protected: + typedef cds_test::intrusive_set_hp base_class; + + protected: + typedef typename base_class::base_int_item< ci::skip_list::node< gc_type>> base_item_type; + typedef typename base_class::member_int_item< ci::skip_list::node< gc_type>> member_item_type; + + void SetUp() + { + typedef ci::SkipListSet< gc_type, base_item_type, + typename ci::skip_list::make_traits< + ci::opt::hook>> + ,ci::opt::disposer + ,ci::opt::compare + >::type + > set_type; + + // +1 - for guarded_ptr + cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::hp::GarbageCollector::Destruct( true ); + } + }; + + + TEST_F( IntrusiveSkipListSet_HP, base_cmp ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_HP, base_less ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_HP, base_cmpmix ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef base_class::less less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_HP, base_xorshift ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + + TEST_F( IntrusiveSkipListSet_HP, member_cmp ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_HP, member_less ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef ci::opt::v::sequential_consistent memory_model; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_HP, member_cmpmix ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef base_class::less less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_HP, member_xorshift ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + +} // namespace diff --git a/test/unit/set/intrusive_skiplist_nogc.cpp b/test/unit/set/intrusive_skiplist_nogc.cpp new file mode 100644 index 00000000..e2c7ec7d --- /dev/null +++ b/test/unit/set/intrusive_skiplist_nogc.cpp @@ -0,0 +1,186 @@ +/* + 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_intrusive_set_nogc.h" + +#include + +namespace { + namespace ci = cds::intrusive; + typedef cds::gc::nogc gc_type; + + class IntrusiveSkipListSet_NoGC : public cds_test::intrusive_set_nogc + { + protected: + typedef cds_test::intrusive_set_nogc base_class; + + protected: + typedef typename base_class::base_int_item< ci::skip_list::node< gc_type>> base_item_type; + typedef typename base_class::member_int_item< ci::skip_list::node< gc_type>> member_item_type; + + //void SetUp() + //{} + + //void TearDown() + //{} + }; + + + TEST_F( IntrusiveSkipListSet_NoGC, base_cmp ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_NoGC, base_less ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_NoGC, base_cmpmix ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef base_class::less less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_NoGC, base_xorshift ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type; + + set_type s; + test( s ); + } + + + TEST_F( IntrusiveSkipListSet_NoGC, member_cmp ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_NoGC, member_less ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef ci::opt::v::sequential_consistent memory_model; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_NoGC, member_cmpmix ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef base_class::less less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveSkipListSet_NoGC, member_xorshift ) + { + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type; + + set_type s; + test( s ); + } + +} // namespace diff --git a/test/unit/set/intrusive_skiplist_rcu_gpb.cpp b/test/unit/set/intrusive_skiplist_rcu_gpb.cpp new file mode 100644 index 00000000..a80370b9 --- /dev/null +++ b/test/unit/set/intrusive_skiplist_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_intrusive_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::general_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPB, IntrusiveSkipListSet, rcu_implementation ); diff --git a/test/unit/set/intrusive_skiplist_rcu_gpi.cpp b/test/unit/set/intrusive_skiplist_rcu_gpi.cpp new file mode 100644 index 00000000..e8b97158 --- /dev/null +++ b/test/unit/set/intrusive_skiplist_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_intrusive_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::general_instant<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPI, IntrusiveSkipListSet, rcu_implementation ); diff --git a/test/unit/set/intrusive_skiplist_rcu_gpt.cpp b/test/unit/set/intrusive_skiplist_rcu_gpt.cpp new file mode 100644 index 00000000..beeeca01 --- /dev/null +++ b/test/unit/set/intrusive_skiplist_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_intrusive_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::general_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPT, IntrusiveSkipListSet, rcu_implementation ); diff --git a/test/unit/set/intrusive_skiplist_rcu_shb.cpp b/test/unit/set/intrusive_skiplist_rcu_shb.cpp new file mode 100644 index 00000000..334cf99d --- /dev/null +++ b/test/unit/set/intrusive_skiplist_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_intrusive_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::signal_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHB, IntrusiveSkipListSet, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/set/intrusive_skiplist_rcu_sht.cpp b/test/unit/set/intrusive_skiplist_rcu_sht.cpp new file mode 100644 index 00000000..04a52d6c --- /dev/null +++ b/test/unit/set/intrusive_skiplist_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_intrusive_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::signal_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHT, IntrusiveSkipListSet, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/set/test_intrusive_skiplist_rcu.h b/test/unit/set/test_intrusive_skiplist_rcu.h new file mode 100644 index 00000000..ddaa8dd1 --- /dev/null +++ b/test/unit/set/test_intrusive_skiplist_rcu.h @@ -0,0 +1,248 @@ +/* + 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_SET_TEST_INTRUSIVE_SKIPLIST_RCU_H +#define CDSUNIT_SET_TEST_INTRUSIVE_SKIPLIST_RCU_H + +#include "test_intrusive_set_rcu.h" +#include + +namespace ci = cds::intrusive; + +template +class IntrusiveSkipListSet: public cds_test::intrusive_set_rcu +{ + typedef cds_test::intrusive_set_rcu base_class; +public: + typedef cds::urcu::gc rcu_type; + typedef typename base_class::base_int_item< ci::skip_list::node> base_item_type; + typedef typename base_class::member_int_item< ci::skip_list::node> member_item_type; + +protected: + void SetUp() + { + RCU::Construct(); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + RCU::Destruct(); + } +}; + +TYPED_TEST_CASE_P( IntrusiveSkipListSet ); + +TYPED_TEST_P( IntrusiveSkipListSet, base_cmp ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template cmp cmp; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< rcu_type, base_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( IntrusiveSkipListSet, base_less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template less less_predicate; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef less_predicate less; + typedef cds::atomicity::item_counter item_counter; + }; + + typedef ci::SkipListSet< rcu_type, base_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( IntrusiveSkipListSet, base_cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template cmp cmp; + typedef typename TestFixture::template less less_predicate; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef less_predicate less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< rcu_type, base_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( IntrusiveSkipListSet, base_xorshift ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template cmp cmp; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::base_hook< ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< rcu_type, base_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + + +TYPED_TEST_P( IntrusiveSkipListSet, member_cmp ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template cmp cmp; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + }; + + typedef ci::SkipListSet< rcu_type, member_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( IntrusiveSkipListSet, member_less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template less less_predicate; + typedef typename TestFixture::hash_int hash_int; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef less_predicate less; + typedef cds::atomicity::item_counter item_counter; + typedef ci::opt::v::sequential_consistent memory_model; + }; + + typedef ci::SkipListSet< rcu_type, member_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( IntrusiveSkipListSet, member_cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template less less_predicate; + typedef typename TestFixture::template cmp cmp; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef less_predicate less; + typedef ci::skip_list::stat<> stat; + }; + + typedef ci::SkipListSet< rcu_type, member_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( IntrusiveSkipListSet, member_xorshift ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template less less_predicate; + typedef typename TestFixture::template cmp cmp; + + struct traits : public ci::skip_list::traits + { + typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< rcu_type >> hook; + typedef mock_disposer disposer; + typedef cmp compare; + typedef less_predicate less; + typedef ci::skip_list::stat<> stat; + typedef ci::skip_list::xorshift random_level_generator; + }; + + typedef ci::SkipListSet< rcu_type, member_item_type, traits > set_type; + + set_type s; + this->test( s ); +} + + +// GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as +// "No test named can be found in this test case" +REGISTER_TYPED_TEST_CASE_P( IntrusiveSkipListSet, + base_cmp, base_less, base_cmpmix, base_xorshift, member_cmp, member_less, member_cmpmix, member_xorshift +); + + +#endif // CDSUNIT_SET_TEST_INTRUSIVE_SKIPLIST_RCU_H + \ No newline at end of file -- 2.34.1