]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added cli test for decodecorpus inside tests/Makefile. Also changed calculation of...
authorPaul Cruz <paulcruz74@fb.com>
Thu, 22 Jun 2017 21:43:44 +0000 (14:43 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Thu, 22 Jun 2017 21:43:44 +0000 (14:43 -0700)
tests/Makefile
tests/decodecorpus.c

index d551a85efe409bb30e555eb4c6739ff56b798faf..4789b1ccf5d64cb2f62ed1905ad229316adb28f3 100644 (file)
@@ -342,21 +342,36 @@ test-decodecorpus: decodecorpus
 
 test-decodecorpus-cli: decodecorpus
        @echo "\n ---- decodecorpus basic cli tests ----"
-       mkdir tests
-       ./decodecorpus -n5 -otests -ptests
-       cd testdir
-       zstd -d z000000.zst -D dictionary -o tmp0
-       zstd -d z000001.zst -D dictionary -o tmp1
-       zstd -d z000002.zst -D dictionary -o tmp2
-       zstd -d z000003.zst -D dictionary -o tmp3
-       zstd -d z000004.zst -D dictionary -o tmp4
-       diff z000000 tmp0
-       diff z000001 tmp1
-       diff z000002 tmp2
-       diff z000003 tmp3
-       diff z000004 tmp4
-       cd ..
-       rm -rf testdir
+       @mkdir testdir
+       ./decodecorpus -n5 -otestdir -ptestdir
+       @cd testdir \
+       zstd -d z000000.zst -o tmp0 \
+       zstd -d z000001.zst -o tmp1 \
+       zstd -d z000002.zst -o tmp2 \
+       zstd -d z000003.zst -o tmp3 \
+       zstd -d z000004.zst -o tmp4 \
+       diff z000000 tmp0 \
+       diff z000001 tmp1 \
+       diff z000002 tmp2 \
+       diff z000003 tmp3 \
+       diff z000004 tmp4 \
+       @rm ./* \
+       @cd ..
+
+       ./decodecorpus -n5 -otestdir -ptestdir --use-dict=1MB
+       @cd testdir \
+       zstd -d z000000.zst -D dictionary -o tmp0 \
+       zstd -d z000001.zst -D dictionary -o tmp1 \
+       zstd -d z000002.zst -D dictionary -o tmp2 \
+       zstd -d z000003.zst -D dictionary -o tmp3 \
+       zstd -d z000004.zst -D dictionary -o tmp4 \
+       diff z000000 tmp0 \
+       diff z000001 tmp1 \
+       diff z000002 tmp2 \
+       diff z000003 tmp3 \
+       diff z000004 tmp4 \
+       @cd .. 
+       @rm -rf testdir
 
 test-pool: pool
        $(QEMU_SYS) ./pool
index 9e4ff810c452293a3a8fe87308b4aa8d96b52ed1..81ddc4b6975b15d3f0e7a0a841dc7e71f26e1802 100644 (file)
@@ -648,7 +648,6 @@ static U32 generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore,
     }
 
     DISPLAYLEVEL(5, "    total match lengths: %u\n", (U32)remainingMatch);
-
     for (i = 0; i < numSequences; i++) {
         /* Generate match and literal lengths by exponential distribution to
          * ensure nice numbers */
@@ -683,8 +682,15 @@ static U32 generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore,
                          1;
                 if (info.useDict && (RAND(seed) & 1)) {
                     /* need to occasionally generate offsets that go past the start */
-                    U32 const lenPastStart = RAND(seed) % info.dictContentSize + 1;
+                    U32 const lenPastStart = (RAND(seed) % info.dictContentSize) + 1;
                     offset = ((BYTE*)srcPtr - (BYTE*)frame->srcStart)+lenPastStart;
+                    if (lenPastStart > frame->header.windowSize) {
+                        matchLen = MIN(matchLen, frame->header.windowSize);
+                    }
+                    if (offset > frame->header.windowSize) {
+                        U32 const matchLenBound = MIN(frame->header.windowSize, lenPastStart);
+                        matchLen = MIN(matchLen, matchLenBound);
+                    }
                 }
                 offsetCode = offset + ZSTD_REP_MOVE;
                 repIndex = 2;