diff options
author | test4973 <Kdo4973@hotmail.com> | 2018-04-04 18:38:55 (GMT) |
---|---|---|
committer | test4973 <Kdo4973@hotmail.com> | 2018-04-04 18:38:55 (GMT) |
commit | 43132af808119e71fdeb153f6e7ad53673c8f9e4 (patch) | |
tree | 544cfebf96b23a909813e5169269debb80804c68 /tests | |
parent | c3f0ed28ffa66fd7e28ec3b6dbbe95eb0974bfef (diff) | |
parent | d759d0630003b0722e9389c2297c1856ba8e939f (diff) | |
download | lz4-43132af808119e71fdeb153f6e7ad53673c8f9e4.zip lz4-43132af808119e71fdeb153f6e7ad53673c8f9e4.tar.gz lz4-43132af808119e71fdeb153f6e7ad53673c8f9e4.tar.bz2 |
Merge branch 'dev' into lowAddr
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 29 | ||||
-rw-r--r-- | tests/frametest.c | 27 |
2 files changed, 32 insertions, 24 deletions
diff --git a/tests/Makefile b/tests/Makefile index 34b8b24..302ebab 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,8 +1,6 @@ # ########################################################################## # LZ4 programs - Makefile -# Copyright (C) Yann Collet 2011-2017 -# -# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets +# Copyright (C) Yann Collet 2011-present # # GPL v2 License # @@ -54,7 +52,7 @@ else EXT = VOID = /dev/null endif -LZ4 := $(PRGDIR)/lz4$(EXT) +LZ4 := $(PRGDIR)/lz4$(EXT) # Default test parameters @@ -185,12 +183,6 @@ test-lz4-contentSize: lz4 datagen $(LZ4) -v tmplc1 | $(LZ4) -t $(LZ4) -v --content-size tmplc1 | $(LZ4) -d > tmplc2 $(DIFF) -s tmplc1 tmplc2 - # test large size [2-4] GB - @./datagen -g3G -P100 | $(LZ4) -vv | $(LZ4) --decompress --force --sparse - tmplc1 - @ls -ls tmplc1 - @./datagen -g3G -P100 | $(LZ4) --quiet --content-size | $(LZ4) --verbose --decompress --force --sparse - tmplc2 - @ls -ls tmplc2 - $(DIFF) -s tmplc1 tmplc2 @$(RM) tmplc* test-lz4-frame-concatenation: lz4 datagen @@ -294,6 +286,13 @@ test-lz4-hugefile: lz4 datagen @echo "\n ---- test huge files compression/decompression ----" ./datagen -g6GB | $(LZ4) -vB5D | $(LZ4) -qt ./datagen -g6GB | $(LZ4) -v5BD | $(LZ4) -qt + # test large file size [2-4] GB + @./datagen -g3G -P100 | $(LZ4) -vv | $(LZ4) --decompress --force --sparse - tmphf1 + @ls -ls tmphf1 + @./datagen -g3G -P100 | $(LZ4) --quiet --content-size | $(LZ4) --verbose --decompress --force --sparse - tmphf2 + @ls -ls tmphf2 + $(DIFF) -s tmphf1 tmphf2 + @$(RM) tmphf* test-lz4-testmode: lz4 datagen @echo "\n ---- bench mode ----" @@ -327,9 +326,13 @@ test-lz4-opt-parser: lz4 datagen ./datagen -g16M -P90 | $(LZ4) -11B5 | $(LZ4) -t ./datagen -g32M -P10 | $(LZ4) -11B5D | $(LZ4) -t -test-lz4: lz4 datagen test-lz4-basic test-lz4-opt-parser test-lz4-multiple \ - test-lz4-sparse test-lz4-frame-concatenation test-lz4-testmode \ - test-lz4-contentSize test-lz4-hugefile test-lz4-dict +test-lz4-essentials : lz4 datagen test-lz4-basic test-lz4-multiple \ + test-lz4-frame-concatenation test-lz4-testmode \ + test-lz4-contentSize test-lz4-dict + @$(RM) tmp* + +test-lz4: lz4 datagen test-lz4-essentials test-lz4-opt-parser \ + test-lz4-sparse test-lz4-hugefile test-lz4-dict @$(RM) tmp* test-lz4c: lz4c datagen diff --git a/tests/frametest.c b/tests/frametest.c index 88d0afd..74d9c88 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -164,7 +164,7 @@ static unsigned FUZ_highbit(U32 v32) /*-******************************************************* * Tests *********************************************************/ -#define CHECK_V(v,f) v = f; if (LZ4F_isError(v)) goto _output_error +#define CHECK_V(v,f) v = f; if (LZ4F_isError(v)) { fprintf(stderr, "%s\n", LZ4F_getErrorName(v)); goto _output_error; } #define CHECK(f) { LZ4F_errorCode_t const CHECK_V(err_ , f); } int basicTests(U32 seed, double compressibility) @@ -509,23 +509,25 @@ int basicTests(U32 seed, double compressibility) CHECK( LZ4F_freeCompressionContext(cctx) ); cctx = NULL; } - /* Dictionary compression test */ { size_t const dictSize = 63 KB; size_t const dstCapacity = LZ4F_compressFrameBound(dictSize, NULL); size_t cSizeNoDict, cSizeWithDict; LZ4F_CDict* const cdict = LZ4F_createCDict(CNBuffer, dictSize); if (cdict == NULL) goto _output_error; + CHECK( LZ4F_createCompressionContext(&cctx, LZ4F_VERSION) ); DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with NULL dict : "); CHECK_V(cSizeNoDict, - LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity, + LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity, CNBuffer, dictSize, NULL, NULL) ); DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeNoDict); + CHECK( LZ4F_freeCompressionContext(cctx) ); + CHECK( LZ4F_createCompressionContext(&cctx, LZ4F_VERSION) ); DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with dict : "); CHECK_V(cSizeWithDict, - LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity, + LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity, CNBuffer, dictSize, cdict, NULL) ); DISPLAYLEVEL(3, "compressed %u bytes into %u bytes \n", @@ -557,7 +559,7 @@ int basicTests(U32 seed, double compressibility) memset(&cParams, 0, sizeof(cParams)); cParams.compressionLevel = -3; CHECK_V(cSizeLevelMax, - LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity, + LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity, CNBuffer, dictSize, cdict, &cParams) ); DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeLevelMax); @@ -569,7 +571,7 @@ int basicTests(U32 seed, double compressibility) memset(&cParams, 0, sizeof(cParams)); cParams.compressionLevel = LZ4F_compressionLevel_max(); CHECK_V(cSizeLevelMax, - LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity, + LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity, CNBuffer, dictSize, cdict, &cParams) ); DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeLevelMax); @@ -584,7 +586,7 @@ int basicTests(U32 seed, double compressibility) cParams.frameInfo.blockMode = LZ4F_blockLinked; cParams.frameInfo.blockSizeID = LZ4F_max64KB; CHECK_V(cSizeContiguous, - LZ4F_compressFrame_usingCDict(compressedBuffer, outCapacity, + LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, outCapacity, CNBuffer, inSize, cdict, &cParams) ); DISPLAYLEVEL(3, "compressed %u bytes into %u bytes \n", @@ -620,7 +622,7 @@ int basicTests(U32 seed, double compressibility) cParams.frameInfo.blockMode = LZ4F_blockIndependent; cParams.frameInfo.blockSizeID = LZ4F_max64KB; CHECK_V(cSizeIndep, - LZ4F_compressFrame_usingCDict(compressedBuffer, outCapacity, + LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, outCapacity, CNBuffer, inSize, cdict, &cParams) ); DISPLAYLEVEL(3, "compressed %u bytes into %u bytes \n", @@ -647,6 +649,7 @@ int basicTests(U32 seed, double compressibility) } LZ4F_freeCDict(cdict); + CHECK( LZ4F_freeCompressionContext(cctx) ); cctx = NULL; } @@ -730,15 +733,17 @@ _output_error: static void locateBuffDiff(const void* buff1, const void* buff2, size_t size, unsigned nonContiguous) { - int p=0; + size_t p=0; const BYTE* b1=(const BYTE*)buff1; const BYTE* b2=(const BYTE*)buff2; if (nonContiguous) { DISPLAY("Non-contiguous output test (%i bytes)\n", (int)size); return; } - while (b1[p]==b2[p]) p++; - DISPLAY("Error at pos %i/%i : %02X != %02X \n", p, (int)size, b1[p], b2[p]); + while (p < size && b1[p]==b2[p]) p++; + if (p != size) { + DISPLAY("Error at pos %i/%i : %02X != %02X \n", (int)p, (int)size, b1[p], b2[p]); + } } |