Only runs standard stack test cases
[libcds.git] / test / stress / stack / push_pop.cpp
index c2222f4e2bb2a7509e3fec08fa3d7fd6061107d8..a032ea510d8bd5a9c9469a4975df306e01d9cea2 100644 (file)
@@ -1,7 +1,7 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
@@ -52,13 +52,13 @@ namespace {
             size_t      nNo;
             size_t      nThread;
 
-            value_type() 
+            value_type()
                 : nNo( 0 )
-                , nThread( 0 ) 
+                , nThread( 0 )
             {}
-            value_type( size_t n ) 
+            value_type( size_t n )
                 : nNo( n )
-                , nThread( 0 ) 
+                , nThread( 0 )
             {}
         };
 
@@ -91,13 +91,13 @@ namespace {
 
             virtual void test()
             {
-                memset( m_arrPush, 0, sizeof( m_arrPush ) );
+                memset( m_arrPush, 0, sizeof( m_arrPush ));
 
                 value_type v;
                 v.nThread = id();
                 for ( size_t i = 0; i < m_nItemCount; ++i ) {
                     v.nNo = i % c_nValArraySize;
-                    if ( m_stack.push( v ) )
+                    if ( m_stack.push( v ))
                         ++m_arrPush[v.nNo];
                     else
                         ++m_nPushError;
@@ -142,13 +142,13 @@ namespace {
 
             virtual void test()
             {
-                memset( m_arrPop, 0, sizeof( m_arrPop ) );
+                memset( m_arrPop, 0, sizeof( m_arrPop ));
 
                 value_type v;
-                while ( !( s_nWorkingProducers.load( atomics::memory_order_acquire ) == 0 && m_stack.empty()) ) {
-                    if ( m_stack.pop( v ) ) {
+                while ( !( s_nWorkingProducers.load( atomics::memory_order_acquire ) == 0 && m_stack.empty())) {
+                    if ( m_stack.pop( v )) {
                         ++m_nPopCount;
-                        if ( v.nNo < sizeof( m_arrPop ) / sizeof( m_arrPop[0] ) )
+                        if ( v.nNo < sizeof( m_arrPop ) / sizeof( m_arrPop[0] ))
                             ++m_arrPop[v.nNo];
                         else
                             ++m_nDirtyPop;
@@ -167,10 +167,10 @@ namespace {
         };
 
     protected:
-        static void SetUpTestCase()\r
-        {\r
-            cds_test::config const& cfg = get_config("Stack_PushPop");\r
-\r
+        static void SetUpTestCase()
+        {
+            cds_test::config const& cfg = get_config("Stack_PushPop");
+
             s_nPushThreadCount = cfg.get_size_t( "PushThreadCount", s_nPushThreadCount );
             s_nPopThreadCount  = cfg.get_size_t( "PopThreadCount",  s_nPopThreadCount );
             s_nStackSize       = cfg.get_size_t( "StackSize",       s_nStackSize );
@@ -180,9 +180,9 @@ namespace {
                 s_nPushThreadCount = 1;
             if ( s_nPopThreadCount == 0 )
                 s_nPopThreadCount = 1;
-        }\r
-\r
-        //static void TearDownTestCase();\r
+        }
+
+        //static void TearDownTestCase();
 
         template <typename Stack>
         void test( Stack& stack )
@@ -199,7 +199,7 @@ namespace {
             propout() << std::make_pair( "producer_thread_count", s_nPushThreadCount )
                 << std::make_pair( "consumer_thread_count", s_nPopThreadCount )
                 << std::make_pair( "push_count", s_nStackSize )
-                ;
+;
 
             std::chrono::milliseconds duration = pool.run();
 
@@ -214,7 +214,7 @@ namespace {
         void test_elimination( Stack& stack )
         {
             test( stack );
-            check_elimination_stat( stack.statistics() );
+            check_elimination_stat( stack.statistics());
         }
 
         void check_elimination_stat( cds::container::treiber_stack::empty_stat const& )
@@ -224,13 +224,13 @@ namespace {
         {
             EXPECT_EQ( s.m_PushCount.get() + s.m_ActivePushCollision.get() + s.m_PassivePushCollision.get(), s_nStackSize );
             EXPECT_EQ( s.m_PopCount.get() + s.m_ActivePopCollision.get() + s.m_PassivePopCollision.get(), s_nStackSize );
-            EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get() );
-            EXPECT_EQ( s.m_ActivePopCollision.get(), s.m_PassivePushCollision.get() );
-            EXPECT_EQ( s.m_ActivePushCollision.get(), s.m_PassivePopCollision.get() );
+            EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get());
+            EXPECT_EQ( s.m_ActivePopCollision.get(), s.m_PassivePushCollision.get());
+            EXPECT_EQ( s.m_ActivePushCollision.get(), s.m_PassivePopCollision.get());
         }
 
         template< class Stack>
-        void analyze( Stack& stack )
+        void analyze( Stack& /*stack*/ )
         {
             cds_test::thread_pool& pool = get_pool();
 
@@ -238,7 +238,7 @@ namespace {
             size_t nPopEmpty = 0;
             size_t nPopCount = 0;
             size_t arrVal[c_nValArraySize];
-            memset( arrVal, 0, sizeof( arrVal ) );
+            memset( arrVal, 0, sizeof( arrVal ));
             size_t nDirtyPop = 0;
 
             for ( size_t threadNo = 0; threadNo < pool.size(); ++threadNo ) {
@@ -263,24 +263,23 @@ namespace {
             }
 
             EXPECT_EQ( nPopCount, s_nStackSize );
-            EXPECT_EQ( nDirtyPop, 0 );
+            EXPECT_EQ( nDirtyPop, 0u );
 
             for ( size_t i = 0; i < sizeof( arrVal ) / sizeof( arrVal[0] ); ++i ) {
-                EXPECT_EQ( arrVal[i], 0 );
+                EXPECT_EQ( arrVal[i], 0u );
             }
 
             propout() << std::make_pair( "push_count", s_nStackSize )
                       << std::make_pair( "push_error", nPushError )
                       << std::make_pair( "pop_empty", nPopEmpty )
                       << std::make_pair( "dirty_pop", nDirtyPop )
-                      ;
+;
         }
     };
 
     CDSSTRESS_TreiberStack( stack_push_pop )
     CDSSTRESS_EliminationStack( stack_push_pop )
-    CDSSTRESS_FCStack( stack_push_pop )
-    CDSSTRESS_FCDeque( stack_push_pop )
-    CDSSTRESS_StdStack( stack_push_pop )
+    //CDSSTRESS_FCStack( stack_push_pop )
+    //CDSSTRESS_FCDeque( stack_push_pop )
 
 } // namespace