From: khizmax Date: Wed, 24 Feb 2016 21:22:40 +0000 (+0300) Subject: Moved stress test for intrusive stack to gtest framework X-Git-Tag: v2.2.0~382 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=6220d44c39b2fc65f18892bcac691f0e850119b1 Moved stress test for intrusive stack to gtest framework --- diff --git a/projects/Win/vc14/stress-stack.vcxproj b/projects/Win/vc14/stress-stack.vcxproj index abd5845d..24fafb14 100644 --- a/projects/Win/vc14/stress-stack.vcxproj +++ b/projects/Win/vc14/stress-stack.vcxproj @@ -29,6 +29,7 @@ + diff --git a/projects/Win/vc14/stress-stack.vcxproj.filters b/projects/Win/vc14/stress-stack.vcxproj.filters index 5d4e437e..9cae1e96 100644 --- a/projects/Win/vc14/stress-stack.vcxproj.filters +++ b/projects/Win/vc14/stress-stack.vcxproj.filters @@ -27,6 +27,9 @@ Source Files + + Source Files + diff --git a/test/stress/stack/CMakeLists.txt b/test/stress/stack/CMakeLists.txt index 8a62e6c2..1d1dc5f7 100644 --- a/test/stress/stack/CMakeLists.txt +++ b/test/stress/stack/CMakeLists.txt @@ -3,6 +3,7 @@ set(PACKAGE_NAME stress-stack) set(CDSSTRESS_STACK_SOURCES ../main.cpp intrusive_push_pop.cpp + intrusive_push_pop_fcstack.cpp push.cpp push_pop.cpp ) diff --git a/test/stress/stack/intrusive_push_pop.cpp b/test/stress/stack/intrusive_push_pop.cpp index 3b89e7bf..30af880e 100644 --- a/test/stress/stack/intrusive_push_pop.cpp +++ b/test/stress/stack/intrusive_push_pop.cpp @@ -177,4 +177,6 @@ namespace { #undef CDSSTRESS_Stack_F + //INSTANTIATE_TEST_CASE_P( a, intrusive_stack_push_pop, ::testing::Values(1)); + } // namespace diff --git a/test/stress/stack/intrusive_push_pop_fcstack.cpp b/test/stress/stack/intrusive_push_pop_fcstack.cpp new file mode 100644 index 00000000..abb70ce4 --- /dev/null +++ b/test/stress/stack/intrusive_push_pop_fcstack.cpp @@ -0,0 +1,120 @@ +/* + 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 "intrusive_stack_push_pop.h" + +namespace { + + struct fc_param + { + unsigned int nCompactFactor; + unsigned int nCombinePassCount; + }; + + static std::vector< fc_param > m_args; + + class intrusive_fcstack_push_pop + : public cds_test::intrusive_stack_push_pop + , public ::testing::WithParamInterface< fc_param > + { + typedef cds_test::intrusive_stack_push_pop base_class; + + public: + static void SetUpTestCase() + { + base_class::SetUpTestCase(); + + if ( s_bFCIterative ) { + for ( unsigned int nCompactFactor = 1; nCompactFactor <= s_nFCCompactFactor; nCompactFactor *= 2 ) { + for ( unsigned int nPass = 1; nPass <= s_nFCCombinePassCount; nPass *= 2 ) + m_args.push_back( { nCompactFactor, nPass } ); + } + } + + if ( m_args.empty()) + m_args.push_back( { 1, 1 } ); + } + static void TearDownTestCase() + { + m_args.clear(); + } + + protected: + typedef base_class::value_type> slist_value_type; + typedef base_class::value_type> list_value_type; + + + template + void test() + { + value_array arrValue( s_nStackSize ); + if ( s_bFCIterative ) { + fc_param arg = GetParam(); + propout() + << std::make_pair( "compact_factor", arg.nCompactFactor ) + << std::make_pair( "combine_pass_count", arg.nCombinePassCount ); + Stack stack( arg.nCompactFactor, arg.nCombinePassCount ); + do_test( stack, arrValue ); + } + else { + Stack stack; + do_test( stack, arrValue ); + } + } + }; + + // FCStack based on boost::intrusive::slist +#define CDSSTRESS_Stack_F( test_fixture, stack_impl ) \ + TEST_P( test_fixture, stack_impl ) \ + { \ + typedef typename istack::Types::stack_impl stack_type; \ + test< stack_type >(); \ + } + + CDSSTRESS_FCStack_slist( intrusive_fcstack_push_pop ) + +#undef CDSSTRESS_Stack_F + + // FCStack based on boost::intrusive::list +#define CDSSTRESS_Stack_F( test_fixture, stack_impl ) \ + TEST_P( test_fixture, stack_impl ) \ + { \ + typedef typename istack::Types::stack_impl stack_type; \ + test< stack_type >(); \ + } + + CDSSTRESS_FCStack_list( intrusive_fcstack_push_pop ) + +#undef CDSSTRESS_Stack_F + +} // namespace + +INSTANTIATE_TEST_CASE_P( FC, intrusive_fcstack_push_pop, ::testing::ValuesIn( m_args )); + diff --git a/test/stress/stack/intrusive_stack_push_pop.h b/test/stress/stack/intrusive_stack_push_pop.h index c919a61c..58538e17 100644 --- a/test/stress/stack/intrusive_stack_push_pop.h +++ b/test/stress/stack/intrusive_stack_push_pop.h @@ -45,8 +45,8 @@ namespace cds_test { static atomics::atomic s_nWorkingProducers; - static CDS_CONSTEXPR const size_t c_nValArraySize = 1024; - static CDS_CONSTEXPR const size_t c_nBadConsumer = 0xbadc0ffe; + static constexpr const size_t c_nValArraySize = 1024; + static constexpr const size_t c_nBadConsumer = 0xbadc0ffe; enum thread_type { @@ -283,8 +283,9 @@ namespace cds_test { { typename Stack::value_type * pEnd = pValStart + s_nStackSize; + size_t const nBadConsumer = c_nBadConsumer; for ( typename Stack::value_type * it = pValStart; it != pEnd; ++it ) - EXPECT_NE( it->nConsumer, c_nBadConsumer ); + EXPECT_NE( it->nConsumer, nBadConsumer ); } analyze( stack ); diff --git a/test/stress/stack/intrusive_stack_type.h b/test/stress/stack/intrusive_stack_type.h index 89f6a8eb..570116d9 100644 --- a/test/stress/stack/intrusive_stack_type.h +++ b/test/stress/stack/intrusive_stack_type.h @@ -470,7 +470,7 @@ namespace cds_test { CDSSTRESS_Stack_F( test_fixture, Elimination_DHP_dyn ) \ CDSSTRESS_Stack_F( test_fixture, Elimination_DHP_dyn_stat ) -#define CDSSTRESS_FCStack( test_fixture ) \ +#define CDSSTRESS_FCStack_slist( test_fixture ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_slist ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_slist_stat ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_slist_elimination ) \ @@ -478,6 +478,8 @@ namespace cds_test { CDSSTRESS_Stack_F( test_fixture, FCStack_slist_mutex_stat ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_slist_mutex_elimination ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_slist_mutex_elimination_stat ) \ + +#define CDSSTRESS_FCStack_list( test_fixture ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_list ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_list_stat ) \ CDSSTRESS_Stack_F( test_fixture, FCStack_list_elimination ) \