25 println "roundTripTest: ./datagen $1 $proba | $ZSTD -v$cLevel | $ZSTD -d$dLevel"
26 ./datagen $1 $proba | $MD5SUM > tmp1
27 ./datagen $1 $proba | $ZSTD --ultra -v$cLevel | $ZSTD -d$dLevel | $MD5SUM > tmp2
45 rm -f tmp.zstd tmp.md5.1 tmp.md5.2
46 println "fileRoundTripTest: ./datagen $1 $local_p > tmp && $ZSTD -v$local_c -c tmp | $ZSTD -d$local_d"
47 ./datagen $1 $local_p > tmp
48 < tmp $MD5SUM > tmp.md5.1
49 $ZSTD --ultra -v$local_c -c tmp | $ZSTD -d$local_d | $MD5SUM > tmp.md5.2
50 $DIFF -q tmp.md5.1 tmp.md5.2
54 dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1"
62 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
63 PRGDIR="$SCRIPT_DIR/../programs"
64 TESTDIR="$SCRIPT_DIR/../tests"
67 detectedTerminal=false
68 if [ -t 0 ] && [ -t 1 ]
72 isTerminal=${isTerminal:-$detectedTerminal}
77 GNU) DEVDEVICE="/dev/random" ;;
78 *) DEVDEVICE="/dev/zero" ;;
89 Darwin) MD5SUM="md5 -r" ;;
90 FreeBSD) MD5SUM="gmd5sum" ;;
91 OpenBSD) MD5SUM="md5" ;;
97 SunOS) DIFF="gdiff" ;;
100 println "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
102 [ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
104 if echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep -q 'multi-threading is disabled'
112 println "\n===> simple tests "
115 println "test : basic compression "
116 $ZSTD -f tmp # trivial compression case, creates tmp.zst
117 println "test : basic decompression"
118 $ZSTD -df tmp.zst # trivial decompression case (overwrites tmp)
119 println "test : too large compression level => auto-fix"
120 $ZSTD -99 -f tmp # too large compression level, automatic sized down
121 $ZSTD -5000000000 -f tmp && die "too large numeric value : must fail"
122 println "test : --fast aka negative compression levels"
123 $ZSTD --fast -f tmp # == -1
124 $ZSTD --fast=3 -f tmp # == -3
125 $ZSTD --fast=200000 -f tmp # too low compression level, automatic fixed
126 $ZSTD --fast=5000000000 -f tmp && die "too large numeric value : must fail"
127 $ZSTD -c --fast=0 tmp > $INTOVOID && die "--fast must not accept value 0"
128 println "test : too large numeric argument"
129 $ZSTD --fast=9999999999 -f tmp && die "should have refused numeric value"
130 println "test : set compression level with environment variable ZSTD_CLEVEL"
131 ZSTD_CLEVEL=12 $ZSTD -f tmp # positive compression level
132 ZSTD_CLEVEL=-12 $ZSTD -f tmp # negative compression level
133 ZSTD_CLEVEL=+12 $ZSTD -f tmp # valid: verbose '+' sign
134 ZSTD_CLEVEL='' $ZSTD -f tmp # empty env var, warn and revert to default setting
135 ZSTD_CLEVEL=- $ZSTD -f tmp # malformed env var, warn and revert to default setting
136 ZSTD_CLEVEL=a $ZSTD -f tmp # malformed env var, warn and revert to default setting
137 ZSTD_CLEVEL=+a $ZSTD -f tmp # malformed env var, warn and revert to default setting
138 ZSTD_CLEVEL=3a7 $ZSTD -f tmp # malformed env var, warn and revert to default setting
139 ZSTD_CLEVEL=50000000000 $ZSTD -f tmp # numeric value too large, warn and revert to default setting
140 println "test : override ZSTD_CLEVEL with command line option"
141 ZSTD_CLEVEL=12 $ZSTD --fast=3 -f tmp # overridden by command line option
142 println "test : compress to stdout"
143 $ZSTD tmp -c > tmpCompressed
144 $ZSTD tmp --stdout > tmpCompressed # long command format
145 println "test : compress to named file"
147 $ZSTD tmp -o tmpCompressed
148 test -f tmpCompressed # file must be created
149 println "test : -o must be followed by filename (must fail)"
150 $ZSTD tmp -of tmpCompressed && die "-o must be followed by filename "
151 println "test : force write, correct order"
152 $ZSTD tmp -fo tmpCompressed
153 println "test : forgotten argument"
155 $ZSTD tmp2 -fo && die "-o must be followed by filename "
156 println "test : implied stdout when input is stdin"
157 println bob | $ZSTD | $ZSTD -d
158 if [ "$isTerminal" = true ]; then
159 println "test : compressed data to terminal"
160 println bob | $ZSTD && die "should have refused : compressed data to terminal"
161 println "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)"
162 $ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal"
164 println "test : null-length file roundtrip"
165 println -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
166 println "test : ensure small file doesn't add 3-bytes null block"
168 $ZSTD tmp1 -c | wc -c | grep "14"
169 $ZSTD < tmp1 | wc -c | grep "14"
170 println "test : decompress file with wrong suffix (must fail)"
171 $ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
172 $ZSTD -df tmp && die "should have refused : wrong extension"
173 println "test : decompress into stdout"
174 $ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout
175 $ZSTD --decompress tmpCompressed -c > tmpResult
176 $ZSTD --decompress tmpCompressed --stdout > tmpResult
177 println "test : decompress from stdin into stdout"
178 $ZSTD -dc < tmp.zst > $INTOVOID # combine decompression, stdin & stdout
179 $ZSTD -dc - < tmp.zst > $INTOVOID
180 $ZSTD -d < tmp.zst > $INTOVOID # implicit stdout when stdin is used
181 $ZSTD -d - < tmp.zst > $INTOVOID
182 println "test : impose memory limitation (must fail)"
183 $ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
184 $ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
185 $ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
186 $ZSTD -d -f tmp.zst --memlimit-decompress=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
187 println "test : overwrite protection"
188 $ZSTD -q tmp && die "overwrite check failed!"
189 println "test : force overwrite"
192 println "test : overwrite readonly file"
193 rm -f tmpro tmpro.zst
194 println foo > tmpro.zst
197 $ZSTD -q tmpro && die "should have refused to overwrite read-only file"
199 println "test: --no-progress flag"
200 $ZSTD tmpro -c --no-progress | $ZSTD -d -f -o "$INTOVOID" --no-progress
201 $ZSTD tmpro -cv --no-progress | $ZSTD -dv -f -o "$INTOVOID" --no-progress
202 rm -f tmpro tmpro.zst
203 println "test: overwrite input file (must fail)"
204 $ZSTD tmp -fo tmp && die "zstd compression overwrote the input file"
205 $ZSTD tmp.zst -dfo tmp.zst && die "zstd decompression overwrote the input file"
206 println "test: detect that input file does not exist"
207 $ZSTD nothere && die "zstd hasn't detected that input file does not exist"
208 println "test: --[no-]compress-literals"
209 $ZSTD tmp -c --no-compress-literals -1 | $ZSTD -t
210 $ZSTD tmp -c --no-compress-literals --fast=1 | $ZSTD -t
211 $ZSTD tmp -c --no-compress-literals -19 | $ZSTD -t
212 $ZSTD tmp -c --compress-literals -1 | $ZSTD -t
213 $ZSTD tmp -c --compress-literals --fast=1 | $ZSTD -t
214 $ZSTD tmp -c --compress-literals -19 | $ZSTD -t
215 $ZSTD -b --fast=1 -i0e1 tmp --compress-literals
216 $ZSTD -b --fast=1 -i0e1 tmp --no-compress-literals
218 println "test: --exclude-compressed flag"
219 rm -rf precompressedFilterTestDir
220 mkdir -p precompressedFilterTestDir
221 ./datagen $size > precompressedFilterTestDir/input.5
222 ./datagen $size > precompressedFilterTestDir/input.6
223 $ZSTD --exclude-compressed --long --rm -r precompressedFilterTestDir
225 ./datagen $size > precompressedFilterTestDir/input.7
226 ./datagen $size > precompressedFilterTestDir/input.8
227 $ZSTD --exclude-compressed --long --rm -r precompressedFilterTestDir
228 test ! -f precompressedFilterTestDir/input.5.zst.zst
229 test ! -f precompressedFilterTestDir/input.6.zst.zst
230 file1timestamp=`date -r precompressedFilterTestDir/input.5.zst +%s`
231 file2timestamp=`date -r precompressedFilterTestDir/input.7.zst +%s`
232 if [[ $file2timestamp -ge $file1timestamp ]]; then
233 println "Test is successful. input.5.zst is precompressed and therefore not compressed/modified again."
235 println "Test is not successful"
237 #File Extension check.
238 ./datagen $size > precompressedFilterTestDir/input.zstbar
239 $ZSTD --exclude-compressed --long --rm -r precompressedFilterTestDir
240 #ZSTD should compress input.zstbar
241 test -f precompressedFilterTestDir/input.zstbar.zst
242 #Check without the --exclude-compressed flag
243 $ZSTD --long --rm -r precompressedFilterTestDir
244 #Files should get compressed again without the --exclude-compressed flag.
245 test -f precompressedFilterTestDir/input.5.zst.zst
246 test -f precompressedFilterTestDir/input.6.zst.zst
247 println "Test completed"
249 println "test : file removal"
251 test ! -f tmp # tmp should no longer be present
252 $ZSTD -f -d --rm tmp.zst
253 test ! -f tmp.zst # tmp.zst should no longer be present
254 println "test : should quietly not remove non-regular file"
256 $ZSTD tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID"
257 grep -v "Refusing to remove non-regular file" tmplog
259 $ZSTD tmp -f -o "$INTOVOID" 2>&1 | grep -v "Refusing to remove non-regular file"
260 println "test : --rm on stdin"
261 println a | $ZSTD --rm > $INTOVOID # --rm should remain silent
263 $ZSTD -f tmp && die "tmp not present : should have failed"
264 test ! -f tmp.zst # tmp.zst should not be created
265 println "test : -d -f do not delete destination when source is not present"
266 touch tmp # create destination file
267 $ZSTD -d -f tmp.zst && die "attempt to decompress a non existing file"
268 test -f tmp # destination file should still be present
269 println "test : -f do not delete destination when source is not present"
270 rm tmp # erase source file
271 touch tmp.zst # create destination file
272 $ZSTD -f tmp && die "attempt to compress a non existing file"
273 test -f tmp.zst # destination file should still be present
274 rm -rf tmp* # may also erase tmp* directory from previous failed run
276 println "\n===> decompression only tests "
277 head -c 1048576 /dev/zero > tmp
278 $ZSTD -d -o tmp1 "$TESTDIR/golden-decompression/rle-first-block.zst"
282 println "test : compress multiple files"
285 $ZSTD tmp1 tmp2 -o "$INTOVOID" -f
286 $ZSTD tmp1 tmp2 -c | $ZSTD -t
287 $ZSTD tmp1 tmp2 -o tmp.zst
291 $ZSTD -t tmp1.zst tmp2.zst
292 $ZSTD -dc tmp1.zst tmp2.zst
293 $ZSTD tmp1.zst tmp2.zst -o "$INTOVOID" -f
294 $ZSTD -d tmp1.zst tmp2.zst -o tmp
296 $ZSTD tmp1 tmp2 -f -o tmpexists
297 $ZSTD tmp1 tmp2 -o tmpexists && die "should have refused to overwrite"
299 if [ "$?" -eq 139 ]; then
300 die "should not have segfaulted"
304 println "test : compress multiple files into an output directory, --output-dir-flat"
306 mkdir tmpInputTestDir
307 mkdir tmpInputTestDir/we
308 mkdir tmpInputTestDir/we/must
309 mkdir tmpInputTestDir/we/must/go
310 mkdir tmpInputTestDir/we/must/go/deeper
311 println cool > tmpInputTestDir/we/must/go/deeper/tmp2
313 $ZSTD tmp1 tmpInputTestDir/we/must/go/deeper/tmp2 --output-dir-flat tmpOutDir
314 test -f tmpOutDir/tmp1.zst
315 test -f tmpOutDir/tmp2.zst
316 println "test : decompress multiple files into an output directory, --output-dir-flat"
317 mkdir tmpOutDirDecomp
318 $ZSTD tmpOutDir -r -d --output-dir-flat tmpOutDirDecomp
319 test -f tmpOutDirDecomp/tmp2
320 test -f tmpOutDirDecomp/tmp1
321 rm -f tmpOutDirDecomp/*
322 $ZSTD tmpOutDir -r -d --output-dir-flat=tmpOutDirDecomp
323 test -f tmpOutDirDecomp/tmp2
324 test -f tmpOutDirDecomp/tmp1
327 println "\n===> Advanced compression parameters "
328 println "Hello world!" | $ZSTD --zstd=windowLog=21, - -o tmp.zst && die "wrong parameters not detected!"
329 println "Hello world!" | $ZSTD --zstd=windowLo=21 - -o tmp.zst && die "wrong parameters not detected!"
330 println "Hello world!" | $ZSTD --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!"
331 println "Hello world!" | $ZSTD --zstd=strategy=10 - -o tmp.zst && die "parameter out of bound not detected!" # > btultra2 : does not exist
332 test ! -f tmp.zst # tmp.zst should not be created
334 roundTripTest -g512K " --zstd=mml=3,tlen=48,strat=6"
335 roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
336 roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,minMatch=3,targetLength=48,strategy=6"
337 roundTripTest -g512K " --single-thread --long --zstd=ldmHashLog=20,ldmMinMatch=64,ldmBucketSizeLog=1,ldmHashRateLog=7"
338 roundTripTest -g512K " --single-thread --long --zstd=lhlog=20,lmml=64,lblog=1,lhrlog=7"
339 roundTripTest -g64K "19 --zstd=strat=9" # btultra2
342 println "\n===> Pass-Through mode "
343 println "Hello world 1!" | $ZSTD -df
344 println "Hello world 2!" | $ZSTD -dcf
345 println "Hello world 3!" > tmp1
349 println "\n===> frame concatenation "
351 println "hello " > hello.tmp
352 println "world!" > world.tmp
353 cat hello.tmp world.tmp > helloworld.tmp
354 $ZSTD -c hello.tmp > hello.zstd
355 $ZSTD -c world.tmp > world.zstd
356 cat hello.zstd world.zstd > helloworld.zstd
357 $ZSTD -dc helloworld.zstd > result.tmp
359 $DIFF helloworld.tmp result.tmp
360 println "frame concatenation without checksum"
361 $ZSTD -c hello.tmp > hello.zstd --no-check
362 $ZSTD -c world.tmp > world.zstd --no-check
363 cat hello.zstd world.zstd > helloworld.zstd
364 $ZSTD -dc helloworld.zstd > result.tmp
365 $DIFF helloworld.tmp result.tmp
366 println "testing zstdcat symlink"
368 ./zstdcat helloworld.zstd > result.tmp
369 $DIFF helloworld.tmp result.tmp
370 ln -s helloworld.zstd helloworld.link.zstd
371 ./zstdcat helloworld.link.zstd > result.tmp
372 $DIFF helloworld.tmp result.tmp
375 println "testing zcat symlink"
377 ./zcat helloworld.zstd > result.tmp
378 $DIFF helloworld.tmp result.tmp
379 ./zcat helloworld.link.zstd > result.tmp
380 $DIFF helloworld.tmp result.tmp
383 println "frame concatenation tests completed"
386 if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] && [ "$UNAME" != "OpenBSD" ] ; then
387 println "\n**** flush write error test **** "
389 println "println foo | $ZSTD > /dev/full"
390 println foo | $ZSTD > /dev/full && die "write error not detected!"
391 println "println foo | $ZSTD | $ZSTD -d > /dev/full"
392 println foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
397 if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
399 println "\n===> symbolic link test "
401 rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
402 println "hello world" > hello.tmp
403 ln -s hello.tmp world.tmp
404 ln -s hello.tmp world2.tmp
405 $ZSTD world.tmp hello.tmp || true
406 test -f hello.tmp.zst # regular file should have been compressed!
407 test ! -f world.tmp.zst # symbolic link should not have been compressed!
408 $ZSTD world.tmp || true
409 test ! -f world.tmp.zst # symbolic link should not have been compressed!
410 $ZSTD world.tmp world2.tmp || true
411 test ! -f world.tmp.zst # symbolic link should not have been compressed!
412 test ! -f world2.tmp.zst # symbolic link should not have been compressed!
413 $ZSTD world.tmp hello.tmp -f
414 test -f world.tmp.zst # symbolic link should have been compressed with --force
415 rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
420 println "\n===> test sparse file support "
422 ./datagen -g5M -P100 > tmpSparse
423 $ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
424 $DIFF -s tmpSparse tmpSparseRegen
425 $ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
426 $DIFF -s tmpSparse tmpOutSparse
427 $ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
428 $DIFF -s tmpSparse tmpOutNoSparse
429 ls -ls tmpSparse* # look at file size and block size on disk
430 ./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks)
431 ./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
432 ls -ls tmpSparseOdd # look at file size and block size on disk
433 println "\n Sparse Compatibility with Console :"
434 println "Hello World 1 !" | $ZSTD | $ZSTD -d -c
435 println "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
436 println "\n Sparse Compatibility with Append :"
437 ./datagen -P100 -g1M > tmpSparse1M
438 cat tmpSparse1M tmpSparse1M > tmpSparse2M
439 $ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
440 $ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
441 $ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
442 ls -ls tmpSparse* # look at file size and block size on disk
443 $DIFF tmpSparse2M tmpSparseRegenerated
447 println "\n===> multiple files tests "
449 ./datagen -s1 > tmp1 2> $INTOVOID
450 ./datagen -s2 -g100K > tmp2 2> $INTOVOID
451 ./datagen -s3 -g1M > tmp3 2> $INTOVOID
452 println "compress tmp* : "
456 println "decompress tmp* : "
459 println "compress tmp* into stdout > tmpall : "
460 $ZSTD -c tmp1 tmp2 tmp3 > tmpall
461 ls -ls tmp* # check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
462 println "decompress tmpall* into stdout > tmpdec : "
464 $ZSTD -dc tmpall* > tmpdec
465 ls -ls tmp* # check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3))
466 println "compress multiple files including a missing one (notHere) : "
467 $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
469 println "\n===> stream-size mode"
471 ./datagen -g11000 > tmp
472 println "test : basic file compression vs sized streaming compression"
473 file_size=$($ZSTD -14 -f tmp -o tmp.zst && wc -c < tmp.zst)
474 stream_size=$(cat tmp | $ZSTD -14 --stream-size=11000 | wc -c)
475 if [ "$stream_size" -gt "$file_size" ]; then
476 die "hinted compression larger than expected"
478 println "test : sized streaming compression and decompression"
479 cat tmp | $ZSTD -14 -f tmp -o --stream-size=11000 tmp.zst
480 $ZSTD -df tmp.zst -o tmp_decompress
481 cmp tmp tmp_decompress || die "difference between original and decompressed file"
482 println "test : incorrect stream size"
483 cat tmp | $ZSTD -14 -f -o tmp.zst --stream-size=11001 && die "should fail with incorrect stream size"
486 println "\n===> size-hint mode"
488 ./datagen -g11000 > tmp
489 ./datagen -g11000 > tmp2
491 println "test : basic file compression vs hinted streaming compression"
492 file_size=$($ZSTD -14 -f tmp -o tmp.zst && wc -c < tmp.zst)
493 stream_size=$(cat tmp | $ZSTD -14 --size-hint=11000 | wc -c)
494 if [ "$stream_size" -ge "$file_size" ]; then
495 die "hinted compression larger than expected"
497 println "test : hinted streaming compression and decompression"
498 cat tmp | $ZSTD -14 -f -o tmp.zst --size-hint=11000
499 $ZSTD -df tmp.zst -o tmp_decompress
500 cmp tmp tmp_decompress || die "difference between original and decompressed file"
501 println "test : hinted streaming compression with dictionary"
502 cat tmp | $ZSTD -14 -f -D tmpDict --size-hint=11000 | $ZSTD -t -D tmpDict
503 println "test : multiple file compression with hints and dictionary"
504 $ZSTD -14 -f -D tmpDict --size-hint=11000 tmp tmp2
505 $ZSTD -14 -f -o tmp1_.zst -D tmpDict --size-hint=11000 tmp
506 $ZSTD -14 -f -o tmp2_.zst -D tmpDict --size-hint=11000 tmp2
507 cmp tmp.zst tmp1_.zst || die "first file's output differs"
508 cmp tmp2.zst tmp2_.zst || die "second file's output differs"
509 println "test : incorrect hinted stream sizes"
510 cat tmp | $ZSTD -14 -f --size-hint=11050 | $ZSTD -t # slightly too high
511 cat tmp | $ZSTD -14 -f --size-hint=10950 | $ZSTD -t # slightly too low
512 cat tmp | $ZSTD -14 -f --size-hint=22000 | $ZSTD -t # considerably too high
513 cat tmp | $ZSTD -14 -f --size-hint=5500 | $ZSTD -t # considerably too low
516 println "\n===> dictionary tests "
518 println "- test with raw dict (content only) "
520 ./datagen -g1M | $MD5SUM > tmp1
521 ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2
523 println "- Create first dictionary "
524 TESTFILE="$PRGDIR"/zstdcli.c
525 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
527 println "- Test dictionary compression with tmpDict as an input file and dictionary"
528 $ZSTD -f tmpDict -D tmpDict && die "compression error not detected!"
529 println "- Dictionary compression roundtrip"
530 $ZSTD -f tmp -D tmpDict
531 $ZSTD -d tmp.zst -D tmpDict -fo result
532 $DIFF "$TESTFILE" result
533 println "- Dictionary compression with btlazy2 strategy"
534 $ZSTD -f tmp -D tmpDict --zstd=strategy=6
535 $ZSTD -d tmp.zst -D tmpDict -fo result
536 $DIFF "$TESTFILE" result
539 println "- Test dictionary compression with multithreading "
540 ./datagen -g5M | $ZSTD -T2 -D tmpDict | $ZSTD -t -D tmpDict # fails with v1.3.2
542 println "- Create second (different) dictionary "
543 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
544 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
545 println "- Create dictionary with short dictID"
546 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
547 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
548 println "- Create dictionary with wrong dictID parameter order (must fail)"
549 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
550 println "- Create dictionary with size limit"
551 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K -v
552 println "- Create dictionary with small size limit"
553 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict3 --maxdict=1K -v
554 println "- Create dictionary with wrong parameter order (must fail)"
555 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict3 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
556 println "- Compress without dictID"
557 $ZSTD -f tmp -D tmpDict1 --no-dictID
558 $ZSTD -d tmp.zst -D tmpDict -fo result
559 $DIFF "$TESTFILE" result
560 println "- Compress with wrong argument order (must fail)"
561 $ZSTD tmp -Df tmpDict1 -c > $INTOVOID && die "-D must be followed by dictionary name "
562 println "- Compress multiple files with dictionary"
565 cp "$TESTDIR"/*.c dirTestDict
566 cp "$PRGDIR"/*.c dirTestDict
567 cp "$PRGDIR"/*.h dirTestDict
568 $MD5SUM dirTestDict/* > tmph1
569 $ZSTD -f --rm dirTestDict/* -D tmpDictC
570 $ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
572 Darwin) println "md5sum -c not supported on OS-X : test skipped" ;; # not compatible with OS-X's md5
573 *) $MD5SUM -c tmph1 ;;
576 println "- dictionary builder on bogus input"
577 println "Hello World" > tmp
578 $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : not enough input source"
579 ./datagen -P0 -g10M > tmp
580 $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise"
581 println "- Test -o before --train"
582 rm -f tmpDict dictionary
583 $ZSTD -o tmpDict --train "$TESTDIR"/*.c "$PRGDIR"/*.c
585 $ZSTD --train "$TESTDIR"/*.c "$PRGDIR"/*.c
587 println "- Test dictionary training fails"
588 echo "000000000000000000000000000000000" > tmpz
589 $ZSTD --train tmpz tmpz tmpz tmpz tmpz tmpz tmpz tmpz tmpz && die "Dictionary training should fail : source is all zeros"
592 $ZSTD --train -T0 tmpz tmpz tmpz tmpz tmpz tmpz tmpz tmpz tmpz && die "Dictionary training should fail : source is all zeros"
593 println "- Create dictionary with multithreading enabled"
594 $ZSTD --train -T0 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
599 println "\n===> fastCover dictionary builder : advanced options "
600 TESTFILE="$PRGDIR"/zstdcli.c
602 println "- Create first dictionary"
603 $ZSTD --train-fastcover=k=46,d=8,f=15,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
605 $ZSTD -f tmp -D tmpDict
606 $ZSTD -d tmp.zst -D tmpDict -fo result
607 $DIFF "$TESTFILE" result
608 println "- Create second (different) dictionary"
609 $ZSTD --train-fastcover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
610 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
611 $ZSTD --train-fastcover=k=56,d=8 && die "Create dictionary without input file"
612 println "- Create dictionary with short dictID"
613 $ZSTD --train-fastcover=k=46,d=8,f=15,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
614 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
615 println "- Create dictionaries with shrink-dict flag enabled"
616 $ZSTD --train-fastcover=steps=1,shrink "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict
617 $ZSTD --train-fastcover=steps=1,shrink=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict1
618 $ZSTD --train-fastcover=steps=1,shrink=5 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict2
619 println "- Create dictionary with size limit"
620 $ZSTD --train-fastcover=steps=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K
621 println "- Create dictionary using all samples for both training and testing"
622 $ZSTD --train-fastcover=k=56,d=8,split=100 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
623 println "- Create dictionary using f=16"
624 $ZSTD --train-fastcover=k=56,d=8,f=16 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
625 $ZSTD --train-fastcover=k=56,d=8,accel=15 -r "$TESTDIR"/*.c "$PRGDIR"/*.c && die "Created dictionary using accel=15"
626 println "- Create dictionary using accel=2"
627 $ZSTD --train-fastcover=k=56,d=8,accel=2 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
628 println "- Create dictionary using accel=10"
629 $ZSTD --train-fastcover=k=56,d=8,accel=10 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
630 println "- Create dictionary with multithreading"
631 $ZSTD --train-fastcover -T4 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
632 println "- Test -o before --train-fastcover"
633 rm -f tmpDict dictionary
634 $ZSTD -o tmpDict --train-fastcover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c
636 $ZSTD --train-fastcover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c
641 println "\n===> legacy dictionary builder "
643 TESTFILE="$PRGDIR"/zstdcli.c
645 println "- Create first dictionary"
646 $ZSTD --train-legacy=selectivity=8 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
648 $ZSTD -f tmp -D tmpDict
649 $ZSTD -d tmp.zst -D tmpDict -fo result
650 $DIFF "$TESTFILE" result
651 $ZSTD --train-legacy=s=8 && die "Create dictionary without input files (should error)"
652 println "- Create second (different) dictionary"
653 $ZSTD --train-legacy=s=5 "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
654 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
655 println "- Create dictionary with short dictID"
656 $ZSTD --train-legacy -s5 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
657 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
658 println "- Create dictionary with size limit"
659 $ZSTD --train-legacy -s9 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K
660 println "- Test -o before --train-legacy"
661 rm -f tmpDict dictionary
662 $ZSTD -o tmpDict --train-legacy "$TESTDIR"/*.c "$PRGDIR"/*.c
664 $ZSTD --train-legacy "$TESTDIR"/*.c "$PRGDIR"/*.c
669 println "\n===> integrity tests "
671 println "test one file (tmp1.zst) "
675 $ZSTD --test tmp1.zst
676 println "test multiple files (*.zst) "
678 println "test bad files (*) "
679 $ZSTD -t ./* && die "bad files not detected !"
680 $ZSTD -t tmp1 && die "bad file not detected !"
682 $ZSTD -t tmp2.zst && die "bad file not detected !"
684 $ZSTD -t tmp3 && die "bad file not detected !" # detects 0-sized files as bad
685 println "test --rm and --test combined "
686 $ZSTD -t --rm tmp1.zst
687 test -f tmp1.zst # check file is still present
688 split -b16384 tmp1.zst tmpSplit.
689 $ZSTD -t tmpSplit.* && die "bad file not detected !"
690 ./datagen | $ZSTD -c | $ZSTD -t
694 println "\n===> golden files tests "
696 $ZSTD -t -r "$TESTDIR/golden-compression"
697 $ZSTD -c -r "$TESTDIR/golden-compression" | $ZSTD -t
700 println "\n===> benchmark mode tests "
702 println "bench one file"
705 println "bench multiple levels"
707 println "bench negative level"
708 $ZSTD -bi0 --fast tmp1
709 println "with recursive and quiet modes"
711 println "benchmark decompression only"
713 $ZSTD -b -d -i0 tmp1.zst
715 println "\n===> zstd compatibility tests "
719 $ZSTD --format=zstd -f tmp
722 println "\n===> gzip compatibility tests "
725 $ZSTD --format=gzip -V || GZIPMODE=0
726 if [ $GZIPMODE -eq 1 ]; then
727 println "gzip support detected"
730 if [ $GZIPEXE -eq 1 ]; then
732 $ZSTD --format=gzip -f tmp
735 $ZSTD -d -f -v tmp.gz
738 println "gzip binary not detected"
741 println "gzip mode not supported"
745 println "\n===> gzip frame tests "
747 if [ $GZIPMODE -eq 1 ]; then
749 $ZSTD -f --format=gzip tmp
751 cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp
752 truncateLastByte tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
755 println "gzip mode not supported"
758 if [ $GZIPMODE -eq 1 ]; then
761 $ZSTD --format=gzip --format=zstd -f tmp
765 println "\n===> xz compatibility tests "
768 $ZSTD --format=xz -V || LZMAMODE=0
769 if [ $LZMAMODE -eq 1 ]; then
770 println "xz support detected"
772 xz -Q -V && lzma -Q -V || XZEXE=0
773 if [ $XZEXE -eq 1 ]; then
774 println "Testing zstd xz and lzma support"
776 $ZSTD --format=lzma -f tmp
777 $ZSTD --format=xz -f tmp
781 lzma -Q -f -k --lzma1 tmp
782 $ZSTD -d -f -v tmp.xz
783 $ZSTD -d -f -v tmp.lzma
785 println "Creating symlinks"
790 println "Testing xz and lzma symlinks"
796 println "Testing unxz and unlzma symlinks"
801 rm xz unxz lzma unlzma
804 println "xz binary not detected"
807 println "xz mode not supported"
811 println "\n===> xz frame tests "
813 if [ $LZMAMODE -eq 1 ]; then
815 $ZSTD -f --format=xz tmp
816 $ZSTD -f --format=lzma tmp
818 cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp
819 truncateLastByte tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
820 truncateLastByte tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
823 println "xz mode not supported"
826 println "\n===> lz4 compatibility tests "
829 $ZSTD --format=lz4 -V || LZ4MODE=0
830 if [ $LZ4MODE -eq 1 ]; then
831 println "lz4 support detected"
834 if [ $LZ4EXE -eq 1 ]; then
836 $ZSTD --format=lz4 -f tmp
839 $ZSTD -d -f -v tmp.lz4
842 println "lz4 binary not detected"
845 println "lz4 mode not supported"
849 println "\n===> lz4 frame tests "
851 if [ $LZ4MODE -eq 1 ]; then
853 $ZSTD -f --format=lz4 tmp
855 cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp
856 truncateLastByte tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
859 println "lz4 mode not supported"
862 println "\n===> suffix list test"
864 ! $ZSTD -d tmp.abc 2> tmplg
866 if [ $GZIPMODE -ne 1 ]; then
867 grep ".gz" tmplg > $INTOVOID && die "Unsupported suffix listed"
870 if [ $LZMAMODE -ne 1 ]; then
871 grep ".lzma" tmplg > $INTOVOID && die "Unsupported suffix listed"
872 grep ".xz" tmplg > $INTOVOID && die "Unsupported suffix listed"
875 if [ $LZ4MODE -ne 1 ]; then
876 grep ".lz4" tmplg > $INTOVOID && die "Unsupported suffix listed"
879 println "\n===> tar extension tests "
881 rm -f tmp tmp.tar tmp.tzst tmp.tgz tmp.txz tmp.tlz4
885 $ZSTD tmp.tar -o tmp.tzst
888 [ -e tmp.tar ] || die ".tzst failed to decompress to .tar!"
889 rm -f tmp.tar tmp.tzst
891 if [ $GZIPMODE -eq 1 ]; then
894 [ -e tmp.tar ] || die ".tgz failed to decompress to .tar!"
895 rm -f tmp.tar tmp.tgz
898 if [ $LZMAMODE -eq 1 ]; then
899 tar c tmp | $ZSTD --format=xz > tmp.txz
901 [ -e tmp.tar ] || die ".txz failed to decompress to .tar!"
902 rm -f tmp.tar tmp.txz
905 if [ $LZ4MODE -eq 1 ]; then
906 tar c tmp | $ZSTD --format=lz4 > tmp.tlz4
908 [ -e tmp.tar ] || die ".tlz4 failed to decompress to .tar!"
909 rm -f tmp.tar tmp.tlz4
912 touch tmp.t tmp.tz tmp.tzs
919 println "\n===> zstd round-trip tests "
922 roundTripTest -g15K # TableID==3
923 roundTripTest -g127K # TableID==2
924 roundTripTest -g255K # TableID==1
925 roundTripTest -g522K # TableID==0
926 roundTripTest -g519K 6 # greedy, hash chain
927 roundTripTest -g517K 16 # btlazy2
928 roundTripTest -g516K 19 # btopt
930 fileRoundTripTest -g500K
932 println "\n===> zstd long distance matching round-trip tests "
933 roundTripTest -g0 "2 --single-thread --long"
934 roundTripTest -g1000K "1 --single-thread --long"
935 roundTripTest -g517K "6 --single-thread --long"
936 roundTripTest -g516K "16 --single-thread --long"
937 roundTripTest -g518K "19 --single-thread --long"
938 fileRoundTripTest -g5M "3 --single-thread --long"
941 roundTripTest -g96K "5 --single-thread"
944 println "\n===> zstdmt round-trip tests "
945 roundTripTest -g4M "1 -T0"
946 roundTripTest -g8M "3 -T2"
947 roundTripTest -g8000K "2 --threads=2"
948 fileRoundTripTest -g4M "19 -T2 -B1M"
950 println "\n===> zstdmt long distance matching round-trip tests "
951 roundTripTest -g8M "3 --long=24 -T2"
953 println "\n===> ovLog tests "
954 ./datagen -g2MB > tmp
955 refSize=$($ZSTD tmp -6 -c --zstd=wlog=18 | wc -c)
956 ov9Size=$($ZSTD tmp -6 -c --zstd=wlog=18,ovlog=9 | wc -c)
957 ov1Size=$($ZSTD tmp -6 -c --zstd=wlog=18,ovlog=1 | wc -c)
958 if [ "$refSize" -eq "$ov9Size" ]; then
959 echo ov9Size should be different from refSize
962 if [ "$refSize" -eq "$ov1Size" ]; then
963 echo ov1Size should be different from refSize
966 if [ "$ov9Size" -ge "$ov1Size" ]; then
967 echo ov9Size="$ov9Size" should be smaller than ov1Size="$ov1Size"
972 println "\n===> no multithreading, skipping zstdmt tests "
977 println "\n===> zstd --list/-l single frame tests "
983 $ZSTD -lv ./*.zst | grep "Decompressed Size:" # check that decompressed size is present in header
985 $ZSTD --list -v ./*.zst
987 println "\n===> zstd --list/-l multiple frame tests "
988 cat tmp1.zst tmp2.zst > tmp12.zst
989 cat tmp12.zst tmp3.zst > tmp123.zst
993 println "\n===> zstd --list/-l error detection tests "
994 $ZSTD -l tmp1 tmp1.zst && die "-l must fail on non-zstd file"
995 $ZSTD --list tmp* && die "-l must fail on non-zstd file"
996 $ZSTD -lv tmp1* && die "-l must fail on non-zstd file"
997 $ZSTD --list -v tmp2 tmp12.zst && die "-l must fail on non-zstd file"
999 println "test : detect truncated compressed file "
1000 TEST_DATA_FILE=truncatable-input.txt
1001 FULL_COMPRESSED_FILE=${TEST_DATA_FILE}.zst
1002 TRUNCATED_COMPRESSED_FILE=truncated-input.txt.zst
1003 ./datagen -g50000 > $TEST_DATA_FILE
1004 $ZSTD -f $TEST_DATA_FILE -o $FULL_COMPRESSED_FILE
1005 dd bs=1 count=100 if=$FULL_COMPRESSED_FILE of=$TRUNCATED_COMPRESSED_FILE
1006 $ZSTD --list $TRUNCATED_COMPRESSED_FILE && die "-l must fail on truncated file"
1009 rm $FULL_COMPRESSED_FILE
1010 rm $TRUNCATED_COMPRESSED_FILE
1012 println "\n===> zstd --list/-l errors when presented with stdin / no files"
1013 $ZSTD -l && die "-l must fail on empty list of files"
1014 $ZSTD -l - && die "-l does not work on stdin"
1015 $ZSTD -l < tmp1.zst && die "-l does not work on stdin"
1016 $ZSTD -l - < tmp1.zst && die "-l does not work on stdin"
1017 $ZSTD -l - tmp1.zst && die "-l does not work on stdin"
1018 $ZSTD -l - tmp1.zst < tmp1.zst && die "-l does not work on stdin"
1019 $ZSTD -l tmp1.zst < tmp2.zst # this will check tmp1.zst, but not tmp2.zst, which is not an error : zstd simply doesn't read stdin in this case. It must not error just because stdin is not a tty
1021 println "\n===> zstd --list/-l test with null files "
1022 ./datagen -g0 > tmp5
1025 $ZSTD -l tmp5* && die "-l must fail on non-zstd file"
1026 $ZSTD -lv tmp5.zst | grep "Decompressed Size: 0.00 KB (0 B)" # check that 0 size is present in header
1027 $ZSTD -lv tmp5* && die "-l must fail on non-zstd file"
1029 println "\n===> zstd --list/-l test with no content size field "
1030 ./datagen -g513K | $ZSTD > tmp6.zst
1032 $ZSTD -lv tmp6.zst | grep "Decompressed Size:" && die "Field :Decompressed Size: should not be available in this compressed file"
1034 println "\n===> zstd --list/-l test with no checksum "
1035 $ZSTD -f --no-check tmp1
1042 println "\n===> zstd long distance matching tests "
1043 roundTripTest -g0 " --single-thread --long"
1044 roundTripTest -g9M "2 --single-thread --long"
1045 # Test parameter parsing
1046 roundTripTest -g1M -P50 "1 --single-thread --long=29" " --memory=512MB"
1047 roundTripTest -g1M -P50 "1 --single-thread --long=29 --zstd=wlog=28" " --memory=256MB"
1048 roundTripTest -g1M -P50 "1 --single-thread --long=29" " --long=28 --memory=512MB"
1049 roundTripTest -g1M -P50 "1 --single-thread --long=29" " --zstd=wlog=28 --memory=512MB"
1054 println "\n===> adaptive mode "
1055 roundTripTest -g270000000 " --adapt"
1056 roundTripTest -g27000000 " --adapt=min=1,max=4"
1057 println "===> test: --adapt must fail on incoherent bounds "
1059 $ZSTD -f -vv --adapt=min=10,max=9 tmp && die "--adapt must fail on incoherent bounds"
1061 println "\n===> rsyncable mode "
1062 roundTripTest -g10M " --rsyncable"
1063 roundTripTest -g10M " --rsyncable -B100K"
1064 println "===> test: --rsyncable must fail with --single-thread"
1065 $ZSTD -f -vv --rsyncable --single-thread tmp && die "--rsyncable must fail with --single-thread"
1069 if [ "$1" != "--test-large-data" ]; then
1070 println "Skipping large data tests"
1075 #############################################################################
1077 println "\n===> large files tests "
1079 roundTripTest -g270000000 1
1080 roundTripTest -g250000000 2
1081 roundTripTest -g230000000 3
1083 roundTripTest -g140000000 -P60 4
1084 roundTripTest -g130000000 -P62 5
1085 roundTripTest -g120000000 -P65 6
1087 roundTripTest -g70000000 -P70 7
1088 roundTripTest -g60000000 -P71 8
1089 roundTripTest -g50000000 -P73 9
1091 roundTripTest -g35000000 -P75 10
1092 roundTripTest -g30000000 -P76 11
1093 roundTripTest -g25000000 -P78 12
1095 roundTripTest -g18000013 -P80 13
1096 roundTripTest -g18000014 -P80 14
1097 roundTripTest -g18000015 -P81 15
1098 roundTripTest -g18000016 -P84 16
1099 roundTripTest -g18000017 -P88 17
1100 roundTripTest -g18000018 -P94 18
1101 roundTripTest -g18000019 -P96 19
1103 roundTripTest -g5000000000 -P99 1
1104 roundTripTest -g1700000000 -P0 "1 --zstd=strategy=6" # ensure btlazy2 can survive an overflow rescale
1106 fileRoundTripTest -g4193M -P99 1
1109 println "\n===> zstd long, long distance matching round-trip tests "
1110 roundTripTest -g270000000 "1 --single-thread --long"
1111 roundTripTest -g130000000 -P60 "5 --single-thread --long"
1112 roundTripTest -g35000000 -P70 "8 --single-thread --long"
1113 roundTripTest -g18000001 -P80 "18 --single-thread --long"
1114 # Test large window logs
1115 roundTripTest -g700M -P50 "1 --single-thread --long=29"
1116 roundTripTest -g600M -P50 "1 --single-thread --long --zstd=wlog=29,clog=28"
1121 println "\n===> zstdmt long round-trip tests "
1122 roundTripTest -g80000000 -P99 "19 -T2" " "
1123 roundTripTest -g5000000000 -P99 "1 -T2" " "
1124 roundTripTest -g500000000 -P97 "1 -T999" " "
1125 fileRoundTripTest -g4103M -P98 " -T0" " "
1126 roundTripTest -g400000000 -P97 "1 --long=24 -T2" " "
1127 # Exposes the bug in https://github.com/facebook/zstd/pull/1678
1128 # This test fails on 4 different travis builds at the time of writing
1129 # because it needs to allocate 8 GB of memory.
1130 # roundTripTest -g10G -P99 "1 -T1 --long=31 --zstd=clog=27 --fast=1000"
1132 println "\n**** no multithreading, skipping zstdmt tests **** "
1136 println "\n===> cover dictionary builder : advanced options "
1138 TESTFILE="$PRGDIR"/zstdcli.c
1140 println "- Create first dictionary"
1141 $ZSTD --train-cover=k=46,d=8,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
1143 $ZSTD -f tmp -D tmpDict
1144 $ZSTD -d tmp.zst -D tmpDict -fo result
1145 $DIFF "$TESTFILE" result
1146 $ZSTD --train-cover=k=56,d=8 && die "Create dictionary without input file (should error)"
1147 println "- Create second (different) dictionary"
1148 $ZSTD --train-cover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
1149 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
1150 println "- Create dictionary using shrink-dict flag"
1151 $ZSTD --train-cover=steps=256,shrink "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict
1152 $ZSTD --train-cover=steps=256,shrink=1 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict1
1153 $ZSTD --train-cover=steps=256,shrink=5 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict2
1154 println "- Create dictionary with short dictID"
1155 $ZSTD --train-cover=k=46,d=8,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
1156 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
1157 println "- Create dictionary with size limit"
1158 $ZSTD --train-cover=steps=8 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K
1159 println "- Compare size of dictionary from 90% training samples with 80% training samples"
1160 $ZSTD --train-cover=split=90 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1161 $ZSTD --train-cover=split=80 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1162 println "- Create dictionary using all samples for both training and testing"
1163 $ZSTD --train-cover=split=100 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1164 println "- Test -o before --train-cover"
1165 rm -f tmpDict dictionary
1166 $ZSTD -o tmpDict --train-cover "$TESTDIR"/*.c "$PRGDIR"/*.c
1168 $ZSTD --train-cover "$TESTDIR"/*.c "$PRGDIR"/*.c
1170 rm -f tmp* dictionary
1173 if [ "$isWindows" = false ] ; then
1175 println "\n===> zstd fifo named pipe test "
1176 head -c 10 /dev/zero > tmp_original
1178 head -c 10 /dev/zero > named_pipe &
1179 $ZSTD named_pipe -o tmp_compressed
1180 $ZSTD -d -o tmp_decompressed tmp_compressed
1181 $DIFF -s tmp_original tmp_decompressed