Uses different pass count for different parallel queue test cases
[libcds.git] / test / stress / queue / push.cpp
index d30aec2f6c34bb0873796282062124fcda90a993..398ca66b197631ba53e1d9ec31310c5093461a2e 100644 (file)
@@ -1,11 +1,11 @@
 /*
     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/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -29,6 +29,7 @@
 */
 
 #include "queue_type.h"
+#include "../misc/common.h"
 
 // Multi-threaded queue test for push operation
 namespace {
@@ -43,12 +44,12 @@ namespace {
         {
             size_t      nNo;
 
-            value_type() 
-                : nNo( 0 ) 
+            value_type()
+                : nNo( 0 )
             {}
 
-            value_type( size_t n ) 
-                : nNo( n ) 
+            value_type( size_t n )
+                : nNo( n )
             {}
         };
 
@@ -95,20 +96,20 @@ namespace {
         };
 
     public:
-        static void SetUpTestCase()\r
-        {\r
-            cds_test::config const& cfg = get_config( "queue_push" );\r
-\r
+        static void SetUpTestCase()
+        {
+            cds_test::config const& cfg = get_config( "queue_push" );
+
             s_nThreadCount = cfg.get_size_t( "ThreadCount", s_nThreadCount );
             s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize );
 
-            if ( s_nThreadCount == 0 )
+            if ( s_nThreadCount == 0u )
                 s_nThreadCount = 1;
-            if ( s_nQueueSize == 0 )
+            if ( s_nQueueSize == 0u )
                 s_nQueueSize = 1000;
-        }\r
-\r
-        //static void TearDownTestCase();\r
+        }
+
+        //static void TearDownTestCase();
 
     protected:
         template <class Queue>
@@ -135,7 +136,7 @@ namespace {
 
             propout() << std::make_pair( "duration", duration );
 
-            analyze( q );
+            DEBUG(analyze( q ));
 
             propout() << q.statistics();
         }
@@ -148,9 +149,9 @@ namespace {
 
             for ( size_t i = 0; i < pool.size(); ++i ) {
                 Producer<Queue>& thread = static_cast<Producer<Queue>&>(pool.get( i ));
-                EXPECT_EQ( thread.m_nPushError, 0 ) << " producer thread " << i;
+                EXPECT_EQ( thread.m_nPushError, 0u ) << " producer thread " << i;
             }
-            EXPECT_TRUE( !q.empty() );
+            EXPECT_TRUE( !q.empty());
 
             std::unique_ptr< uint8_t[] > arr( new uint8_t[s_nQueueSize] );
             memset( arr.get(), 0, sizeof(arr[0]) * s_nQueueSize );
@@ -173,22 +174,17 @@ namespace {
     CDSSTRESS_MoirQueue( queue_push )
     CDSSTRESS_BasketQueue( queue_push )
     CDSSTRESS_OptimsticQueue( queue_push )
-    CDSSTRESS_FCQueue( queue_push )
-    CDSSTRESS_FCDeque( queue_push )
     CDSSTRESS_RWQueue( queue_push )
-    CDSSTRESS_StdQueue( queue_push )
 
 #undef CDSSTRESS_Queue_F
-#define CDSSTRESS_Queue_F( test_fixture, type_name, level ) \
+#define CDSSTRESS_Queue_F( test_fixture, type_name ) \
     TEST_F( test_fixture, type_name ) \
     { \
-        if ( !check_detail_level( level )) return; \
         typedef queue::Types< value_type >::type_name queue_type; \
         queue_type queue( s_nQueueSize ); \
         test( queue ); \
     }
 
-    CDSSTRESS_TsigasQueue( queue_push )
     CDSSTRESS_VyukovQueue( queue_push )
 
 #undef CDSSTRESS_Queue_F
@@ -237,18 +233,28 @@ namespace {
         }
     };
 
-#define CDSSTRESS_Queue_F( test_fixture, type_name, level ) \
+#define CDSSTRESS_Queue_F( test_fixture, type_name ) \
     TEST_P( test_fixture, type_name ) \
     { \
-        if ( !check_detail_level( level )) return; \
         typedef typename queue::Types<value_type>::type_name queue_type; \
         test< queue_type >(); \
     }
 
     CDSSTRESS_SegmentedQueue( segmented_queue_push )
 
+#ifdef CDSTEST_GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG
+    static std::string get_test_parameter_name( testing::TestParamInfo<size_t> const& p )
+    {
+        return std::to_string( p.param );
+    }
     INSTANTIATE_TEST_CASE_P( SQ,
         segmented_queue_push,
-        ::testing::ValuesIn( segmented_queue_push::get_test_parameters()));
+        ::testing::ValuesIn( segmented_queue_push::get_test_parameters()), get_test_parameter_name );
+#else
+        INSTANTIATE_TEST_CASE_P( SQ,
+            segmented_queue_push,
+            ::testing::ValuesIn( segmented_queue_push::get_test_parameters()));
+#endif
+
 
 } // namespace