]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/playTests.sh
Import zstd 1.3.1
[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
17     rm -f tmp1 tmp2
18     $ECHO "roundTripTest: ./datagen $1 $proba | $ZSTD -v$cLevel | $ZSTD -d"
19     ./datagen $1 $proba | $MD5SUM > tmp1
20     ./datagen $1 $proba | $ZSTD --ultra -v$cLevel | $ZSTD -d  | $MD5SUM > tmp2
21     $DIFF -q tmp1 tmp2
22 }
23
24 fileRoundTripTest() {
25     if [ -n "$3" ]; then
26         local_c="$3"
27         local_p="$2"
28     else
29         local_c="$2"
30         local_p=""
31     fi
32
33     rm -f tmp.zstd tmp.md5.1 tmp.md5.2
34     $ECHO "fileRoundTripTest: ./datagen $1 $local_p > tmp && $ZSTD -v$local_c -c tmp | $ZSTD -d"
35     ./datagen $1 $local_p > tmp
36     cat tmp | $MD5SUM > tmp.md5.1
37     $ZSTD --ultra -v$local_c -c tmp | $ZSTD -d | $MD5SUM > tmp.md5.2
38     $DIFF -q tmp.md5.1 tmp.md5.2
39 }
40
41 isTerminal=false
42 if [ -t 0 ] && [ -t 1 ]
43 then
44     isTerminal=true
45 fi
46
47 isWindows=false
48 ECHO="echo -e"
49 INTOVOID="/dev/null"
50 case "$OS" in
51   Windows*)
52     isWindows=true
53     INTOVOID="NUL"
54     ;;
55 esac
56
57 UNAME=$(uname)
58 case "$UNAME" in
59   Darwin) MD5SUM="md5 -r" ;;
60   FreeBSD) MD5SUM="gmd5sum" ;;
61   *) MD5SUM="md5sum" ;;
62 esac
63
64 DIFF="diff"
65 case "$UNAME" in
66   SunOS) DIFF="gdiff" ;;
67 esac
68
69 $ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
70
71 [ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
72
73 if [ -n "$(echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep 'multi-threading is disabled')" ]
74 then
75     hasMT=""
76 else
77     hasMT="true"
78 fi
79
80 $ECHO "\n**** simple tests **** "
81
82 ./datagen > tmp
83 $ECHO "test : basic compression "
84 $ZSTD -f tmp                      # trivial compression case, creates tmp.zst
85 $ECHO "test : basic decompression"
86 $ZSTD -df tmp.zst                 # trivial decompression case (overwrites tmp)
87 $ECHO "test : too large compression level (must fail)"
88 $ZSTD -99 -f tmp  # too large compression level, automatic sized down
89 $ECHO "test : compress to stdout"
90 $ZSTD tmp -c > tmpCompressed
91 $ZSTD tmp --stdout > tmpCompressed       # long command format
92 $ECHO "test : compress to named file"
93 rm tmpCompressed
94 $ZSTD tmp -o tmpCompressed
95 test -f tmpCompressed   # file must be created
96 $ECHO "test : -o must be followed by filename (must fail)"
97 $ZSTD tmp -of tmpCompressed && die "-o must be followed by filename "
98 $ECHO "test : force write, correct order"
99 $ZSTD tmp -fo tmpCompressed
100 $ECHO "test : forgotten argument"
101 cp tmp tmp2
102 $ZSTD tmp2 -fo && die "-o must be followed by filename "
103 $ECHO "test : implied stdout when input is stdin"
104 $ECHO bob | $ZSTD | $ZSTD -d
105 if [ "$isTerminal" = true ]; then
106 $ECHO "test : compressed data to terminal"
107 $ECHO bob | $ZSTD && die "should have refused : compressed data to terminal"
108 $ECHO "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)"
109 $ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal"
110 fi
111 $ECHO "test : null-length file roundtrip"
112 $ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
113 $ECHO "test : decompress file with wrong suffix (must fail)"
114 $ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
115 $ZSTD -df tmp && die "should have refused : wrong extension"
116 $ECHO "test : decompress into stdout"
117 $ZSTD -d tmpCompressed -c > tmpResult    # decompression using stdout
118 $ZSTD --decompress tmpCompressed -c > tmpResult
119 $ZSTD --decompress tmpCompressed --stdout > tmpResult
120 $ECHO "test : decompress from stdin into stdout"
121 $ZSTD -dc   < tmp.zst > $INTOVOID   # combine decompression, stdin & stdout
122 $ZSTD -dc - < tmp.zst > $INTOVOID
123 $ZSTD -d    < tmp.zst > $INTOVOID   # implicit stdout when stdin is used
124 $ZSTD -d  - < tmp.zst > $INTOVOID
125 $ECHO "test : impose memory limitation (must fail)"
126 $ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
127 $ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
128 $ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
129 $ZSTD -d -f tmp.zst --memlimit-decompress=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
130 $ECHO "test : overwrite protection"
131 $ZSTD -q tmp && die "overwrite check failed!"
132 $ECHO "test : force overwrite"
133 $ZSTD -q -f tmp
134 $ZSTD -q --force tmp
135 $ECHO "test : overwrite readonly file"
136 rm -f tmpro tmpro.zst
137 $ECHO foo > tmpro.zst
138 $ECHO foo > tmpro
139 chmod 400 tmpro.zst
140 $ZSTD -q tmpro && die "should have refused to overwrite read-only file"
141 $ZSTD -q -f tmpro
142 rm -f tmpro tmpro.zst
143 $ECHO "test : file removal"
144 $ZSTD -f --rm tmp
145 test ! -f tmp  # tmp should no longer be present
146 $ZSTD -f -d --rm tmp.zst
147 test ! -f tmp.zst   # tmp.zst should no longer be present
148 $ECHO "test : --rm on stdin"
149 $ECHO a | $ZSTD --rm > $INTOVOID   # --rm should remain silent
150 rm tmp
151 $ZSTD -f tmp && die "tmp not present : should have failed"
152 test ! -f tmp.zst  # tmp.zst should not be created
153
154
155 $ECHO "\n**** Advanced compression parameters **** "
156 $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,      - -o tmp.zst && die "wrong parameters not detected!"
157 $ECHO "Hello world!" | $ZSTD --zstd=windowLo=21        - -o tmp.zst && die "wrong parameters not detected!"
158 $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog  - -o tmp.zst && die "wrong parameters not detected!"
159 test ! -f tmp.zst  # tmp.zst should not be created
160 roundTripTest -g512K
161 roundTripTest -g512K " --zstd=slen=3,tlen=48,strat=6"
162 roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
163 roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6"
164 roundTripTest -g512K 19
165
166
167 $ECHO "\n**** Pass-Through mode **** "
168 $ECHO "Hello world 1!" | $ZSTD -df
169 $ECHO "Hello world 2!" | $ZSTD -dcf
170 $ECHO "Hello world 3!" > tmp1
171 $ZSTD -dcf tmp1
172
173
174 $ECHO "\n**** frame concatenation **** "
175
176 $ECHO "hello " > hello.tmp
177 $ECHO "world!" > world.tmp
178 cat hello.tmp world.tmp > helloworld.tmp
179 $ZSTD -c hello.tmp > hello.zstd
180 $ZSTD -c world.tmp > world.zstd
181 cat hello.zstd world.zstd > helloworld.zstd
182 $ZSTD -dc helloworld.zstd > result.tmp
183 cat result.tmp
184 $DIFF helloworld.tmp result.tmp
185 $ECHO "frame concatenation without checksum"
186 $ZSTD -c hello.tmp > hello.zstd --no-check
187 $ZSTD -c world.tmp > world.zstd --no-check
188 cat hello.zstd world.zstd > helloworld.zstd
189 $ZSTD -dc helloworld.zstd > result.tmp
190 cat result.tmp
191 $DIFF helloworld.tmp result.tmp
192 rm ./*.tmp ./*.zstd
193 $ECHO "frame concatenation tests completed"
194
195
196 if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
197 $ECHO "\n**** flush write error test **** "
198
199 $ECHO "$ECHO foo | $ZSTD > /dev/full"
200 $ECHO foo | $ZSTD > /dev/full && die "write error not detected!"
201 $ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full"
202 $ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
203
204
205 $ECHO "\n**** symbolic link test **** "
206
207 rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
208 $ECHO "hello world" > hello.tmp
209 ln -s hello.tmp world.tmp
210 $ZSTD world.tmp hello.tmp
211 test -f hello.tmp.zst  # regular file should have been compressed!
212 test ! -f world.tmp.zst  # symbolic link should not have been compressed!
213 $ZSTD world.tmp hello.tmp -f
214 test -f world.tmp.zst  # symbolic link should have been compressed with --force
215 rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
216
217 fi
218
219
220 $ECHO "\n**** test sparse file support **** "
221
222 ./datagen -g5M  -P100 > tmpSparse
223 $ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
224 $DIFF -s tmpSparse tmpSparseRegen
225 $ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
226 $DIFF -s tmpSparse tmpOutSparse
227 $ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
228 $DIFF -s tmpSparse tmpOutNoSparse
229 ls -ls tmpSparse*  # look at file size and block size on disk
230 ./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd   # Odd size file (to not finish on an exact nb of blocks)
231 ./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
232 ls -ls tmpSparseOdd  # look at file size and block size on disk
233 $ECHO "\n Sparse Compatibility with Console :"
234 $ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c
235 $ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
236 $ECHO "\n Sparse Compatibility with Append :"
237 ./datagen -P100 -g1M > tmpSparse1M
238 cat tmpSparse1M tmpSparse1M > tmpSparse2M
239 $ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
240 $ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
241 $ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
242 ls -ls tmpSparse*  # look at file size and block size on disk
243 $DIFF tmpSparse2M tmpSparseRegenerated
244 rm tmpSparse*
245
246
247 $ECHO "\n**** multiple files tests **** "
248
249 ./datagen -s1        > tmp1 2> $INTOVOID
250 ./datagen -s2 -g100K > tmp2 2> $INTOVOID
251 ./datagen -s3 -g1M   > tmp3 2> $INTOVOID
252 $ECHO "compress tmp* : "
253 $ZSTD -f tmp*
254 ls -ls tmp*
255 rm tmp1 tmp2 tmp3
256 $ECHO "decompress tmp* : "
257 $ZSTD -df *.zst
258 ls -ls tmp*
259 $ECHO "compress tmp* into stdout > tmpall : "
260 $ZSTD -c tmp1 tmp2 tmp3 > tmpall
261 ls -ls tmp*  # check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
262 $ECHO "decompress tmpall* into stdout > tmpdec : "
263 cp tmpall tmpall2
264 $ZSTD -dc tmpall* > tmpdec
265 ls -ls tmp* # check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3))
266 $ECHO "compress multiple files including a missing one (notHere) : "
267 $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
268
269
270 $ECHO "\n**** dictionary tests **** "
271
272 $ECHO "- test with raw dict (content only) "
273 ./datagen > tmpDict
274 ./datagen -g1M | $MD5SUM > tmp1
275 ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2
276 $DIFF -q tmp1 tmp2
277 $ECHO "- Create first dictionary "
278 TESTFILE=../programs/zstdcli.c
279 $ZSTD --train *.c ../programs/*.c -o tmpDict
280 cp $TESTFILE tmp
281 $ZSTD -f tmp -D tmpDict
282 $ZSTD -d tmp.zst -D tmpDict -fo result
283 $DIFF $TESTFILE result
284 $ECHO "- Create second (different) dictionary "
285 $ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC
286 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
287 $ECHO "- Create dictionary with short dictID"
288 $ZSTD --train *.c ../programs/*.c --dictID=1 -o tmpDict1
289 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
290 $ECHO "- Create dictionary with wrong dictID parameter order (must fail)"
291 $ZSTD --train *.c ../programs/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
292 $ECHO "- Create dictionary with size limit"
293 $ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict=4K -v
294 $ECHO "- Create dictionary with wrong parameter order (must fail)"
295 $ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
296 $ECHO "- Compress without dictID"
297 $ZSTD -f tmp -D tmpDict1 --no-dictID
298 $ZSTD -d tmp.zst -D tmpDict -fo result
299 $DIFF $TESTFILE result
300 $ECHO "- Compress with wrong argument order (must fail)"
301 $ZSTD tmp -Df tmpDict1 -c > $INTOVOID && die "-D must be followed by dictionary name "
302 $ECHO "- Compress multiple files with dictionary"
303 rm -rf dirTestDict
304 mkdir dirTestDict
305 cp *.c dirTestDict
306 cp ../programs/*.c dirTestDict
307 cp ../programs/*.h dirTestDict
308 $MD5SUM dirTestDict/* > tmph1
309 $ZSTD -f --rm dirTestDict/* -D tmpDictC
310 $ZSTD -d --rm dirTestDict/*.zst -D tmpDictC  # note : use internal checksum by default
311 case "$UNAME" in
312   Darwin) $ECHO "md5sum -c not supported on OS-X : test skipped" ;;  # not compatible with OS-X's md5
313   *) $MD5SUM -c tmph1 ;;
314 esac
315 rm -rf dirTestDict
316 $ECHO "- dictionary builder on bogus input"
317 $ECHO "Hello World" > tmp
318 $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : not enough input source"
319 ./datagen -P0 -g10M > tmp
320 $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise"
321 rm tmp*
322
323
324 $ECHO "\n**** cover dictionary tests **** "
325
326 TESTFILE=../programs/zstdcli.c
327 ./datagen > tmpDict
328 $ECHO "- Create first dictionary"
329 $ZSTD --train-cover=k=46,d=8 *.c ../programs/*.c -o tmpDict
330 cp $TESTFILE tmp
331 $ZSTD -f tmp -D tmpDict
332 $ZSTD -d tmp.zst -D tmpDict -fo result
333 $DIFF $TESTFILE result
334 $ECHO "- Create second (different) dictionary"
335 $ZSTD --train-cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC
336 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
337 $ECHO "- Create dictionary with short dictID"
338 $ZSTD --train-cover=k=46,d=8 *.c ../programs/*.c --dictID=1 -o tmpDict1
339 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
340 $ECHO "- Create dictionary with size limit"
341 $ZSTD --train-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
342 rm tmp*
343
344 $ECHO "\n**** legacy dictionary tests **** "
345
346 TESTFILE=../programs/zstdcli.c
347 ./datagen > tmpDict
348 $ECHO "- Create first dictionary"
349 $ZSTD --train-legacy=selectivity=8 *.c ../programs/*.c -o tmpDict
350 cp $TESTFILE tmp
351 $ZSTD -f tmp -D tmpDict
352 $ZSTD -d tmp.zst -D tmpDict -fo result
353 $DIFF $TESTFILE result
354 $ECHO "- Create second (different) dictionary"
355 $ZSTD --train-legacy=s=5 *.c ../programs/*.c ../programs/*.h -o tmpDictC
356 $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
357 $ECHO "- Create dictionary with short dictID"
358 $ZSTD --train-legacy -s5 *.c ../programs/*.c --dictID=1 -o tmpDict1
359 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
360 $ECHO "- Create dictionary with size limit"
361 $ZSTD --train-legacy -s9 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
362 rm tmp*
363
364
365 $ECHO "\n**** integrity tests **** "
366
367 $ECHO "test one file (tmp1.zst) "
368 ./datagen > tmp1
369 $ZSTD tmp1
370 $ZSTD -t tmp1.zst
371 $ZSTD --test tmp1.zst
372 $ECHO "test multiple files (*.zst) "
373 $ZSTD -t *.zst
374 $ECHO "test bad files (*) "
375 $ZSTD -t * && die "bad files not detected !"
376 $ZSTD -t tmp1 && die "bad file not detected !"
377 cp tmp1 tmp2.zst
378 $ZSTD -t tmp2.zst && die "bad file not detected !"
379 ./datagen -g0 > tmp3
380 $ZSTD -t tmp3 && die "bad file not detected !"   # detects 0-sized files as bad
381 $ECHO "test --rm and --test combined "
382 $ZSTD -t --rm tmp1.zst
383 test -f tmp1.zst   # check file is still present
384 split -b16384 tmp1.zst tmpSplit.
385 $ZSTD -t tmpSplit.* && die "bad file not detected !"
386 ./datagen | $ZSTD -c | $ZSTD -t
387
388
389
390 $ECHO "\n**** golden files tests **** "
391
392 $ZSTD -t -r files
393 $ZSTD -c -r files | $ZSTD -t
394
395
396 $ECHO "\n**** benchmark mode tests **** "
397
398 $ECHO "bench one file"
399 ./datagen > tmp1
400 $ZSTD -bi0 tmp1
401 $ECHO "bench multiple levels"
402 $ZSTD -i0b0e3 tmp1
403 $ECHO "with recursive and quiet modes"
404 $ZSTD -rqi1b1e2 tmp1
405
406
407 $ECHO "\n**** gzip compatibility tests **** "
408
409 GZIPMODE=1
410 $ZSTD --format=gzip -V || GZIPMODE=0
411 if [ $GZIPMODE -eq 1 ]; then
412     $ECHO "gzip support detected"
413     GZIPEXE=1
414     gzip -V || GZIPEXE=0
415     if [ $GZIPEXE -eq 1 ]; then
416         ./datagen > tmp
417         $ZSTD --format=gzip -f tmp
418         gzip -t -v tmp.gz
419         gzip -f tmp
420         $ZSTD -d -f -v tmp.gz
421         rm tmp*
422     else
423         $ECHO "gzip binary not detected"
424     fi
425 else
426     $ECHO "gzip mode not supported"
427 fi
428
429
430 $ECHO "\n**** gzip frame tests **** "
431
432 if [ $GZIPMODE -eq 1 ]; then
433     ./datagen > tmp
434     $ZSTD -f --format=gzip tmp
435     $ZSTD -f tmp
436     cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp
437     head -c -1 tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
438     rm tmp*
439 else
440     $ECHO "gzip mode not supported"
441 fi
442
443
444 $ECHO "\n**** xz compatibility tests **** "
445
446 LZMAMODE=1
447 $ZSTD --format=xz -V || LZMAMODE=0
448 if [ $LZMAMODE -eq 1 ]; then
449     $ECHO "xz support detected"
450     XZEXE=1
451     xz -V && lzma -V || XZEXE=0
452     if [ $XZEXE -eq 1 ]; then
453         $ECHO "Testing zstd xz and lzma support"
454         ./datagen > tmp
455         $ZSTD --format=lzma -f tmp
456         $ZSTD --format=xz -f tmp
457         xz -t -v tmp.xz
458         xz -t -v tmp.lzma
459         xz -f -k tmp
460         lzma -f -k --lzma1 tmp
461         $ZSTD -d -f -v tmp.xz
462         $ZSTD -d -f -v tmp.lzma
463         rm tmp*
464         $ECHO "Creating symlinks"
465         ln -s $ZSTD ./xz
466         ln -s $ZSTD ./unxz
467         ln -s $ZSTD ./lzma
468         ln -s $ZSTD ./unlzma
469         $ECHO "Testing xz and lzma symlinks"
470         ./datagen > tmp
471         ./xz tmp
472         xz -d tmp.xz
473         ./lzma tmp
474         lzma -d tmp.lzma
475         $ECHO "Testing unxz and unlzma symlinks"
476         xz tmp
477         ./xz -d tmp.xz
478         lzma tmp
479         ./lzma -d tmp.lzma
480         rm xz unxz lzma unlzma
481         rm tmp*
482     else
483         $ECHO "xz binary not detected"
484     fi
485 else
486     $ECHO "xz mode not supported"
487 fi
488
489
490 $ECHO "\n**** xz frame tests **** "
491
492 if [ $LZMAMODE -eq 1 ]; then
493     ./datagen > tmp
494     $ZSTD -f --format=xz tmp
495     $ZSTD -f --format=lzma tmp
496     $ZSTD -f tmp
497     cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp
498     head -c -1 tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
499     head -c -1 tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
500     rm tmp*
501 else
502     $ECHO "xz mode not supported"
503 fi
504
505 $ECHO "\n**** lz4 compatibility tests **** "
506
507 LZ4MODE=1
508 $ZSTD --format=lz4 -V || LZ4MODE=0
509 if [ $LZ4MODE -eq 1 ]; then
510     $ECHO "lz4 support detected"
511     LZ4EXE=1
512     lz4 -V || LZ4EXE=0
513     if [ $LZ4EXE -eq 1 ]; then
514         ./datagen > tmp
515         $ZSTD --format=lz4 -f tmp
516         lz4 -t -v tmp.lz4
517         lz4 -f tmp
518         $ZSTD -d -f -v tmp.lz4
519         rm tmp*
520     else
521         $ECHO "lz4 binary not detected"
522     fi
523 else
524     $ECHO "lz4 mode not supported"
525 fi
526
527
528 $ECHO "\n**** lz4 frame tests **** "
529
530 if [ $LZ4MODE -eq 1 ]; then
531     ./datagen > tmp
532     $ZSTD -f --format=lz4 tmp
533     $ZSTD -f tmp
534     cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp
535     head -c -1 tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
536     rm tmp*
537 else
538     $ECHO "lz4 mode not supported"
539 fi
540
541 $ECHO "\n**** zstd round-trip tests **** "
542
543 roundTripTest
544 roundTripTest -g15K       # TableID==3
545 roundTripTest -g127K      # TableID==2
546 roundTripTest -g255K      # TableID==1
547 roundTripTest -g522K      # TableID==0
548 roundTripTest -g519K 6    # greedy, hash chain
549 roundTripTest -g517K 16   # btlazy2
550 roundTripTest -g516K 19   # btopt
551
552 fileRoundTripTest -g500K
553
554 if [ -n "$hasMT" ]
555 then
556     $ECHO "\n**** zstdmt round-trip tests **** "
557     roundTripTest -g4M "1 -T0"
558     roundTripTest -g8M "3 -T2"
559     roundTripTest -g8000K "2 --threads=2"
560     fileRoundTripTest -g4M "19 -T2 -B1M"
561 else
562     $ECHO "\n**** no multithreading, skipping zstdmt tests **** "
563 fi
564
565 rm tmp*
566
567 $ECHO "\n**** zstd --list/-l single frame tests ****"
568 ./datagen > tmp1
569 ./datagen > tmp2
570 ./datagen > tmp3
571 ./datagen > tmp4
572 $ZSTD tmp*
573 $ZSTD -l *.zst
574 $ZSTD -lv *.zst
575 $ZSTD --list *.zst
576 $ZSTD --list -v *.zst
577
578 $ECHO "\n**** zstd --list/-l multiple frame tests ****"
579 cat tmp1.zst tmp2.zst > tmp12.zst
580 cat tmp3.zst tmp4.zst > tmp34.zst
581 cat tmp12.zst tmp34.zst > tmp1234.zst
582 cat tmp12.zst tmp4.zst > tmp124.zst
583 $ZSTD -l *.zst
584 $ZSTD -lv *.zst
585 $ZSTD --list *.zst
586 $ZSTD --list -v *.zst
587
588 $ECHO "\n**** zstd --list/-l error detection tests ****"
589 ! $ZSTD -l tmp1 tmp1.zst
590 ! $ZSTD --list tmp*
591 ! $ZSTD -lv tmp1*
592 ! $ZSTD --list -v tmp2 tmp23.zst
593
594 $ECHO "\n**** zstd --list/-l test with null files ****"
595 ./datagen -g0 > tmp5
596 $ZSTD tmp5
597 $ZSTD -l tmp5.zst
598 ! $ZSTD -l tmp5*
599 $ZSTD -lv tmp5.zst
600 ! $ZSTD -lv tmp5*
601
602 $ECHO "\n**** zstd --list/-l test with no content size field ****"
603 ./datagen -g1MB | $ZSTD > tmp6.zst
604 $ZSTD -l tmp6.zst
605 $ZSTD -lv tmp6.zst
606
607 $ECHO "\n**** zstd --list/-l test with no checksum ****"
608 $ZSTD -f --no-check tmp1
609 $ZSTD -l tmp1.zst
610 $ZSTD -lv tmp1.zst
611
612 rm tmp*
613
614
615 if [ "$1" != "--test-large-data" ]; then
616     $ECHO "Skipping large data tests"
617     exit 0
618 fi
619
620 roundTripTest -g270000000 1
621 roundTripTest -g270000000 2
622 roundTripTest -g270000000 3
623
624 roundTripTest -g140000000 -P60 4
625 roundTripTest -g140000000 -P60 5
626 roundTripTest -g140000000 -P60 6
627
628 roundTripTest -g70000000 -P70 7
629 roundTripTest -g70000000 -P70 8
630 roundTripTest -g70000000 -P70 9
631
632 roundTripTest -g35000000 -P75 10
633 roundTripTest -g35000000 -P75 11
634 roundTripTest -g35000000 -P75 12
635
636 roundTripTest -g18000013 -P80 13
637 roundTripTest -g18000014 -P80 14
638 roundTripTest -g18000015 -P80 15
639 roundTripTest -g18000016 -P80 16
640 roundTripTest -g18000017 -P80 17
641 roundTripTest -g18000018 -P94 18
642 roundTripTest -g18000019 -P94 19
643
644 roundTripTest -g68000020 -P99 20
645 roundTripTest -g6000000000 -P99 1
646
647 fileRoundTripTest -g4193M -P99 1
648
649 if [ -n "$hasMT" ]
650 then
651     $ECHO "\n**** zstdmt long round-trip tests **** "
652     roundTripTest -g99000000 -P99 "20 -T2"
653     roundTripTest -g6000000000 -P99 "1 -T2"
654     roundTripTest -g1500000000 -P97 "1 -T999"
655     fileRoundTripTest -g4195M -P98 " -T0"
656 else
657     $ECHO "\n**** no multithreading, skipping zstdmt tests **** "
658 fi
659
660 rm tmp*