diff options
author | Yann Collet <cyan@fb.com> | 2019-04-12 22:55:38 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2019-04-12 23:10:55 (GMT) |
commit | 9c49e3ca07673949c58d9cffb23034ad0865fefb (patch) | |
tree | ece0e96158e38ac6fb037ea5a43fc64d5dae47fe | |
parent | e865a3e7ec36ca812d8ebb920796732eaceb5135 (diff) | |
download | lz4-9c49e3ca07673949c58d9cffb23034ad0865fefb.zip lz4-9c49e3ca07673949c58d9cffb23034ad0865fefb.tar.gz lz4-9c49e3ca07673949c58d9cffb23034ad0865fefb.tar.bz2 |
added tests for -d -m -c
seems to work properly
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | programs/lz4io.c | 11 | ||||
-rw-r--r-- | tests/Makefile | 34 |
3 files changed, 35 insertions, 13 deletions
@@ -33,3 +33,6 @@ bin/ # Windows / Msys nul ld.exe* + +# test files +*.lz4 diff --git a/programs/lz4io.c b/programs/lz4io.c index bf412da..121bd44 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -766,6 +766,12 @@ int LZ4IO_compressMultipleFilenames(LZ4IO_prefs_t* const prefs, /* loop on each file */ for (i=0; i<ifntSize; i++) { size_t const ifnSize = strlen(inFileNamesTable[i]); + if (!strcmp(suffix, stdoutmark)) { + missed_files += LZ4IO_compressFilename_extRess(prefs, ress, + inFileNamesTable[i], stdoutmark, + compressionLevel); + continue; + } if (ofnSize <= ifnSize+suffixSize+1) { free(dstFileName); ofnSize = ifnSize + 20; @@ -778,9 +784,8 @@ int LZ4IO_compressMultipleFilenames(LZ4IO_prefs_t* const prefs, strcat(dstFileName, suffix); missed_files += LZ4IO_compressFilename_extRess(prefs, ress, - inFileNamesTable[i], - !strcmp(suffix,stdoutmark) ? stdoutmark : dstFileName, - compressionLevel); + inFileNamesTable[i], dstFileName, + compressionLevel); } /* Close & Free */ diff --git a/tests/Makefile b/tests/Makefile index 8442ab8..70cae63 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -222,7 +222,7 @@ test-lz4-frame-concatenation: lz4 datagen @$(LZ4) -zq tmp-lfc-nonempty > tmp-lfc-nonempty.lz4 cat tmp-lfc-nonempty.lz4 tmp-lfc-empty.lz4 tmp-lfc-nonempty.lz4 > tmp-lfc-concat.lz4 $(LZ4) -d tmp-lfc-concat.lz4 > tmp-lfc-result - sdiff tmp-lfc-src tmp-lfc-result + cmp tmp-lfc-src tmp-lfc-result @$(RM) tmp-lfc-* @echo frame concatenation test completed @@ -230,22 +230,36 @@ test-lz4-multiple: lz4 datagen @echo "\n ---- test multiple files ----" @./datagen -s1 > tmp-tlm1 2> $(VOID) @./datagen -s2 -g100K > tmp-tlm2 2> $(VOID) - @./datagen -s3 -g1M > tmp-tlm3 2> $(VOID) + @./datagen -s3 -g200K > tmp-tlm3 2> $(VOID) + # compress multiple files : one .lz4 per source file $(LZ4) -f -m tmp-tlm* test -f tmp-tlm1.lz4 test -f tmp-tlm2.lz4 test -f tmp-tlm3.lz4 - @$(RM) tmp-tlm1 tmp-tlm2 tmp-tlm3 - $(LZ4) -df -m tmp-tlm*.lz4 - test -f tmp-tlm1 - test -f tmp-tlm2 - test -f tmp-tlm3 + # decompress multiple files : one output file per .lz4 + mv tmp-tlm1 tmp-tlm1-orig + mv tmp-tlm2 tmp-tlm2-orig + mv tmp-tlm3 tmp-tlm3-orig + $(LZ4) -d -f -m tmp-tlm*.lz4 + cmp tmp-tlm1 tmp-tlm1-orig # must be identical + cmp tmp-tlm2 tmp-tlm2-orig + cmp tmp-tlm3 tmp-tlm3-orig + # compress multiple files into stdout cat tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 > tmp-tlm-concat1 $(RM) *.lz4 - $(LZ4) -f -m tmp-tlm* -c > tmp-tlm-concat2 + $(LZ4) -m tmp-tlm1 tmp-tlm2 tmp-tlm3 -c > tmp-tlm-concat2 test ! -f tmp-tlm1.lz4 # must not create .lz4 artefact - sdiff tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent - ! $(LZ4) -f -m tmp-tlm1 notHere tmp-tlm2 # must fail : notHere not present + cmp tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent + # decompress multiple files into stdout + $(RM) tmp-tlm-concat1 tmp-tlm-concat2 + $(LZ4) -f -m tmp-tlm1 tmp-tlm2 tmp-tlm3 # generate .lz4 to decompress + cat tmp-tlm1 tmp-tlm2 tmp-tlm3 > tmp-tlm-concat1 # create concatenated reference + $(RM) tmp-tlm1 tmp-tlm2 tmp-tlm3 + $(LZ4) -d -m tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 -c > tmp-tlm-concat2 + test ! -f tmp-tlm1 # must not create file artefact + cmp tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent + # compress multiple files, one of which is absent (must fail) + ! $(LZ4) -f -m tmp-tlm-concat1 notHere tmp-tlm-concat2 # must fail : notHere not present @$(RM) tmp-tlm* test-lz4-basic: lz4 datagen unlz4 lz4cat |