]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/playTests.sh
import zstd 1.4.0
[FreeBSD/FreeBSD.git] / tests / playTests.sh
1 #!/bin/sh -e
2
3 die() {
4     $ECHO "$@" 1>&2
5     exit 1
6 }
7
8 roundTripTest() {
9     if [ -n "$3" ]; then
10         cLevel="$3"
11         proba="$2"
12     else
13         cLevel="$2"
14         proba=""
15     fi
16     if [ -n "$4" ]; then
17         dLevel="$4"
18     else
19         dLevel="$cLevel"
20     fi
21
22     rm -f tmp1 tmp2
23     $ECHO "roundTripTest: ./datagen $1 $proba | $ZSTD -v$cLevel | $ZSTD -d$dLevel"
24     ./datagen $1 $proba | $MD5SUM > tmp1
25     ./datagen $1 $proba | $ZSTD --ultra -v$cLevel | $ZSTD -d$dLevel  | $MD5SUM > tmp2
26     $DIFF -q tmp1 tmp2
27 }
28
29 fileRoundTripTest() {
30     if [ -n "$3" ]; then
31         local_c="$3"
32         local_p="$2"
33     else
34         local_c="$2"
35         local_p=""
36     fi
37     if [ -n "$4" ]; then
38         local_d="$4"
39     else
40         local_d="$local_c"
41     fi
42
43     rm -f tmp.zstd tmp.md5.1 tmp.md5.2
44     $ECHO "fileRoundTripTest: ./datagen $1 $local_p > tmp && $ZSTD -v$local_c -c tmp | $ZSTD -d$local_d"
45     ./datagen $1 $local_p > tmp
46     < tmp $MD5SUM > tmp.md5.1
47     $ZSTD --ultra -v$local_c -c tmp | $ZSTD -d$local_d | $MD5SUM > tmp.md5.2
48     $DIFF -q tmp.md5.1 tmp.md5.2
49 }
50
51 truncateLastByte() {
52         dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1"
53 }
54
55 UNAME=$(uname)
56
57 isTerminal=false
58 if [ -t 0 ] && [ -t 1 ]
59 then
60     isTerminal=true
61 fi
62
63 isWindows=false
64 INTOVOID="/dev/null"
65 case "$UNAME" in
66   GNU) DEVDEVICE="/dev/random" ;;
67   *) DEVDEVICE="/dev/zero" ;;
68 esac
69 case "$OS" in
70   Windows*)
71     isWindows=true
72     INTOVOID="NUL"
73     DEVDEVICE="NUL"
74     ;;
75 esac
76
77 case "$UNAME" in
78   Darwin) MD5SUM="md5 -r" ;;
79   FreeBSD) MD5SUM="gmd5sum" ;;
80   OpenBSD) MD5SUM="md5" ;;
81   *) MD5SUM="md5sum" ;;
82 esac
83
84 DIFF="diff"
85 case "$UNAME" in
86   SunOS) DIFF="gdiff" ;;
87 esac
88
89 ECHO="echo -e"
90 case "$UNAME" in
91   Darwin) ECHO="echo" ;;
92 esac
93
94 $ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
95
96 [ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
97
98 if [ -n "$(echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep 'multi-threading is disabled')" ]
99 then
100     hasMT=""
101 else
102     hasMT="true"
103 fi
104
105
106
107 $ECHO "\n===>  simple tests "
108
109 ./datagen > tmp
110 $ECHO "test : basic compression "
111 $ZSTD -f tmp                      # trivial compression case, creates tmp.zst
112 $ECHO "test : basic decompression"
113 $ZSTD -df tmp.zst                 # trivial decompression case (overwrites tmp)
114 $ECHO "test : too large compression level => auto-fix"
115 $ZSTD -99 -f tmp  # too large compression level, automatic sized down
116 $ZSTD -5000000000 -f tmp && die "too large numeric value : must fail"
117 $ECHO "test : --fast aka negative compression levels"
118 $ZSTD --fast -f tmp  # == -1
119 $ZSTD --fast=3 -f tmp  # == -3
120 $ZSTD --fast=200000 -f tmp  # too low compression level, automatic fixed
121 $ZSTD --fast=5000000000 -f tmp && die "too large numeric value : must fail"
122 $ZSTD -c --fast=0 tmp > $INTOVOID && die "--fast must not accept value 0"
123 $ECHO "test : too large numeric argument"
124 $ZSTD --fast=9999999999 -f tmp  && die "should have refused numeric value"
125 $ECHO "test : set compression level with environment variable ZSTD_CLEVEL"
126 ZSTD_CLEVEL=12  $ZSTD -f tmp # positive compression level
127 ZSTD_CLEVEL=-12 $ZSTD -f tmp # negative compression level
128 ZSTD_CLEVEL=+12 $ZSTD -f tmp # valid: verbose '+' sign
129 ZSTD_CLEVEL=    $ZSTD -f tmp # empty env var, warn and revert to default setting
130 ZSTD_CLEVEL=-   $ZSTD -f tmp # malformed env var, warn and revert to default setting
131 ZSTD_CLEVEL=a   $ZSTD -f tmp # malformed env var, warn and revert to default setting
132 ZSTD_CLEVEL=+a  $ZSTD -f tmp # malformed env var, warn and revert to default setting
133 ZSTD_CLEVEL=3a7 $ZSTD -f tmp # malformed env var, warn and revert to default setting
134 ZSTD_CLEVEL=50000000000  $ZSTD -f tmp # numeric value too large, warn and revert to default setting
135 $ECHO "test : override ZSTD_CLEVEL with command line option"
136 ZSTD_CLEVEL=12  $ZSTD --fast=3 -f tmp # overridden by command line option
137 $ECHO "test : compress to stdout"
138 $ZSTD tmp -c > tmpCompressed
139 $ZSTD tmp --stdout > tmpCompressed       # long command format
140 $ECHO "test : compress to named file"
141 rm tmpCompressed
142 $ZSTD tmp -o tmpCompressed
143 test -f tmpCompressed   # file must be created
144 $ECHO "test : -o must be followed by filename (must fail)"
145 $ZSTD tmp -of tmpCompressed && die "-o must be followed by filename "
146 $ECHO "test : force write, correct order"
147 $ZSTD tmp -fo tmpCompressed
148 $ECHO "test : forgotten argument"
149 cp tmp tmp2
150 $ZSTD tmp2 -fo && die "-o must be followed by filename "
151 $ECHO "test : implied stdout when input is stdin"
152 $ECHO bob | $ZSTD | $ZSTD -d
153 if [ "$isTerminal" = true ]; then
154 $ECHO "test : compressed data to terminal"
155 $ECHO bob | $ZSTD && die "should have refused : compressed data to terminal"
156 $ECHO "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)"
157 $ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal"
158 fi
159 $ECHO "test : null-length file roundtrip"
160 $ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
161 $ECHO "test : ensure small file doesn't add 3-bytes null block"
162 ./datagen -g1 > tmp1
163 $ZSTD tmp1 -c | wc -c | grep "14"
164 $ZSTD < tmp1  | wc -c | grep "14"
165 $ECHO "test : decompress file with wrong suffix (must fail)"
166 $ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
167 $ZSTD -df tmp && die "should have refused : wrong extension"
168 $ECHO "test : decompress into stdout"
169 $ZSTD -d tmpCompressed -c > tmpResult    # decompression using stdout
170 $ZSTD --decompress tmpCompressed -c > tmpResult
171 $ZSTD --decompress tmpCompressed --stdout > tmpResult
172 $ECHO "test : decompress from stdin into stdout"
173 $ZSTD -dc   < tmp.zst > $INTOVOID   # combine decompression, stdin & stdout
174 $ZSTD -dc - < tmp.zst > $INTOVOID
175 $ZSTD -d    < tmp.zst > $INTOVOID   # implicit stdout when stdin is used
176 $ZSTD -d  - < tmp.zst > $INTOVOID
177 $ECHO "test : impose memory limitation (must fail)"
178 $ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
179 $ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
180 $ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
181 $ZSTD -d -f tmp.zst --memlimit-decompress=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
182 $ECHO "test : overwrite protection"
183 $ZSTD -q tmp && die "overwrite check failed!"
184 $ECHO "test : force overwrite"
185 $ZSTD -q -f tmp
186 $ZSTD -q --force tmp
187 $ECHO "test : overwrite readonly file"
188 rm -f tmpro tmpro.zst
189 $ECHO foo > tmpro.zst
190 $ECHO foo > tmpro
191 chmod 400 tmpro.zst
192 $ZSTD -q tmpro && die "should have refused to overwrite read-only file"
193 $ZSTD -q -f tmpro
194 $ECHO "test: --no-progress flag"
195 $ZSTD tmpro -c --no-progress | $ZSTD -d -f -o "$INTOVOID" --no-progress
196 $ZSTD tmpro -cv --no-progress | $ZSTD -dv -f -o "$INTOVOID" --no-progress
197 rm -f tmpro tmpro.zst
198 $ECHO "test: overwrite input file (must fail)"
199 $ZSTD tmp -fo tmp && die "zstd compression overwrote the input file"
200 $ZSTD tmp.zst -dfo tmp.zst && die "zstd decompression overwrote the input file"
201 $ECHO "test: detect that input file does not exist"
202 $ZSTD nothere && die "zstd hasn't detected that input file does not exist"
203 $ECHO "test: --[no-]compress-literals"
204 $ZSTD tmp -c --no-compress-literals -1       | $ZSTD -t
205 $ZSTD tmp -c --no-compress-literals --fast=1 | $ZSTD -t
206 $ZSTD tmp -c --no-compress-literals -19      | $ZSTD -t
207 $ZSTD tmp -c --compress-literals    -1       | $ZSTD -t
208 $ZSTD tmp -c --compress-literals    --fast=1 | $ZSTD -t
209 $ZSTD tmp -c --compress-literals    -19      | $ZSTD -t
210 $ZSTD -b --fast=1 -i1e1 tmp --compress-literals
211 $ZSTD -b --fast=1 -i1e1 tmp --no-compress-literals
212
213 $ECHO "test : file removal"
214 $ZSTD -f --rm tmp
215 test ! -f tmp  # tmp should no longer be present
216 $ZSTD -f -d --rm tmp.zst
217 test ! -f tmp.zst   # tmp.zst should no longer be present
218 $ECHO "test : should quietly not remove non-regular file"
219 $ECHO hello > tmp
220 $ZSTD tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID"
221 grep -v "Refusing to remove non-regular file" tmplog
222 rm -f tmplog
223 $ZSTD tmp -f -o "$INTOVOID" 2>&1 | grep -v "Refusing to remove non-regular file"
224 $ECHO "test : --rm on stdin"
225 $ECHO a | $ZSTD --rm > $INTOVOID   # --rm should remain silent
226 rm tmp
227 $ZSTD -f tmp && die "tmp not present : should have failed"
228 test ! -f tmp.zst  # tmp.zst should not be created
229 $ECHO "test : -d -f do not delete destination when source is not present"
230 touch tmp    # create destination file
231 $ZSTD -d -f tmp.zst && die "attempt to decompress a non existing file"
232 test -f tmp  # destination file should still be present
233 $ECHO "test : -f do not delete destination when source is not present"
234 rm tmp         # erase source file
235 touch tmp.zst  # create destination file
236 $ZSTD -f tmp && die "attempt to compress a non existing file"
237 test -f tmp.zst  # destination file should still be present
238 rm tmp*
239
240
241 $ECHO "test : compress multiple files"
242 $ECHO hello > tmp1
243 $ECHO world > tmp2
244 $ZSTD tmp1 tmp2 -o "$INTOVOID" -f
245 $ZSTD tmp1 tmp2 -c | $ZSTD -t
246 $ZSTD tmp1 tmp2 -o tmp.zst
247 test ! -f tmp1.zst
248 test ! -f tmp2.zst
249 $ZSTD tmp1 tmp2
250 $ZSTD -t tmp1.zst tmp2.zst
251 $ZSTD -dc tmp1.zst tmp2.zst
252 $ZSTD tmp1.zst tmp2.zst -o "$INTOVOID" -f
253 $ZSTD -d tmp1.zst tmp2.zst -o tmp
254 touch tmpexists
255 $ZSTD tmp1 tmp2 -f -o tmpexists
256 $ZSTD tmp1 tmp2 -o tmpexists && die "should have refused to overwrite"
257 # Bug: PR #972
258 if [ "$?" -eq 139 ]; then
259   die "should not have segfaulted"
260 fi
261 rm tmp*
262
263
264 $ECHO "\n===>  Advanced compression parameters "
265 $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,      - -o tmp.zst && die "wrong parameters not detected!"
266 $ECHO "Hello world!" | $ZSTD --zstd=windowLo=21        - -o tmp.zst && die "wrong parameters not detected!"
267 $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog  - -o tmp.zst && die "wrong parameters not detected!"
268 $ECHO "Hello world!" | $ZSTD --zstd=strategy=10        - -o tmp.zst && die "parameter out of bound not detected!"  # > btultra2 : does not exist
269 test ! -f tmp.zst  # tmp.zst should not be created
270 roundTripTest -g512K
271 roundTripTest -g512K " --zstd=mml=3,tlen=48,strat=6"
272 roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
273 roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,minMatch=3,targetLength=48,strategy=6"
274 roundTripTest -g512K " --single-thread --long --zstd=ldmHashLog=20,ldmMinMatch=64,ldmBucketSizeLog=1,ldmHashRateLog=7"
275 roundTripTest -g512K " --single-thread --long --zstd=lhlog=20,lmml=64,lblog=1,lhrlog=7"
276 roundTripTest -g64K  "19 --zstd=strat=9"   # btultra2
277
278
279 $ECHO "\n===>  Pass-Through mode "
280 $ECHO "Hello world 1!" | $ZSTD -df
281 $ECHO "Hello world 2!" | $ZSTD -dcf
282 $ECHO "Hello world 3!" > tmp1
283 $ZSTD -dcf tmp1
284
285
286 $ECHO "\n===>  frame concatenation "
287
288 $ECHO "hello " > hello.tmp
289 $ECHO "world!" > world.tmp
290 cat hello.tmp world.tmp > helloworld.tmp
291 $ZSTD -c hello.tmp > hello.zstd
292 $ZSTD -c world.tmp > world.zstd
293 cat hello.zstd world.zstd > helloworld.zstd
294 $ZSTD -dc helloworld.zstd > result.tmp
295 cat result.tmp
296 $DIFF helloworld.tmp result.tmp
297 $ECHO "frame concatenation without checksum"
298 $ZSTD -c hello.tmp > hello.zstd --no-check
299 $ZSTD -c world.tmp > world.zstd --no-check
300 cat hello.zstd world.zstd > helloworld.zstd
301 $ZSTD -dc helloworld.zstd > result.tmp
302 $DIFF helloworld.tmp result.tmp
303 $ECHO "testing zstdcat symlink"
304 ln -sf $ZSTD zstdcat
305 ./zstdcat helloworld.zstd > result.tmp
306 $DIFF helloworld.tmp result.tmp
307 rm zstdcat
308 rm result.tmp
309 $ECHO "testing zcat symlink"
310 ln -sf $ZSTD zcat
311 ./zcat helloworld.zstd > result.tmp
312 $DIFF helloworld.tmp result.tmp
313 rm zcat
314 rm ./*.tmp ./*.zstd
315 $ECHO "frame concatenation tests completed"
316
317
318 if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] && [ "$UNAME" != "OpenBSD" ] ; then
319 $ECHO "\n**** flush write error test **** "
320
321 $ECHO "$ECHO foo | $ZSTD > /dev/full"
322 $ECHO foo | $ZSTD > /dev/full && die "write error not detected!"
323 $ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full"
324 $ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
325
326 fi
327
328
329 if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
330
331 $ECHO "\n===>  symbolic link test "
332
333 rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
334 $ECHO "hello world" > hello.tmp
335 ln -s hello.tmp world.tmp
336 ln -s hello.tmp world2.tmp
337 $ZSTD world.tmp hello.tmp || true
338 test -f hello.tmp.zst  # regular file should have been compressed!
339 test ! -f world.tmp.zst  # symbolic link should not have been compressed!
340 $ZSTD world.tmp || true
341 test ! -f world.tmp.zst  # symbolic link should not have been compressed!
342 $ZSTD world.tmp world2.tmp || true
343 test ! -f world.tmp.zst  # symbolic link should not have been compressed!
344 test ! -f world2.tmp.zst  # symbolic link should not have been compressed!
345 $ZSTD world.tmp hello.tmp -f
346 test -f world.tmp.zst  # symbolic link should have been compressed with --force
347 rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
348
349 fi
350
351
352 $ECHO "\n===>  test sparse file support "
353
354 ./datagen -g5M  -P100 > tmpSparse
355 $ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
356 $DIFF -s tmpSparse tmpSparseRegen
357 $ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
358 $DIFF -s tmpSparse tmpOutSparse
359 $ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
360 $DIFF -s tmpSparse tmpOutNoSparse
361 ls -ls tmpSparse*  # look at file size and block size on disk
362 ./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd   # Odd size file (to not finish on an exact nb of blocks)
363 ./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
364 ls -ls tmpSparseOdd  # look at file size and block size on disk
365 $ECHO "\n Sparse Compatibility with Console :"
366 $ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c
367 $ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
368 $ECHO "\n Sparse Compatibility with Append :"
369 ./datagen -P100 -g1M > tmpSparse1M
370 cat tmpSparse1M tmpSparse1M > tmpSparse2M
371 $ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
372 $ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
373 $ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
374 ls -ls tmpSparse*  # look at file size and block size on disk
375 $DIFF tmpSparse2M tmpSparseRegenerated
376 rm tmpSparse*
377
378
379 $ECHO "\n===>  multiple files tests "
380
381 ./datagen -s1        > tmp1 2> $INTOVOID
382 ./datagen -s2 -g100K > tmp2 2> $INTOVOID
383 ./datagen -s3 -g1M   > tmp3 2> $INTOVOID
384 $ECHO "compress tmp* : "
385 $ZSTD -f tmp*
386 ls -ls tmp*
387 rm tmp1 tmp2 tmp3
388 $ECHO "decompress tmp* : "
389 $ZSTD -df *.zst
390 ls -ls tmp*
391 $ECHO "compress tmp* into stdout > tmpall : "
392 $ZSTD -c tmp1 tmp2 tmp3 > tmpall
393 ls -ls tmp*  # check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
394 $ECHO "decompress tmpall* into stdout > tmpdec : "
395 cp tmpall tmpall2
396 $ZSTD -dc tmpall* > tmpdec
397 ls -ls tmp* # check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3))
398 $ECHO "compress multiple files including a missing one (notHere) : "
399 $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
400
401
402 $ECHO "\n===>  dictionary tests "
403
404 $ECHO "- test with raw dict (content only) "
405 ./datagen > tmpDict
406 ./datagen -g1M | $MD5SUM > tmp1
407 ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2
408 $DIFF -q tmp1 tmp2
409 $ECHO "- Create first dictionary "
410 TESTFILE=../programs/zstdcli.c
411 $ZSTD --train *.c ../programs/*.c -o tmpDict
412 cp $TESTFILE tmp
413 $ECHO "- Test dictionary compression with tmpDict as an input file and dictionary"
414 $ZSTD -f tmpDict -D tmpDict && die "compression error not detected!"
415 $ECHO "- Dictionary compression roundtrip"
416 $ZSTD -f tmp -D tmpDict
417 $ZSTD -d tmp.zst -D tmpDict -fo result
418 $DIFF $TESTFILE result
419 $ECHO "- Dictionary compression with btlazy2 strategy"
420 $ZSTD -f tmp -D tmpDict --zstd=strategy=6
421 $ZSTD -d tmp.zst -D tmpDict -fo result
422 $DIFF $TESTFILE result
423 if [ -n "$hasMT" ]
424 then
425     $ECHO "- Test dictionary compression with multithreading "
426     ./datagen -g5M | $ZSTD -T2 -D tmpDict | $ZSTD -t -D tmpDict   # fails with v1.3.2
427 fi
428 $ECHO "- Create second (different) dictionary "
429 $ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC
430 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
431 $ECHO "- Create dictionary with short dictID"
432 $ZSTD --train *.c ../programs/*.c --dictID=1 -o tmpDict1
433 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
434 $ECHO "- Create dictionary with wrong dictID parameter order (must fail)"
435 $ZSTD --train *.c ../programs/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
436 $ECHO "- Create dictionary with size limit"
437 $ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict=4K -v
438 $ECHO "- Create dictionary with small size limit"
439 $ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict=1K -v
440 $ECHO "- Create dictionary with wrong parameter order (must fail)"
441 $ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
442 $ECHO "- Compress without dictID"
443 $ZSTD -f tmp -D tmpDict1 --no-dictID
444 $ZSTD -d tmp.zst -D tmpDict -fo result
445 $DIFF $TESTFILE result
446 $ECHO "- Compress with wrong argument order (must fail)"
447 $ZSTD tmp -Df tmpDict1 -c > $INTOVOID && die "-D must be followed by dictionary name "
448 $ECHO "- Compress multiple files with dictionary"
449 rm -rf dirTestDict
450 mkdir dirTestDict
451 cp *.c dirTestDict
452 cp ../programs/*.c dirTestDict
453 cp ../programs/*.h dirTestDict
454 $MD5SUM dirTestDict/* > tmph1
455 $ZSTD -f --rm dirTestDict/* -D tmpDictC
456 $ZSTD -d --rm dirTestDict/*.zst -D tmpDictC  # note : use internal checksum by default
457 case "$UNAME" in
458   Darwin) $ECHO "md5sum -c not supported on OS-X : test skipped" ;;  # not compatible with OS-X's md5
459   *) $MD5SUM -c tmph1 ;;
460 esac
461 rm -rf dirTestDict
462 $ECHO "- dictionary builder on bogus input"
463 $ECHO "Hello World" > tmp
464 $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : not enough input source"
465 ./datagen -P0 -g10M > tmp
466 $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise"
467 $ECHO "- Test -o before --train"
468 rm -f tmpDict dictionary
469 $ZSTD -o tmpDict --train *.c ../programs/*.c
470 test -f tmpDict
471 $ZSTD --train *.c ../programs/*.c
472 test -f dictionary
473 rm tmp* dictionary
474
475
476 $ECHO "\n===>  fastCover dictionary builder : advanced options "
477
478 TESTFILE=../programs/zstdcli.c
479 ./datagen > tmpDict
480 $ECHO "- Create first dictionary"
481 $ZSTD --train-fastcover=k=46,d=8,f=15,split=80 *.c ../programs/*.c -o tmpDict
482 cp $TESTFILE tmp
483 $ZSTD -f tmp -D tmpDict
484 $ZSTD -d tmp.zst -D tmpDict -fo result
485 $DIFF $TESTFILE result
486 $ECHO "- Create second (different) dictionary"
487 $ZSTD --train-fastcover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC
488 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
489 $ECHO "- Create dictionary with short dictID"
490 $ZSTD --train-fastcover=k=46,d=8,f=15,split=80 *.c ../programs/*.c --dictID=1 -o tmpDict1
491 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
492 $ECHO "- Create dictionary with size limit"
493 $ZSTD --train-fastcover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
494 $ECHO "- Compare size of dictionary from 90% training samples with 80% training samples"
495 $ZSTD --train-fastcover=split=90 -r *.c ../programs/*.c
496 $ZSTD --train-fastcover=split=80 -r *.c ../programs/*.c
497 $ECHO "- Create dictionary using all samples for both training and testing"
498 $ZSTD --train-fastcover=split=100 -r *.c ../programs/*.c
499 $ECHO "- Create dictionary using f=16"
500 $ZSTD --train-fastcover=f=16 -r *.c ../programs/*.c
501 $ECHO "- Create dictionary using accel=2"
502 $ZSTD --train-fastcover=accel=2 -r *.c ../programs/*.c
503 $ECHO "- Create dictionary using accel=10"
504 $ZSTD --train-fastcover=accel=10 -r *.c ../programs/*.c
505 $ECHO "- Create dictionary with multithreading"
506 $ZSTD --train-fastcover -T4 -r *.c ../programs/*.c
507 $ECHO "- Test -o before --train-fastcover"
508 rm -f tmpDict dictionary
509 $ZSTD -o tmpDict --train-fastcover *.c ../programs/*.c
510 test -f tmpDict
511 $ZSTD --train-fastcover *.c ../programs/*.c
512 test -f dictionary
513 rm tmp* dictionary
514
515
516 $ECHO "\n===>  legacy dictionary builder "
517
518 TESTFILE=../programs/zstdcli.c
519 ./datagen > tmpDict
520 $ECHO "- Create first dictionary"
521 $ZSTD --train-legacy=selectivity=8 *.c ../programs/*.c -o tmpDict
522 cp $TESTFILE tmp
523 $ZSTD -f tmp -D tmpDict
524 $ZSTD -d tmp.zst -D tmpDict -fo result
525 $DIFF $TESTFILE result
526 $ECHO "- Create second (different) dictionary"
527 $ZSTD --train-legacy=s=5 *.c ../programs/*.c ../programs/*.h -o tmpDictC
528 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
529 $ECHO "- Create dictionary with short dictID"
530 $ZSTD --train-legacy -s5 *.c ../programs/*.c --dictID=1 -o tmpDict1
531 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
532 $ECHO "- Create dictionary with size limit"
533 $ZSTD --train-legacy -s9 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
534 $ECHO "- Test -o before --train-legacy"
535 rm -f tmpDict dictionary
536 $ZSTD -o tmpDict --train-legacy *.c ../programs/*.c
537 test -f tmpDict
538 $ZSTD --train-legacy *.c ../programs/*.c
539 test -f dictionary
540 rm tmp* dictionary
541
542
543 $ECHO "\n===>  integrity tests "
544
545 $ECHO "test one file (tmp1.zst) "
546 ./datagen > tmp1
547 $ZSTD tmp1
548 $ZSTD -t tmp1.zst
549 $ZSTD --test tmp1.zst
550 $ECHO "test multiple files (*.zst) "
551 $ZSTD -t *.zst
552 $ECHO "test bad files (*) "
553 $ZSTD -t * && die "bad files not detected !"
554 $ZSTD -t tmp1 && die "bad file not detected !"
555 cp tmp1 tmp2.zst
556 $ZSTD -t tmp2.zst && die "bad file not detected !"
557 ./datagen -g0 > tmp3
558 $ZSTD -t tmp3 && die "bad file not detected !"   # detects 0-sized files as bad
559 $ECHO "test --rm and --test combined "
560 $ZSTD -t --rm tmp1.zst
561 test -f tmp1.zst   # check file is still present
562 split -b16384 tmp1.zst tmpSplit.
563 $ZSTD -t tmpSplit.* && die "bad file not detected !"
564 ./datagen | $ZSTD -c | $ZSTD -t
565
566
567
568 $ECHO "\n===>  golden files tests "
569
570 $ZSTD -t -r files
571 $ZSTD -c -r files | $ZSTD -t
572
573
574 $ECHO "\n===>  benchmark mode tests "
575
576 $ECHO "bench one file"
577 ./datagen > tmp1
578 $ZSTD -bi0 tmp1
579 $ECHO "bench multiple levels"
580 $ZSTD -i0b0e3 tmp1
581 $ECHO "bench negative level"
582 $ZSTD -bi0 --fast tmp1
583 $ECHO "with recursive and quiet modes"
584 $ZSTD -rqi1b1e2 tmp1
585 $ECHO "benchmark decompression only"
586 $ZSTD -f tmp1
587 $ZSTD -b -d -i1 tmp1.zst
588
589 $ECHO "\n===>  zstd compatibility tests "
590
591 ./datagen > tmp
592 rm -f tmp.zst
593 $ZSTD --format=zstd -f tmp
594 test -f tmp.zst
595
596 $ECHO "\n===>  gzip compatibility tests "
597
598 GZIPMODE=1
599 $ZSTD --format=gzip -V || GZIPMODE=0
600 if [ $GZIPMODE -eq 1 ]; then
601     $ECHO "gzip support detected"
602     GZIPEXE=1
603     gzip -V || GZIPEXE=0
604     if [ $GZIPEXE -eq 1 ]; then
605         ./datagen > tmp
606         $ZSTD --format=gzip -f tmp
607         gzip -t -v tmp.gz
608         gzip -f tmp
609         $ZSTD -d -f -v tmp.gz
610         rm tmp*
611     else
612         $ECHO "gzip binary not detected"
613     fi
614 else
615     $ECHO "gzip mode not supported"
616 fi
617
618
619 $ECHO "\n===>  gzip frame tests "
620
621 if [ $GZIPMODE -eq 1 ]; then
622     ./datagen > tmp
623     $ZSTD -f --format=gzip tmp
624     $ZSTD -f tmp
625     cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp
626     truncateLastByte tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
627     rm tmp*
628 else
629     $ECHO "gzip mode not supported"
630 fi
631
632 if [ $GZIPMODE -eq 1 ]; then
633     ./datagen > tmp
634     rm -f tmp.zst
635     $ZSTD --format=gzip --format=zstd -f tmp
636     test -f tmp.zst
637 fi
638
639 $ECHO "\n===>  xz compatibility tests "
640
641 LZMAMODE=1
642 $ZSTD --format=xz -V || LZMAMODE=0
643 if [ $LZMAMODE -eq 1 ]; then
644     $ECHO "xz support detected"
645     XZEXE=1
646     xz -Q -V && lzma -Q -V || XZEXE=0
647     if [ $XZEXE -eq 1 ]; then
648         $ECHO "Testing zstd xz and lzma support"
649         ./datagen > tmp
650         $ZSTD --format=lzma -f tmp
651         $ZSTD --format=xz -f tmp
652         xz -Q -t -v tmp.xz
653         xz -Q -t -v tmp.lzma
654         xz -Q -f -k tmp
655         lzma -Q -f -k --lzma1 tmp
656         $ZSTD -d -f -v tmp.xz
657         $ZSTD -d -f -v tmp.lzma
658         rm tmp*
659         $ECHO "Creating symlinks"
660         ln -s $ZSTD ./xz
661         ln -s $ZSTD ./unxz
662         ln -s $ZSTD ./lzma
663         ln -s $ZSTD ./unlzma
664         $ECHO "Testing xz and lzma symlinks"
665         ./datagen > tmp
666         ./xz tmp
667         xz -Q -d tmp.xz
668         ./lzma tmp
669         lzma -Q -d tmp.lzma
670         $ECHO "Testing unxz and unlzma symlinks"
671         xz -Q tmp
672         ./xz -d tmp.xz
673         lzma -Q tmp
674         ./lzma -d tmp.lzma
675         rm xz unxz lzma unlzma
676         rm tmp*
677     else
678         $ECHO "xz binary not detected"
679     fi
680 else
681     $ECHO "xz mode not supported"
682 fi
683
684
685 $ECHO "\n===>  xz frame tests "
686
687 if [ $LZMAMODE -eq 1 ]; then
688     ./datagen > tmp
689     $ZSTD -f --format=xz tmp
690     $ZSTD -f --format=lzma tmp
691     $ZSTD -f tmp
692     cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp
693     truncateLastByte tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
694     truncateLastByte tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
695     rm tmp*
696 else
697     $ECHO "xz mode not supported"
698 fi
699
700 $ECHO "\n===>  lz4 compatibility tests "
701
702 LZ4MODE=1
703 $ZSTD --format=lz4 -V || LZ4MODE=0
704 if [ $LZ4MODE -eq 1 ]; then
705     $ECHO "lz4 support detected"
706     LZ4EXE=1
707     lz4 -V || LZ4EXE=0
708     if [ $LZ4EXE -eq 1 ]; then
709         ./datagen > tmp
710         $ZSTD --format=lz4 -f tmp
711         lz4 -t -v tmp.lz4
712         lz4 -f tmp
713         $ZSTD -d -f -v tmp.lz4
714         rm tmp*
715     else
716         $ECHO "lz4 binary not detected"
717     fi
718 else
719     $ECHO "lz4 mode not supported"
720 fi
721
722
723 $ECHO "\n===>  lz4 frame tests "
724
725 if [ $LZ4MODE -eq 1 ]; then
726     ./datagen > tmp
727     $ZSTD -f --format=lz4 tmp
728     $ZSTD -f tmp
729     cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp
730     truncateLastByte tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
731     rm tmp*
732 else
733     $ECHO "lz4 mode not supported"
734 fi
735
736 $ECHO "\n===> suffix list test"
737
738 ! $ZSTD -d tmp.abc 2> tmplg
739
740 if [ $GZIPMODE -ne 1 ]; then
741     grep ".gz" tmplg > $INTOVOID && die "Unsupported suffix listed"
742 fi
743
744 if [ $LZMAMODE -ne 1 ]; then
745     grep ".lzma" tmplg > $INTOVOID && die "Unsupported suffix listed"
746     grep ".xz" tmplg > $INTOVOID && die "Unsupported suffix listed"
747 fi
748
749 if [ $LZ4MODE -ne 1 ]; then
750     grep ".lz4" tmplg > $INTOVOID && die "Unsupported suffix listed"
751 fi
752
753 $ECHO "\n===>  zstd round-trip tests "
754
755 roundTripTest
756 roundTripTest -g15K       # TableID==3
757 roundTripTest -g127K      # TableID==2
758 roundTripTest -g255K      # TableID==1
759 roundTripTest -g522K      # TableID==0
760 roundTripTest -g519K 6    # greedy, hash chain
761 roundTripTest -g517K 16   # btlazy2
762 roundTripTest -g516K 19   # btopt
763
764 fileRoundTripTest -g500K
765
766 $ECHO "\n===>  zstd long distance matching round-trip tests "
767 roundTripTest -g0 "2 --single-thread --long"
768 roundTripTest -g1000K "1 --single-thread --long"
769 roundTripTest -g517K "6 --single-thread --long"
770 roundTripTest -g516K "16 --single-thread --long"
771 roundTripTest -g518K "19 --single-thread --long"
772 fileRoundTripTest -g5M "3 --single-thread --long"
773
774
775 roundTripTest -g96K "5 --single-thread"
776 if [ -n "$hasMT" ]
777 then
778     $ECHO "\n===>  zstdmt round-trip tests "
779     roundTripTest -g4M "1 -T0"
780     roundTripTest -g8M "3 -T2"
781     roundTripTest -g8000K "2 --threads=2"
782     fileRoundTripTest -g4M "19 -T2 -B1M"
783
784     $ECHO "\n===>  zstdmt long distance matching round-trip tests "
785     roundTripTest -g8M "3 --long=24 -T2"
786
787     $ECHO "\n===>  ovLog tests "
788     ./datagen -g2MB > tmp
789     refSize=$($ZSTD tmp -6 -c --zstd=wlog=18         | wc -c)
790     ov9Size=$($ZSTD tmp -6 -c --zstd=wlog=18,ovlog=9 | wc -c)
791     ov1Size=$($ZSTD tmp -6 -c --zstd=wlog=18,ovlog=1 | wc -c)
792     if [ $refSize -eq $ov9Size ]; then
793         echo ov9Size should be different from refSize
794         exit 1
795     fi
796     if [ $refSize -eq $ov1Size ]; then
797         echo ov1Size should be different from refSize
798         exit 1
799     fi
800     if [ $ov9Size -ge $ov1Size ]; then
801         echo ov9Size=$ov9Size should be smaller than ov1Size=$ov1Size
802         exit 1
803     fi
804
805 else
806     $ECHO "\n===>  no multithreading, skipping zstdmt tests "
807 fi
808
809 rm tmp*
810
811 $ECHO "\n===>  zstd --list/-l single frame tests "
812 ./datagen > tmp1
813 ./datagen > tmp2
814 ./datagen > tmp3
815 $ZSTD tmp*
816 $ZSTD -l *.zst
817 $ZSTD -lv *.zst | grep "Decompressed Size:"  # check that decompressed size is present in header
818 $ZSTD --list *.zst
819 $ZSTD --list -v *.zst
820
821 $ECHO "\n===>  zstd --list/-l multiple frame tests "
822 cat tmp1.zst tmp2.zst > tmp12.zst
823 cat tmp12.zst tmp3.zst > tmp123.zst
824 $ZSTD -l *.zst
825 $ZSTD -lv *.zst
826
827 $ECHO "\n===>  zstd --list/-l error detection tests "
828 $ZSTD -l tmp1 tmp1.zst && die "-l must fail on non-zstd file"
829 $ZSTD --list tmp* && die "-l must fail on non-zstd file"
830 $ZSTD -lv tmp1* && die "-l must fail on non-zstd file"
831 $ZSTD --list -v tmp2 tmp12.zst && die "-l must fail on non-zstd file"
832
833 $ECHO "test : detect truncated compressed file "
834 TEST_DATA_FILE=truncatable-input.txt
835 FULL_COMPRESSED_FILE=${TEST_DATA_FILE}.zst
836 TRUNCATED_COMPRESSED_FILE=truncated-input.txt.zst
837 ./datagen -g50000 > $TEST_DATA_FILE
838 $ZSTD -f $TEST_DATA_FILE -o $FULL_COMPRESSED_FILE
839 dd bs=1 count=100 if=$FULL_COMPRESSED_FILE of=$TRUNCATED_COMPRESSED_FILE
840 $ZSTD --list $TRUNCATED_COMPRESSED_FILE && die "-l must fail on truncated file"
841
842 rm $TEST_DATA_FILE
843 rm $FULL_COMPRESSED_FILE
844 rm $TRUNCATED_COMPRESSED_FILE
845
846 $ECHO "\n===>  zstd --list/-l errors when presented with stdin / no files"
847 $ZSTD -l && die "-l must fail on empty list of files"
848 $ZSTD -l - && die "-l does not work on stdin"
849 $ZSTD -l < tmp1.zst && die "-l does not work on stdin"
850 $ZSTD -l - < tmp1.zst && die "-l does not work on stdin"
851 $ZSTD -l - tmp1.zst && die "-l does not work on stdin"
852 $ZSTD -l - tmp1.zst < tmp1.zst && die "-l does not work on stdin"
853 $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
854
855 $ECHO "\n===>  zstd --list/-l test with null files "
856 ./datagen -g0 > tmp5
857 $ZSTD tmp5
858 $ZSTD -l tmp5.zst
859 $ZSTD -l tmp5* && die "-l must fail on non-zstd file"
860 $ZSTD -lv tmp5.zst | grep "Decompressed Size: 0.00 KB (0 B)"  # check that 0 size is present in header
861 $ZSTD -lv tmp5* && die "-l must fail on non-zstd file"
862
863 $ECHO "\n===>  zstd --list/-l test with no content size field "
864 ./datagen -g513K | $ZSTD > tmp6.zst
865 $ZSTD -l tmp6.zst
866 $ZSTD -lv tmp6.zst | grep "Decompressed Size:"  && die "Field :Decompressed Size: should not be available in this compressed file"
867
868 $ECHO "\n===>   zstd --list/-l test with no checksum "
869 $ZSTD -f --no-check tmp1
870 $ZSTD -l tmp1.zst
871 $ZSTD -lv tmp1.zst
872
873 rm tmp*
874
875
876 $ECHO "\n===>   zstd long distance matching tests "
877 roundTripTest -g0 " --single-thread --long"
878 roundTripTest -g9M "2 --single-thread --long"
879 # Test parameter parsing
880 roundTripTest -g1M -P50 "1 --single-thread --long=29" " --memory=512MB"
881 roundTripTest -g1M -P50 "1 --single-thread --long=29 --zstd=wlog=28" " --memory=256MB"
882 roundTripTest -g1M -P50 "1 --single-thread --long=29" " --long=28 --memory=512MB"
883 roundTripTest -g1M -P50 "1 --single-thread --long=29" " --zstd=wlog=28 --memory=512MB"
884
885
886 $ECHO "\n===>   adaptive mode "
887 roundTripTest -g270000000 " --adapt"
888 roundTripTest -g27000000 " --adapt=min=1,max=4"
889 $ECHO "===>   test: --adapt must fail on incoherent bounds "
890 ./datagen > tmp
891 $ZSTD -f -vv --adapt=min=10,max=9 tmp && die "--adapt must fail on incoherent bounds"
892
893 $ECHO "\n===>   rsyncable mode "
894 roundTripTest -g10M " --rsyncable"
895 roundTripTest -g10M " --rsyncable -B100K"
896 $ECHO "===>   test: --rsyncable must fail with --single-thread"
897 $ZSTD -f -vv --rsyncable --single-thread tmp && die "--rsyncable must fail with --single-thread"
898
899
900 if [ "$1" != "--test-large-data" ]; then
901     $ECHO "Skipping large data tests"
902     exit 0
903 fi
904
905
906 #############################################################################
907
908 $ECHO "\n===>   large files tests "
909
910 roundTripTest -g270000000 1
911 roundTripTest -g250000000 2
912 roundTripTest -g230000000 3
913
914 roundTripTest -g140000000 -P60 4
915 roundTripTest -g130000000 -P62 5
916 roundTripTest -g120000000 -P65 6
917
918 roundTripTest -g70000000 -P70 7
919 roundTripTest -g60000000 -P71 8
920 roundTripTest -g50000000 -P73 9
921
922 roundTripTest -g35000000 -P75 10
923 roundTripTest -g30000000 -P76 11
924 roundTripTest -g25000000 -P78 12
925
926 roundTripTest -g18000013 -P80 13
927 roundTripTest -g18000014 -P80 14
928 roundTripTest -g18000015 -P81 15
929 roundTripTest -g18000016 -P84 16
930 roundTripTest -g18000017 -P88 17
931 roundTripTest -g18000018 -P94 18
932 roundTripTest -g18000019 -P96 19
933
934 roundTripTest -g5000000000 -P99 1
935 roundTripTest -g1700000000 -P0 "1 --zstd=strategy=6"   # ensure btlazy2 can survive an overflow rescale
936
937 fileRoundTripTest -g4193M -P99 1
938
939
940 $ECHO "\n===>   zstd long, long distance matching round-trip tests "
941 roundTripTest -g270000000 "1 --single-thread --long"
942 roundTripTest -g130000000 -P60 "5 --single-thread --long"
943 roundTripTest -g35000000 -P70 "8 --single-thread --long"
944 roundTripTest -g18000001 -P80  "18 --single-thread --long"
945 # Test large window logs
946 roundTripTest -g700M -P50 "1 --single-thread --long=29"
947 roundTripTest -g600M -P50 "1 --single-thread --long --zstd=wlog=29,clog=28"
948
949
950 if [ -n "$hasMT" ]
951 then
952     $ECHO "\n===>   zstdmt long round-trip tests "
953     roundTripTest -g80000000 -P99 "19 -T2" " "
954     roundTripTest -g5000000000 -P99 "1 -T2" " "
955     roundTripTest -g500000000 -P97 "1 -T999" " "
956     fileRoundTripTest -g4103M -P98 " -T0" " "
957     roundTripTest -g400000000 -P97 "1 --long=24 -T2" " "
958 else
959     $ECHO "\n**** no multithreading, skipping zstdmt tests **** "
960 fi
961
962
963 $ECHO "\n===>  cover dictionary builder : advanced options "
964
965 TESTFILE=../programs/zstdcli.c
966 ./datagen > tmpDict
967 $ECHO "- Create first dictionary"
968 $ZSTD --train-cover=k=46,d=8,split=80 *.c ../programs/*.c -o tmpDict
969 cp $TESTFILE tmp
970 $ZSTD -f tmp -D tmpDict
971 $ZSTD -d tmp.zst -D tmpDict -fo result
972 $DIFF $TESTFILE result
973 $ECHO "- Create second (different) dictionary"
974 $ZSTD --train-cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC
975 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
976 $ECHO "- Create dictionary with short dictID"
977 $ZSTD --train-cover=k=46,d=8,split=80 *.c ../programs/*.c --dictID=1 -o tmpDict1
978 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
979 $ECHO "- Create dictionary with size limit"
980 $ZSTD --train-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
981 $ECHO "- Compare size of dictionary from 90% training samples with 80% training samples"
982 $ZSTD --train-cover=split=90 -r *.c ../programs/*.c
983 $ZSTD --train-cover=split=80 -r *.c ../programs/*.c
984 $ECHO "- Create dictionary using all samples for both training and testing"
985 $ZSTD --train-cover=split=100 -r *.c ../programs/*.c
986 $ECHO "- Test -o before --train-cover"
987 rm -f tmpDict dictionary
988 $ZSTD -o tmpDict --train-cover *.c ../programs/*.c
989 test -f tmpDict
990 $ZSTD --train-cover *.c ../programs/*.c
991 test -f dictionary
992 rm -f tmp* dictionary
993
994
995 rm -f tmp*