Moved stress test for intrusive stack to gtest framework
authorkhizmax <libcds.dev@gmail.com>
Wed, 24 Feb 2016 21:22:40 +0000 (00:22 +0300)
committerkhizmax <libcds.dev@gmail.com>
Wed, 24 Feb 2016 21:22:40 +0000 (00:22 +0300)
projects/Win/vc14/stress-stack.vcxproj
projects/Win/vc14/stress-stack.vcxproj.filters
test/stress/stack/CMakeLists.txt
test/stress/stack/intrusive_push_pop.cpp
test/stress/stack/intrusive_push_pop_fcstack.cpp [new file with mode: 0644]
test/stress/stack/intrusive_stack_push_pop.h
test/stress/stack/intrusive_stack_type.h

index abd5845d703c6f5939011de4d64395bedc2666fa..24fafb14130ae620d9f55f63e90a4947aa2c2601 100644 (file)
@@ -29,6 +29,7 @@
   <ItemGroup>\r
     <ClCompile Include="..\..\..\test\stress\main.cpp" />\r
     <ClCompile Include="..\..\..\test\stress\stack\intrusive_push_pop.cpp" />\r
+    <ClCompile Include="..\..\..\test\stress\stack\intrusive_push_pop_fcstack.cpp" />\r
     <ClCompile Include="..\..\..\test\stress\stack\push.cpp" />\r
     <ClCompile Include="..\..\..\test\stress\stack\push_pop.cpp" />\r
   </ItemGroup>\r
index 5d4e437eaea4aff8ec25174e9aeacd5adae6f745..9cae1e96dff9d8db465b56116c6ff06b68305e88 100644 (file)
@@ -27,6 +27,9 @@
     <ClCompile Include="..\..\..\test\stress\stack\intrusive_push_pop.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\..\test\stress\stack\intrusive_push_pop_fcstack.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\..\test\stress\stack\stack_type.h">\r
index 8a62e6c2d71b11cb67e6b9b46599682e44cef727..1d1dc5f76a6c9bca95c552ff8ba1a34e0b360ccd 100644 (file)
@@ -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
 )
index 3b89e7bf594148a7dca16fab0988028dc19535cf..30af880eba5db4f3b987f61feb60063fe888895a 100644 (file)
@@ -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 (file)
index 0000000..abb70ce
--- /dev/null
@@ -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<boost::intrusive::slist_base_hook<>> slist_value_type;
+        typedef base_class::value_type<boost::intrusive::list_base_hook<>>  list_value_type;
+
+
+        template <typename Stack>
+        void test()
+        {
+            value_array<typename Stack::value_type> 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<slist_value_type>::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<list_value_type>::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 ));
+
index c919a61c37cfadd526de086dcb6600fce9d583e0..58538e172148507d6103ba701feb9b43a6c7f1b4 100644 (file)
@@ -45,8 +45,8 @@ namespace cds_test {
 
         static atomics::atomic<size_t>  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 );
index 89f6a8eb27915a61a84fc4a0b9a117ca01178451..570116d9d533a2bed0738e7a10a08d03ffe3cb8a 100644 (file)
@@ -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 ) \