2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef CDSUNIT_LIST_TEST_INTRUSIVE_LAZY_LIST_RCU_H
31 #define CDSUNIT_LIST_TEST_INTRUSIVE_LAZY_LIST_RCU_H
33 #include "test_intrusive_list_rcu.h"
34 #include <cds/intrusive/lazy_list_rcu.h>
36 namespace ci = cds::intrusive;
39 class IntrusiveLazyList : public cds_test::intrusive_list_rcu
41 typedef cds_test::intrusive_list_rcu base_class;
43 typedef cds::urcu::gc<RCU> rcu_type;
44 typedef typename base_class::base_item< ci::lazy_list::node< rcu_type >> base_item;
45 typedef typename base_class::member_item< ci::lazy_list::node< rcu_type >> member_item;
51 cds::threading::Manager::attachThread();
56 cds::threading::Manager::detachThread();
61 TYPED_TEST_CASE_P( IntrusiveLazyList );
63 TYPED_TEST_P( IntrusiveLazyList, base_hook )
65 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item,
66 typename ci::lazy_list::make_traits<
67 ci::opt::hook< ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >>>
68 , ci::opt::disposer< typename TestFixture::mock_disposer >
69 , cds::opt::less< typename TestFixture::template less< typename TestFixture::base_item >>
74 this->test_common( l );
75 this->test_ordered_iterator( l );
79 TYPED_TEST_P( IntrusiveLazyList, base_hook_cmp )
81 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item,
82 typename ci::lazy_list::make_traits<
83 ci::opt::hook< ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >>>
84 , ci::opt::disposer< typename TestFixture::mock_disposer >
85 , cds::opt::compare< typename TestFixture::template cmp< typename TestFixture::base_item >>
90 this->test_common( l );
91 this->test_ordered_iterator( l );
95 TYPED_TEST_P( IntrusiveLazyList, base_hook_item_counting )
97 struct traits : public ci::lazy_list::traits {
98 typedef ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >> hook;
99 typedef typename TestFixture::mock_disposer disposer;
100 typedef typename TestFixture::template cmp< typename TestFixture::base_item > compare;
101 typedef typename TestFixture::template less< typename TestFixture::base_item > less;
102 typedef cds::atomicity::item_counter item_counter;
104 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item, traits > list_type;
107 this->test_common( l );
108 this->test_ordered_iterator( l );
112 TYPED_TEST_P( IntrusiveLazyList, base_hook_backoff )
114 struct traits : public ci::lazy_list::traits {
115 typedef ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >> hook;
116 typedef typename TestFixture::mock_disposer disposer;
117 typedef typename TestFixture::template cmp< typename TestFixture::base_item > compare;
118 typedef typename TestFixture::template less< typename TestFixture::base_item > less;
119 typedef cds::atomicity::item_counter item_counter;
120 typedef cds::backoff::pause back_off;
122 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item, traits > list_type;
125 this->test_common( l );
126 this->test_ordered_iterator( l );
130 TYPED_TEST_P( IntrusiveLazyList, base_hook_seqcst )
132 struct traits : public ci::lazy_list::traits {
133 typedef ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >> hook;
134 typedef typename TestFixture::mock_disposer disposer;
135 typedef typename TestFixture::template cmp< typename TestFixture::base_item > compare;
136 typedef cds::atomicity::item_counter item_counter;
137 typedef cds::opt::v::sequential_consistent memory_model;
139 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item, traits > list_type;
142 this->test_common( l );
143 this->test_ordered_iterator( l );
147 TYPED_TEST_P( IntrusiveLazyList, base_hook_stat )
149 struct traits: public ci::lazy_list::traits {
150 typedef ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >> hook;
151 typedef typename TestFixture::mock_disposer disposer;
152 typedef typename TestFixture::template cmp< typename TestFixture::base_item > compare;
153 typedef cds::atomicity::item_counter item_counter;
154 typedef cds::intrusive::lazy_list::stat<> stat;
156 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item, traits > list_type;
159 this->test_common( l );
160 this->test_ordered_iterator( l );
164 TYPED_TEST_P( IntrusiveLazyList, base_hook_wrapped_stat )
166 struct traits: public ci::lazy_list::traits {
167 typedef ci::lazy_list::base_hook< cds::opt::gc< typename TestFixture::rcu_type >> hook;
168 typedef typename TestFixture::mock_disposer disposer;
169 typedef typename TestFixture::template cmp< typename TestFixture::base_item > compare;
170 typedef cds::atomicity::item_counter item_counter;
171 typedef cds::intrusive::lazy_list::wrapped_stat<> stat;
173 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::base_item, traits > list_type;
175 cds::intrusive::lazy_list::stat<> st;
177 this->test_common( l );
178 this->test_ordered_iterator( l );
182 TYPED_TEST_P( IntrusiveLazyList, member_hook )
184 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item,
185 typename ci::lazy_list::make_traits<
186 ci::opt::hook< ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >>>
187 ,ci::opt::disposer< typename TestFixture::mock_disposer >
188 ,cds::opt::less< typename TestFixture::template less< typename TestFixture::member_item >>
193 this->test_common( l );
194 this->test_ordered_iterator( l );
198 TYPED_TEST_P( IntrusiveLazyList, member_hook_cmp )
200 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item,
201 typename ci::lazy_list::make_traits<
202 ci::opt::hook< ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >>>
203 ,ci::opt::disposer< typename TestFixture::mock_disposer >
204 ,cds::opt::compare< typename TestFixture::template cmp< typename TestFixture::member_item >>
209 this->test_common( l );
210 this->test_ordered_iterator( l );
214 TYPED_TEST_P( IntrusiveLazyList, member_hook_item_counting )
216 struct traits : public ci::lazy_list::traits {
217 typedef ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >> hook;
218 typedef typename TestFixture::mock_disposer disposer;
219 typedef typename TestFixture::template cmp< typename TestFixture::member_item > compare;
220 typedef typename TestFixture::template less< typename TestFixture::member_item > less;
221 typedef cds::atomicity::item_counter item_counter;
223 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item, traits > list_type;
226 this->test_common( l );
227 this->test_ordered_iterator( l );
231 TYPED_TEST_P( IntrusiveLazyList, member_hook_seqcst )
233 struct traits : public ci::lazy_list::traits {
234 typedef ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >> hook;
235 typedef typename TestFixture::mock_disposer disposer;
236 typedef typename TestFixture::template less< typename TestFixture::member_item > less;
237 typedef cds::atomicity::item_counter item_counter;
238 typedef cds::opt::v::sequential_consistent memory_model;
240 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item, traits > list_type;
243 this->test_common( l );
244 this->test_ordered_iterator( l );
248 TYPED_TEST_P( IntrusiveLazyList, member_hook_back_off )
250 struct traits : public ci::lazy_list::traits {
251 typedef ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >> hook;
252 typedef typename TestFixture::mock_disposer disposer;
253 typedef typename TestFixture::template cmp< typename TestFixture::member_item > compare;
254 typedef typename TestFixture::template less< typename TestFixture::member_item > less;
255 typedef cds::atomicity::item_counter item_counter;
256 typedef cds::backoff::empty back_off;
258 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item, traits > list_type;
261 this->test_common( l );
262 this->test_ordered_iterator( l );
266 TYPED_TEST_P( IntrusiveLazyList, member_hook_stat )
268 struct traits: public ci::lazy_list::traits {
269 typedef ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >> hook;
270 typedef typename TestFixture::mock_disposer disposer;
271 typedef typename TestFixture::template cmp< typename TestFixture::member_item > compare;
272 typedef typename TestFixture::template less< typename TestFixture::member_item > less;
273 typedef cds::atomicity::item_counter item_counter;
274 typedef cds::intrusive::lazy_list::stat<> stat;
276 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item, traits > list_type;
279 this->test_common( l );
280 this->test_ordered_iterator( l );
284 TYPED_TEST_P( IntrusiveLazyList, member_hook_wrapped_stat )
286 struct traits: public ci::lazy_list::traits {
287 typedef ci::lazy_list::member_hook< offsetof( typename TestFixture::member_item, hMember ), cds::opt::gc< typename TestFixture::rcu_type >> hook;
288 typedef typename TestFixture::mock_disposer disposer;
289 typedef typename TestFixture::template cmp< typename TestFixture::member_item > compare;
290 typedef cds::atomicity::item_counter item_counter;
291 typedef cds::intrusive::lazy_list::wrapped_stat<> stat;
293 typedef ci::LazyList< typename TestFixture::rcu_type, typename TestFixture::member_item, traits > list_type;
295 cds::intrusive::lazy_list::stat<> st;
297 this->test_common( l );
298 this->test_ordered_iterator( l );
302 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
303 // "No test named <test_name> can be found in this test case"
304 REGISTER_TYPED_TEST_CASE_P( IntrusiveLazyList,
305 base_hook, base_hook_cmp, base_hook_item_counting, base_hook_backoff, base_hook_seqcst, base_hook_stat, base_hook_wrapped_stat, member_hook, member_hook_cmp, member_hook_item_counting, member_hook_seqcst, member_hook_back_off, member_hook_stat, member_hook_wrapped_stat
309 #endif // CDSUNIT_LIST_TEST_INTRUSIVE_LAZY_LIST_RCU_H