[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 2899bc3..e35e8ea 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 4cd0bab..c28ab90 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;