Uses different pass count for different parallel queue test cases
[libcds.git] / test / stress / queue / random.cpp
index 65b81a264498681c0bbdfb627f4181caae9bba62..5a4188a60e8b7ed10131dc3326fdf7491356c3a5 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:
 
@@ -25,7 +25,7 @@
     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.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #include "queue_type.h"
@@ -89,7 +89,7 @@ namespace {
                 value_type node;
 
                 while ( m_nPushCount < nTotalPush ) {
-                    if ( (rand() & 3) != 3 ) {
+                    if ( ( std::rand() & 3) != 3 ) {
                         node.nThread = id();
                         node.nNo = ++m_nPushCount;
                         if ( !m_Queue.push( node )) {
@@ -161,26 +161,26 @@ namespace {
         };
 
     public:
-        static void SetUpTestCase()\r
-        {\r
-            cds_test::config const& cfg = get_config( "queue_random" );\r
-\r
+        static void SetUpTestCase()
+        {
+            cds_test::config const& cfg = get_config( "queue_random" );
+
             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>
         void analyze( Queue& q  )
         {
-            EXPECT_TRUE( q.empty() );
+            EXPECT_TRUE( q.empty());
 
             std::vector< size_t > arrPushCount;
             arrPushCount.resize( s_nThreadCount, 0 );
@@ -192,9 +192,9 @@ namespace {
             cds_test::thread_pool& pool = get_pool();
             for ( size_t i = 0; i < pool.size(); ++i ) {
                 Strain<Queue>& thr = static_cast<Strain<Queue> &>( pool.get(i));
-                EXPECT_EQ( thr.m_nUndefWriter, 0 );
-                EXPECT_EQ( thr.m_nRepeatValue, 0 );
-                EXPECT_EQ( thr.m_nPushError, 0 );
+                EXPECT_EQ( thr.m_nUndefWriter, 0u );
+                EXPECT_EQ( thr.m_nRepeatValue, 0u );
+                EXPECT_EQ( thr.m_nPushError, 0u );
                 nPushError += thr.m_nPushError;
 
                 arrPushCount[ thr.id() ] += thr.m_nPushCount;
@@ -237,10 +237,7 @@ namespace {
     CDSSTRESS_MoirQueue( queue_random )
     CDSSTRESS_BasketQueue( queue_random )
     CDSSTRESS_OptimsticQueue( queue_random )
-    CDSSTRESS_FCQueue( queue_random )
-    CDSSTRESS_FCDeque( queue_random )
     CDSSTRESS_RWQueue( queue_random )
-    CDSSTRESS_StdQueue( queue_random )
 
 #undef CDSSTRESS_Queue_F
 #define CDSSTRESS_Queue_F( test_fixture, type_name ) \
@@ -251,7 +248,6 @@ namespace {
         test( queue ); \
     }
 
-    CDSSTRESS_TsigasQueue( queue_random )
     CDSSTRESS_VyukovQueue( queue_random )
 
 #undef CDSSTRESS_Queue_F
@@ -324,7 +320,18 @@ namespace {
 
     CDSSTRESS_SegmentedQueue( segmented_queue_random )
 
+#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_random,
+        ::testing::ValuesIn( segmented_queue_random::get_test_parameters()), get_test_parameter_name );
+#else
     INSTANTIATE_TEST_CASE_P( SQ,
         segmented_queue_random,
         ::testing::ValuesIn( segmented_queue_random::get_test_parameters()));
+#endif
+
 } // namespace