]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
stronger zbuff synchronization tests
authorYann Collet <yann.collet.73@gmail.com>
Sun, 3 Apr 2016 23:22:26 +0000 (01:22 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Sun, 3 Apr 2016 23:22:26 +0000 (01:22 +0200)
programs/zbufftest.c

index eba2c15102df49803c8afbabc793c9fce8fa7838..8d940134033368063671b5db487a40bb35f3f78a 100644 (file)
@@ -286,8 +286,15 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
         if (nbTests >= testNb) DISPLAYUPDATE(2, "/%6u   ", nbTests);
         FUZ_rand(&coreSeed);
         lseed = coreSeed ^ prime1;
+
+        /* random state complete reset */
+        /* some problems only happen when states are re-used in a specific order */
+        if ((FUZ_rand(&lseed) & 0xFF) == 131) { ZBUFF_freeCCtx(zc); zc = ZBUFF_createCCtx(); }
+        if ((FUZ_rand(&lseed) & 0xFF) == 132) { ZBUFF_freeDCtx(zd); zd = ZBUFF_createDCtx(); }
+
+        /* srcBuffer selection */
         buffNb = FUZ_rand(&lseed) & 0x7F;
-        if (buffNb & 7) buffNb=2;   /* select srcBuffer */
+        if (buffNb & 7) buffNb=2;
         else {
             buffNb >>= 3;
             if (buffNb & 7) {