[UBsan] Fixed set-insdelfind stress test
authorkhizmax <libcds.dev@gmail.com>
Sun, 5 Mar 2017 18:46:43 +0000 (21:46 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 5 Mar 2017 18:46:43 +0000 (21:46 +0300)
test/stress/set/insdel_find/set_insdelfind.cpp
test/stress/set/insdel_find/set_insdelfind.h

index 2899bc39636b03290104ad95d2a8317237c11b4e..e35e8ea726e95f2d451b61a76b7761834606dabd 100644 (file)
@@ -47,6 +47,7 @@ namespace set {
     size_t Set_InsDelFind::s_nFeldmanSet_ArrayBits = 4;
 
     size_t Set_InsDelFind::s_nLoadFactor = 2;
+    Set_InsDelFind::actions Set_InsDelFind::s_arrShuffle[Set_InsDelFind::c_nShuffleSize];
 
     void Set_InsDelFind::SetUpTestCase()
     {
@@ -93,6 +94,18 @@ namespace set {
         s_nFeldmanSet_ArrayBits = cfg.get_size_t( "FeldmanMapArrayBits", s_nFeldmanSet_ArrayBits );
         if ( s_nFeldmanSet_ArrayBits == 0 )
             s_nFeldmanSet_ArrayBits = 2;
+
+        actions * pFirst = s_arrShuffle;
+        actions * pLast = s_arrShuffle + s_nInsertPercentage;
+        std::fill( pFirst, pLast, do_insert );
+        pFirst = pLast;
+        pLast += s_nDeletePercentage;
+        std::fill( pFirst, pLast, do_delete );
+        pFirst = pLast;
+        pLast = s_arrShuffle + sizeof( s_arrShuffle ) / sizeof( s_arrShuffle[0] );
+        if ( pFirst < pLast )
+            std::fill( pFirst, pLast, do_find );
+        shuffle( s_arrShuffle, pLast );
     }
 
     std::vector<size_t> Set_InsDelFind_LF::get_load_factors()
index 4cd0bab1d10977bf2939680a04b3b9893503f0ba..c28ab90af53f40a089840f4a5126903b743ab5b6 100644 (file)
@@ -62,7 +62,7 @@ namespace set {
             do_delete
         };
         static const unsigned int c_nShuffleSize = 100;
-        actions m_arrShuffle[c_nShuffleSize];
+        static actions s_arrShuffle[c_nShuffleSize];
 
     protected:
         typedef size_t  key_type;
@@ -103,7 +103,6 @@ namespace set {
                 Set& rSet = m_Set;
                 Set_InsDelFind& fixture = pool().template fixture<Set_InsDelFind>();
 
-                actions * pAct = fixture.m_arrShuffle;
                 unsigned int i = 0;
                 size_t const nNormalize = size_t(-1) / ( fixture.s_nSetSize * 2);
 
@@ -111,7 +110,7 @@ namespace set {
                 while ( !time_elapsed()) {
                     nRand = cds::bitop::RandXorShift(nRand);
                     size_t n = nRand / nNormalize;
-                    switch ( pAct[i] ) {
+                    switch ( s_arrShuffle[i] ) {
                     case do_find:
                         if ( rSet.contains( n ))
                             ++m_nFindSuccess;