2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
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.
31 #include "intrusive_stack_push_pop.h"
37 unsigned int nCompactFactor;
38 unsigned int nCombinePassCount;
41 class intrusive_fcstack_push_pop
42 : public cds_test::intrusive_stack_push_pop
43 , public ::testing::WithParamInterface< fc_param >
45 typedef cds_test::intrusive_stack_push_pop base_class;
49 static std::vector< fc_param > get_test_parameters()
51 cds_test::config const& cfg = cds_test::stress_fixture::get_config( "IntrusiveStack_PushPop" );
52 bool bFCIterative = cfg.get_bool( "FCIterate", s_bFCIterative );
53 unsigned int nFCCombinePassCount = cfg.get_uint( "FCCombinePassCount", s_nFCCombinePassCount );
54 unsigned int nFCCompactFactor = cfg.get_uint( "FCCompactFactor", s_nFCCompactFactor );
56 std::vector< fc_param > args;
58 for ( unsigned int nCompactFactor = 1; nCompactFactor <= nFCCompactFactor; nCompactFactor *= 2 ) {
59 for ( unsigned int nPass = 1; nPass <= nFCCombinePassCount; nPass *= 2 )
60 args.push_back( { nCompactFactor, nPass } );
65 if ( nFCCompactFactor && nFCCombinePassCount )
66 args.push_back( { nFCCompactFactor, nFCCombinePassCount } );
68 args.push_back( { 0, 0 } );
74 #ifdef CDSTEST_GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG
75 static std::string get_test_parameter_name( testing::TestParamInfo<fc_param> const& p )
77 if ( p.param.nCombinePassCount ) {
79 ss << "compact_factor" << p.param.nCompactFactor
80 << "__combine_pass_count" << p.param.nCombinePassCount
85 return std::string( "with_defaults" );
91 typedef base_class::value_type<boost::intrusive::slist_base_hook<>> slist_value_type;
92 typedef base_class::value_type<boost::intrusive::list_base_hook<>> list_value_type;
94 template <typename Stack>
97 value_array<typename Stack::value_type> arrValue( s_nStackSize );
98 if ( s_bFCIterative ) {
99 fc_param arg = GetParam();
100 if ( arg.nCombinePassCount ) {
102 << std::make_pair( "compact_factor", arg.nCompactFactor )
103 << std::make_pair( "combine_pass_count", arg.nCombinePassCount );
104 Stack stack( arg.nCompactFactor, arg.nCombinePassCount );
105 do_test( stack, arrValue );
109 do_test( stack, arrValue );
113 fc_param arg = GetParam();
114 if ( arg.nCombinePassCount ) {
116 << std::make_pair( "compact_factor", arg.nCompactFactor )
117 << std::make_pair( "combine_pass_count", arg.nCombinePassCount );
118 Stack stack( arg.nCompactFactor, arg.nCombinePassCount );
119 do_test( stack, arrValue );
123 do_test( stack, arrValue );
129 // FCStack based on boost::intrusive::slist
130 #define CDSSTRESS_Stack_F( test_fixture, stack_impl ) \
131 TEST_P( test_fixture, stack_impl ) \
133 typedef typename istack::Types<slist_value_type>::stack_impl stack_type; \
134 test< stack_type >(); \
137 CDSSTRESS_FCStack_slist( intrusive_fcstack_push_pop )
139 #undef CDSSTRESS_Stack_F
141 // FCStack based on boost::intrusive::list
142 #define CDSSTRESS_Stack_F( test_fixture, stack_impl ) \
143 TEST_P( test_fixture, stack_impl ) \
145 typedef typename istack::Types<list_value_type>::stack_impl stack_type; \
146 test< stack_type >(); \
149 CDSSTRESS_FCStack_list( intrusive_fcstack_push_pop )
151 #undef CDSSTRESS_Stack_F
155 #ifdef CDSTEST_GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG
156 INSTANTIATE_TEST_CASE_P( FC,
157 intrusive_fcstack_push_pop,
158 ::testing::ValuesIn( intrusive_fcstack_push_pop::get_test_parameters()),
159 intrusive_fcstack_push_pop::get_test_parameter_name );
161 INSTANTIATE_TEST_CASE_P( FC,
162 intrusive_fcstack_push_pop,
163 ::testing::ValuesIn( intrusive_fcstack_push_pop::get_test_parameters()));