]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Move test to appropriate location
authorsenhuang42 <senhuang96@fb.com>
Tue, 27 Oct 2020 20:59:43 +0000 (16:59 -0400)
committersenhuang42 <senhuang96@fb.com>
Tue, 27 Oct 2020 20:59:43 +0000 (16:59 -0400)
tests/fuzzer.c

index f0ac24677ff1ec79e11e80a4b2259ed45daabdb9..eb1b28c1c79644daf5d85407a608d8766d5853ae 100644 (file)
@@ -385,42 +385,6 @@ static int basicUnitTests(U32 const seed, double compressibility)
     }
     DISPLAYLEVEL(3, "OK \n");
 
-    DISPLAYLEVEL(3, "test%3i : LDM + opt parser with uncompressible block ", testNb++);
-    {   ZSTD_CCtx* cctx = ZSTD_createCCtx();
-        ZSTD_DCtx* dctx = ZSTD_createDCtx();
-        size_t const srcSize = 300 KB;
-        size_t const flushSize = 128 KB + 5;
-        size_t const dstSize = ZSTD_compressBound(srcSize);
-        char* src = CNBuffer;
-        char* dst = compressedBuffer;
-
-        ZSTD_outBuffer out = { dst, dstSize, 0 };
-        ZSTD_inBuffer in = { src, flushSize, 0 };
-
-        RDG_genBuffer(src, srcSize, 0.5, 0.5, seed);
-        /* Force an LDM to exist that crosses block boundary into uncompressible block */
-        memcpy(src + 125 KB, src, 3 KB + 5);
-
-        /* Enable MT, LDM, and opt parser */
-        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1));
-        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_enableLongDistanceMatching, 1));
-        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1));
-        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, 19));
-
-        /* Flushes a block of 128 KB and block of 5 bytes */
-        CHECK_Z(ZSTD_compressStream2(cctx, &out, &in, ZSTD_e_flush));
-
-        /* Compress the rest */
-        in.size = 300 KB;
-        CHECK_Z(ZSTD_compressStream2(cctx, &out, &in, ZSTD_e_end));
-
-        CHECK_Z(ZSTD_decompress(decodedBuffer, CNBuffSize, dst, out.pos));
-
-        ZSTD_freeCCtx(cctx);
-        ZSTD_freeDCtx(dctx);
-    }
-    DISPLAYLEVEL(3, "OK \n");
-
     DISPLAYLEVEL(3, "test%3u : compress %u bytes : ", testNb++, (unsigned)CNBuffSize);
     {   ZSTD_CCtx* const cctx = ZSTD_createCCtx();
         if (cctx==NULL) goto _output_error;
@@ -754,6 +718,42 @@ static int basicUnitTests(U32 const seed, double compressibility)
     }
     DISPLAYLEVEL(3, "OK \n");
 
+    DISPLAYLEVEL(3, "test%3i : LDM + opt parser with small uncompressible block ", testNb++);
+    {   ZSTD_CCtx* cctx = ZSTD_createCCtx();
+        ZSTD_DCtx* dctx = ZSTD_createDCtx();
+        size_t const srcSize = 300 KB;
+        size_t const flushSize = 128 KB + 5;
+        size_t const dstSize = ZSTD_compressBound(srcSize);
+        char* src = CNBuffer;
+        char* dst = compressedBuffer;
+
+        ZSTD_outBuffer out = { dst, dstSize, 0 };
+        ZSTD_inBuffer in = { src, flushSize, 0 };
+
+        RDG_genBuffer(src, srcSize, 0.5, 0.5, seed);
+        /* Force an LDM to exist that crosses block boundary into uncompressible block */
+        memcpy(src + 125 KB, src, 3 KB + 5);
+
+        /* Enable MT, LDM, and opt parser */
+        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1));
+        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_enableLongDistanceMatching, 1));
+        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1));
+        CHECK_Z(ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, 19));
+
+        /* Flushes a block of 128 KB and block of 5 bytes */
+        CHECK_Z(ZSTD_compressStream2(cctx, &out, &in, ZSTD_e_flush));
+
+        /* Compress the rest */
+        in.size = 300 KB;
+        CHECK_Z(ZSTD_compressStream2(cctx, &out, &in, ZSTD_e_end));
+
+        CHECK_Z(ZSTD_decompress(decodedBuffer, CNBuffSize, dst, out.pos));
+
+        ZSTD_freeCCtx(cctx);
+        ZSTD_freeDCtx(dctx);
+    }
+    DISPLAYLEVEL(3, "OK \n");
+
     DISPLAYLEVEL(3, "test%3i : testing ldm dictionary gets invalidated : ", testNb++);
     {
         ZSTD_CCtx* const cctx = ZSTD_createCCtx();