From 887176193fecc4c0a804a76a00b7677258256898 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 19 Mar 2016 12:01:53 +0300 Subject: [PATCH] Migrated SkipListSet unit test to gtest --- projects/Win/vc14/gtest-set.vcxproj | 23 +++ projects/Win/vc14/gtest-set.vcxproj.filters | 30 +++ test/unit/set/CMakeLists.txt | 8 + test/unit/set/skiplist_dhp.cpp | 161 +++++++++++++++++ test/unit/set/skiplist_hp.cpp | 162 +++++++++++++++++ test/unit/set/skiplist_nogc.cpp | 149 +++++++++++++++ test/unit/set/skiplist_rcu_gpb.cpp | 41 +++++ test/unit/set/skiplist_rcu_gpi.cpp | 41 +++++ test/unit/set/skiplist_rcu_gpt.cpp | 41 +++++ test/unit/set/skiplist_rcu_shb.cpp | 45 +++++ test/unit/set/skiplist_rcu_sht.cpp | 45 +++++ test/unit/set/test_skiplist_rcu.h | 191 ++++++++++++++++++++ 12 files changed, 937 insertions(+) create mode 100644 test/unit/set/skiplist_dhp.cpp create mode 100644 test/unit/set/skiplist_hp.cpp create mode 100644 test/unit/set/skiplist_nogc.cpp create mode 100644 test/unit/set/skiplist_rcu_gpb.cpp create mode 100644 test/unit/set/skiplist_rcu_gpi.cpp create mode 100644 test/unit/set/skiplist_rcu_gpt.cpp create mode 100644 test/unit/set/skiplist_rcu_shb.cpp create mode 100644 test/unit/set/skiplist_rcu_sht.cpp create mode 100644 test/unit/set/test_skiplist_rcu.h diff --git a/projects/Win/vc14/gtest-set.vcxproj b/projects/Win/vc14/gtest-set.vcxproj index c7056066..df5b23b6 100644 --- a/projects/Win/vc14/gtest-set.vcxproj +++ b/projects/Win/vc14/gtest-set.vcxproj @@ -72,6 +72,28 @@ + + + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + 4503 4503 @@ -180,6 +202,7 @@ + diff --git a/projects/Win/vc14/gtest-set.vcxproj.filters b/projects/Win/vc14/gtest-set.vcxproj.filters index 6c8d01e9..aad25aaa 100644 --- a/projects/Win/vc14/gtest-set.vcxproj.filters +++ b/projects/Win/vc14/gtest-set.vcxproj.filters @@ -19,6 +19,9 @@ {6cf522b0-3039-424a-80f6-12e9ca592630} + + {5c30de7f-5e68-4ef5-b9a5-63a1ec626010} + @@ -120,6 +123,30 @@ Source Files\SplitList + + Source Files\SkipList + + + Source Files\SkipList + + + Source Files\SkipList + + + Source Files\SkipList + + + Source Files\SkipList + + + Source Files\SkipList + + + Source Files\SkipList + + + Source Files\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 98606398..0dae6f46 100644 --- a/test/unit/set/CMakeLists.txt +++ b/test/unit/set/CMakeLists.txt @@ -18,6 +18,14 @@ set(CDSGTEST_SET_SOURCES michael_michael_rcu_gpt.cpp michael_michael_rcu_shb.cpp michael_michael_rcu_sht.cpp + skiplist_hp.cpp + skiplist_dhp.cpp + skiplist_nogc.cpp + skiplist_rcu_gpb.cpp + skiplist_rcu_gpi.cpp + skiplist_rcu_gpt.cpp + skiplist_rcu_shb.cpp + skiplist_rcu_sht.cpp split_lazy_hp.cpp split_lazy_dhp.cpp split_lazy_nogc.cpp diff --git a/test/unit/set/skiplist_dhp.cpp b/test/unit/set/skiplist_dhp.cpp new file mode 100644 index 00000000..5eb2c0e8 --- /dev/null +++ b/test/unit/set/skiplist_dhp.cpp @@ -0,0 +1,161 @@ +/* + 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_set_hp.h" + +#include + +namespace { + namespace cc = cds::container; + typedef cds::gc::DHP gc_type; + + class SkipListSet_DHP : public cds_test::container_set_hp + { + protected: + typedef cds_test::container_set_hp base_class; + + void SetUp() + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + }; + typedef cc::SkipListSet< gc_type, int_item > 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( SkipListSet_DHP, compare ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::compare< cmp > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_DHP, less ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< base_class::less > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_DHP, cmpmix ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< base_class::less > + ,cds::opt::compare< cmp > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_DHP, item_counting ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_DHP, backoff ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_DHP, stat ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cc::skip_list::stat<> stat; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_DHP, random_level_generator ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cc::skip_list::stat<> stat; + typedef cc::skip_list::xorshift random_level_generator; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + +} // namespace diff --git a/test/unit/set/skiplist_hp.cpp b/test/unit/set/skiplist_hp.cpp new file mode 100644 index 00000000..bf9727eb --- /dev/null +++ b/test/unit/set/skiplist_hp.cpp @@ -0,0 +1,162 @@ +/* + 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_set_hp.h" + +#include + +namespace { + namespace cc = cds::container; + typedef cds::gc::HP gc_type; + + class SkipListSet_HP : public cds_test::container_set_hp + { + protected: + typedef cds_test::container_set_hp base_class; + + void SetUp() + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + }; + typedef cc::SkipListSet< gc_type, int_item > 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( SkipListSet_HP, compare ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::compare< cmp > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_HP, less ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< base_class::less > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_HP, cmpmix ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< base_class::less > + ,cds::opt::compare< cmp > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_HP, item_counting ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_HP, backoff ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_HP, stat ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cc::skip_list::stat<> stat; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_HP, random_level_generator ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cc::skip_list::stat<> stat; + typedef cc::skip_list::xorshift random_level_generator; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + +} // namespace diff --git a/test/unit/set/skiplist_nogc.cpp b/test/unit/set/skiplist_nogc.cpp new file mode 100644 index 00000000..302c21d6 --- /dev/null +++ b/test/unit/set/skiplist_nogc.cpp @@ -0,0 +1,149 @@ +/* + 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_set_nogc.h" + +#include + +namespace { + namespace cc = cds::container; + typedef cds::gc::nogc gc_type; + + class SkipListSet_NoGC : public cds_test::container_set_nogc + { + protected: + typedef cds_test::container_set_nogc base_class; + + //void SetUp() + //{} + + //void TearDown() + //{} + }; + + TEST_F( SkipListSet_NoGC, compare ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::compare< cmp > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_NoGC, less ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< base_class::less > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_NoGC, cmpmix ) + { + typedef cc::SkipListSet< gc_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< base_class::less > + ,cds::opt::compare< cmp > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_NoGC, item_counting ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_NoGC, backoff ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_NoGC, stat ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cc::skip_list::stat<> stat; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + + TEST_F( SkipListSet_NoGC, random_level_generator ) + { + struct set_traits: public cc::skip_list::traits + { + typedef cmp compare; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cc::skip_list::stat<> stat; + typedef cc::skip_list::xorshift random_level_generator; + }; + typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type; + + set_type s; + test( s ); + } + +} // namespace diff --git a/test/unit/set/skiplist_rcu_gpb.cpp b/test/unit/set/skiplist_rcu_gpb.cpp new file mode 100644 index 00000000..e6e77cfc --- /dev/null +++ b/test/unit/set/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_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::general_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPB, SkipListSet, rcu_implementation ); diff --git a/test/unit/set/skiplist_rcu_gpi.cpp b/test/unit/set/skiplist_rcu_gpi.cpp new file mode 100644 index 00000000..86ca7c28 --- /dev/null +++ b/test/unit/set/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_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::general_instant<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPI, SkipListSet, rcu_implementation ); diff --git a/test/unit/set/skiplist_rcu_gpt.cpp b/test/unit/set/skiplist_rcu_gpt.cpp new file mode 100644 index 00000000..65aed08c --- /dev/null +++ b/test/unit/set/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_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::general_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPT, SkipListSet, rcu_implementation ); diff --git a/test/unit/set/skiplist_rcu_shb.cpp b/test/unit/set/skiplist_rcu_shb.cpp new file mode 100644 index 00000000..4111ea87 --- /dev/null +++ b/test/unit/set/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_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::signal_buffered<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHB, SkipListSet, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/set/skiplist_rcu_sht.cpp b/test/unit/set/skiplist_rcu_sht.cpp new file mode 100644 index 00000000..bdc75656 --- /dev/null +++ b/test/unit/set/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_skiplist_rcu.h" + +namespace { + + typedef cds::urcu::signal_threaded<> rcu_implementation; + +} // namespace + +INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHT, SkipListSet, rcu_implementation ); + +#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED diff --git a/test/unit/set/test_skiplist_rcu.h b/test/unit/set/test_skiplist_rcu.h new file mode 100644 index 00000000..ca931319 --- /dev/null +++ b/test/unit/set/test_skiplist_rcu.h @@ -0,0 +1,191 @@ +/* + 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_SKIPLIST_RCU_H +#define CDSUNIT_SET_TEST_SKIPLIST_RCU_H + +#include "test_set_rcu.h" +#include + +namespace cc = cds::container; + +template +class SkipListSet: public cds_test::container_set_rcu +{ + typedef cds_test::container_set_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( SkipListSet ); + +//TYPED_TEST_P( SkipListSet, compare ) +TYPED_TEST_P( SkipListSet, compare ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + typedef cc::SkipListSet< rcu_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::compare< typename TestFixture::cmp > + >::type + > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( SkipListSet, less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + typedef cc::SkipListSet< rcu_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< typename TestFixture::less > + >::type + > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( SkipListSet, cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + typedef cc::SkipListSet< rcu_type, int_item, + typename cc::skip_list::make_traits< + cds::opt::less< typename TestFixture::less > + ,cds::opt::compare< typename TestFixture::cmp > + >::type + > set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( SkipListSet, item_counting ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + struct set_traits: public cc::skip_list::traits + { + typedef typename TestFixture::cmp compare; + typedef typename TestFixture::less less; + typedef cds::atomicity::item_counter item_counter; + }; + typedef cc::SkipListSet< rcu_type, int_item, set_traits >set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( SkipListSet, backoff ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + struct set_traits: public cc::skip_list::traits + { + typedef typename TestFixture::cmp compare; + typedef typename TestFixture::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + }; + typedef cc::SkipListSet< rcu_type, int_item, set_traits >set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( SkipListSet, stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + struct set_traits: public cc::skip_list::traits + { + typedef typename TestFixture::cmp compare; + typedef typename TestFixture::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::backoff::yield back_off; + typedef cc::skip_list::stat<> stat; + }; + typedef cc::SkipListSet< rcu_type, int_item, set_traits >set_type; + + set_type s; + this->test( s ); +} + +TYPED_TEST_P( SkipListSet, random_level_generator ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::int_item int_item; + + struct set_traits: public cc::skip_list::traits + { + typedef typename TestFixture::cmp compare; + typedef typename TestFixture::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cc::skip_list::stat<> stat; + typedef cc::skip_list::xorshift random_level_generator; + typedef cds::opt::v::rcu_assert_deadlock rcu_check_deadlock; + }; + typedef cc::SkipListSet< rcu_type, int_item, set_traits >set_type; + + set_type s; + this->test( s ); +} + + +// GCC 5: All this->test names should be written on single line, otherwise a runtime error will be encountered like as +// "No this->test named can be found in this this->test case" +REGISTER_TYPED_TEST_CASE_P( SkipListSet, + compare, less, cmpmix, item_counting, backoff, stat, random_level_generator +); + + +#endif // CDSUNIT_SET_TEST_SKIPLIST_RCU_H + \ No newline at end of file -- 2.34.1