blob: 773da845b5b541e0490cf7101b6033624edf3e2f [file] [log] [blame]
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +03001#!/bin/sh -e
2
3die() {
inikep5d589562016-05-25 10:50:28 +02004 $ECHO "$@" 1>&2
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +03005 exit 1
6}
7
Konstantin Tokarev76be3782015-12-08 18:36:37 +03008roundTripTest() {
9 if [ -n "$3" ]; then
Yann Collet4616fad2017-07-10 17:16:41 -070010 cLevel="$3"
11 proba="$2"
Konstantin Tokarev76be3782015-12-08 18:36:37 +030012 else
Yann Collet4616fad2017-07-10 17:16:41 -070013 cLevel="$2"
14 proba=""
Konstantin Tokarev76be3782015-12-08 18:36:37 +030015 fi
Nick Terrellc233bdb2017-09-22 14:04:39 -070016 if [ -n "$4" ]; then
17 dLevel="$4"
18 else
19 dLevel="$cLevel"
20 fi
Konstantin Tokarev76be3782015-12-08 18:36:37 +030021
22 rm -f tmp1 tmp2
Nick Terrellc233bdb2017-09-22 14:04:39 -070023 $ECHO "roundTripTest: ./datagen $1 $proba | $ZSTD -v$cLevel | $ZSTD -d$dLevel"
Yann Collet4616fad2017-07-10 17:16:41 -070024 ./datagen $1 $proba | $MD5SUM > tmp1
Nick Terrellc233bdb2017-09-22 14:04:39 -070025 ./datagen $1 $proba | $ZSTD --ultra -v$cLevel | $ZSTD -d$dLevel | $MD5SUM > tmp2
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +010026 $DIFF -q tmp1 tmp2
Konstantin Tokarev76be3782015-12-08 18:36:37 +030027}
28
Sean Purcelleb70d212017-04-11 17:15:13 -070029fileRoundTripTest() {
30 if [ -n "$3" ]; then
31 local_c="$3"
32 local_p="$2"
33 else
34 local_c="$2"
35 local_p=""
36 fi
Nick Terrellc233bdb2017-09-22 14:04:39 -070037 if [ -n "$4" ]; then
38 local_d="$4"
39 else
40 local_d="$local_c"
41 fi
Sean Purcelleb70d212017-04-11 17:15:13 -070042
43 rm -f tmp.zstd tmp.md5.1 tmp.md5.2
Nick Terrellc233bdb2017-09-22 14:04:39 -070044 $ECHO "fileRoundTripTest: ./datagen $1 $local_p > tmp && $ZSTD -v$local_c -c tmp | $ZSTD -d$local_d"
Sean Purcelleb70d212017-04-11 17:15:13 -070045 ./datagen $1 $local_p > tmp
Yann Collet42526212017-10-05 20:21:59 -070046 < tmp $MD5SUM > tmp.md5.1
Nick Terrellc233bdb2017-09-22 14:04:39 -070047 $ZSTD --ultra -v$local_c -c tmp | $ZSTD -d$local_d | $MD5SUM > tmp.md5.2
Sean Purcelleb70d212017-04-11 17:15:13 -070048 $DIFF -q tmp.md5.1 tmp.md5.2
49}
50
Sean Purcell9a38dfa2017-03-17 12:32:18 -070051isTerminal=false
52if [ -t 0 ] && [ -t 1 ]
53then
54 isTerminal=true
55fi
56
inikep5d589562016-05-25 10:50:28 +020057isWindows=false
Yann Collet391a1282016-06-21 17:06:25 +020058INTOVOID="/dev/null"
Nick Terrell82bc8fe2017-12-13 12:04:46 -080059DEVDEVICE="/dev/zero"
inikep993a9df2016-05-27 10:07:46 +020060case "$OS" in
Yann Collet673f0d72016-06-06 00:26:38 +020061 Windows*)
inikep5d589562016-05-25 10:50:28 +020062 isWindows=true
Sean Purcell9a38dfa2017-03-17 12:32:18 -070063 INTOVOID="NUL"
Nick Terrell82bc8fe2017-12-13 12:04:46 -080064 DEVDEVICE="NUL"
inikep993a9df2016-05-27 10:07:46 +020065 ;;
66esac
inikep5d589562016-05-25 10:50:28 +020067
Dimitry Andric12df6da2016-12-12 19:22:47 +010068UNAME=$(uname)
69case "$UNAME" in
70 Darwin) MD5SUM="md5 -r" ;;
71 FreeBSD) MD5SUM="gmd5sum" ;;
Yann Collet94d1a932016-12-06 12:02:56 -080072 *) MD5SUM="md5sum" ;;
73esac
inikep5d589562016-05-25 10:50:28 +020074
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +010075DIFF="diff"
76case "$UNAME" in
77 SunOS) DIFF="gdiff" ;;
78esac
79
Yann Collet62568c92017-09-25 14:26:26 -070080ECHO="echo -e"
81case "$UNAME" in
82 Darwin) ECHO="echo" ;;
83esac
84
Przemyslaw Skibinskie579ab52016-11-14 12:57:05 +010085$ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
inikep5d589562016-05-25 10:50:28 +020086
Konstantin Tokarev76be3782015-12-08 18:36:37 +030087[ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
88
Sean Purcellc424ec22017-04-17 11:38:53 -070089if [ -n "$(echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep 'multi-threading is disabled')" ]
90then
91 hasMT=""
92else
93 hasMT="true"
94fi
95
Yann Collet241c57a2017-10-16 14:01:42 -070096$ECHO "\n===> simple tests "
Yann Colletde95f962016-05-23 19:46:47 +020097
Yann Collet8154c3d2016-02-13 03:12:10 +010098./datagen > tmp
Yann Colletb3060f72016-09-09 16:44:16 +020099$ECHO "test : basic compression "
Yann Collet673f0d72016-06-06 00:26:38 +0200100$ZSTD -f tmp # trivial compression case, creates tmp.zst
Yann Colletb3060f72016-09-09 16:44:16 +0200101$ECHO "test : basic decompression"
Yann Collet673f0d72016-06-06 00:26:38 +0200102$ZSTD -df tmp.zst # trivial decompression case (overwrites tmp)
inikep5d589562016-05-25 10:50:28 +0200103$ECHO "test : too large compression level (must fail)"
Yann Colletfab02302016-08-12 19:00:18 +0200104$ZSTD -99 -f tmp # too large compression level, automatic sized down
inikep5d589562016-05-25 10:50:28 +0200105$ECHO "test : compress to stdout"
Yann Collet0d348d42016-05-29 02:02:24 +0200106$ZSTD tmp -c > tmpCompressed
Yann Colletd6931172016-05-10 05:56:09 +0200107$ZSTD tmp --stdout > tmpCompressed # long command format
Yann Collet27b5ac62016-09-21 14:20:56 +0200108$ECHO "test : compress to named file"
109rm tmpCompressed
110$ZSTD tmp -o tmpCompressed
Yann Collet01a1abf2017-05-05 19:15:24 -0700111test -f tmpCompressed # file must be created
Yann Collet27b5ac62016-09-21 14:20:56 +0200112$ECHO "test : -o must be followed by filename (must fail)"
Yann Collet714464f2016-09-21 16:05:03 +0200113$ZSTD tmp -of tmpCompressed && die "-o must be followed by filename "
Yann Collet27b5ac62016-09-21 14:20:56 +0200114$ECHO "test : force write, correct order"
115$ZSTD tmp -fo tmpCompressed
Yann Collet714464f2016-09-21 16:05:03 +0200116$ECHO "test : forgotten argument"
117cp tmp tmp2
118$ZSTD tmp2 -fo && die "-o must be followed by filename "
Yann Colletc8431422016-09-01 15:05:57 -0700119$ECHO "test : implied stdout when input is stdin"
120$ECHO bob | $ZSTD | $ZSTD -d
Sean Purcell9a38dfa2017-03-17 12:32:18 -0700121if [ "$isTerminal" = true ]; then
Sean Purcelld9730712017-03-16 16:25:19 -0700122$ECHO "test : compressed data to terminal"
123$ECHO bob | $ZSTD && die "should have refused : compressed data to terminal"
124$ECHO "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)"
125$ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal"
Sean Purcell9a38dfa2017-03-17 12:32:18 -0700126fi
inikep5d589562016-05-25 10:50:28 +0200127$ECHO "test : null-length file roundtrip"
128$ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
129$ECHO "test : decompress file with wrong suffix (must fail)"
Yann Collet2d08b092016-02-16 14:42:08 +0100130$ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
Yann Collet391a1282016-06-21 17:06:25 +0200131$ZSTD -df tmp && die "should have refused : wrong extension"
132$ECHO "test : decompress into stdout"
Yann Collet0d348d42016-05-29 02:02:24 +0200133$ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout
Yann Collet2d08b092016-02-16 14:42:08 +0100134$ZSTD --decompress tmpCompressed -c > tmpResult
135$ZSTD --decompress tmpCompressed --stdout > tmpResult
Yann Collet391a1282016-06-21 17:06:25 +0200136$ECHO "test : decompress from stdin into stdout"
137$ZSTD -dc < tmp.zst > $INTOVOID # combine decompression, stdin & stdout
138$ZSTD -dc - < tmp.zst > $INTOVOID
139$ZSTD -d < tmp.zst > $INTOVOID # implicit stdout when stdin is used
140$ZSTD -d - < tmp.zst > $INTOVOID
Yann Colletd4cda272016-10-14 13:13:13 -0700141$ECHO "test : impose memory limitation (must fail)"
142$ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
Yann Collet11223492016-10-14 14:07:11 -0700143$ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
Yann Colletd7b120a2016-10-14 14:22:32 -0700144$ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
145$ZSTD -d -f tmp.zst --memlimit-decompress=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
Yann Collet391a1282016-06-21 17:06:25 +0200146$ECHO "test : overwrite protection"
Yann Collet2d08b092016-02-16 14:42:08 +0100147$ZSTD -q tmp && die "overwrite check failed!"
Yann Collet391a1282016-06-21 17:06:25 +0200148$ECHO "test : force overwrite"
Yann Collet2d08b092016-02-16 14:42:08 +0100149$ZSTD -q -f tmp
150$ZSTD -q --force tmp
Sean Purcell9da11c62017-04-06 12:58:49 -0700151$ECHO "test : overwrite readonly file"
Sean Purcell16521722017-04-06 17:06:30 -0700152rm -f tmpro tmpro.zst
Sean Purcell9da11c62017-04-06 12:58:49 -0700153$ECHO foo > tmpro.zst
154$ECHO foo > tmpro
155chmod 400 tmpro.zst
Sean Purcell16521722017-04-06 17:06:30 -0700156$ZSTD -q tmpro && die "should have refused to overwrite read-only file"
157$ZSTD -q -f tmpro
158rm -f tmpro tmpro.zst
Yann Colletb09b12c2016-06-09 22:59:51 +0200159$ECHO "test : file removal"
160$ZSTD -f --rm tmp
Yann Collet01a1abf2017-05-05 19:15:24 -0700161test ! -f tmp # tmp should no longer be present
Yann Colletb09b12c2016-06-09 22:59:51 +0200162$ZSTD -f -d --rm tmp.zst
Yann Collet01a1abf2017-05-05 19:15:24 -0700163test ! -f tmp.zst # tmp.zst should no longer be present
Nick Terrell82bc8fe2017-12-13 12:04:46 -0800164$ECHO "test : should quietly not remove non-regular file"
165$ECHO hello > tmp
166$ZSTD tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID"
167grep -v "Refusing to remove non-regular file" tmplog
168rm -f tmplog
169$ZSTD tmp -f -o "$INTONULL" 2>&1 | grep -v "Refusing to remove non-regular file"
Yann Collet67d86a72017-02-27 16:09:20 -0800170$ECHO "test : --rm on stdin"
171$ECHO a | $ZSTD --rm > $INTOVOID # --rm should remain silent
Yann Colletb09b12c2016-06-09 22:59:51 +0200172rm tmp
173$ZSTD -f tmp && die "tmp not present : should have failed"
Yann Collet01a1abf2017-05-05 19:15:24 -0700174test ! -f tmp.zst # tmp.zst should not be created
Yann Colletde95f962016-05-23 19:46:47 +0200175
Nick Terrell4680e852017-12-12 18:32:50 -0800176$ECHO "test : compress multiple files"
177$ECHO hello > tmp1
178$ECHO world > tmp2
179$ZSTD tmp1 tmp2 -o "$INTOVOID"
180$ZSTD tmp1 tmp2 -c | $ZSTD -t
181$ZSTD tmp1 tmp2 -o tmp.zst
182test ! -f tmp1.zst
183test ! -f tmp2.zst
184$ZSTD tmp1 tmp2
185$ZSTD -t tmp1.zst tmp2.zst
186$ZSTD -dc tmp1.zst tmp2.zst
187$ZSTD tmp1.zst tmp2.zst -o "$INTOVOID"
188$ZSTD -d tmp1.zst tmp2.zst -o tmp
189rm tmp*
190
191
Yann Colletde95f962016-05-23 19:46:47 +0200192
Yann Collet241c57a2017-10-16 14:01:42 -0700193$ECHO "\n===> Advanced compression parameters "
Przemyslaw Skibinski24a42362016-12-14 18:07:31 +0100194$ECHO "Hello world!" | $ZSTD --zstd=windowLog=21, - -o tmp.zst && die "wrong parameters not detected!"
195$ECHO "Hello world!" | $ZSTD --zstd=windowLo=21 - -o tmp.zst && die "wrong parameters not detected!"
Przemyslaw Skibinskif9a56662016-12-14 18:43:06 +0100196$ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!"
Yann Collet01a1abf2017-05-05 19:15:24 -0700197test ! -f tmp.zst # tmp.zst should not be created
Przemyslaw Skibinski9b4fa0d2016-12-14 16:50:00 +0100198roundTripTest -g512K
Przemyslaw Skibinskiab5ed6f2016-12-14 17:10:38 +0100199roundTripTest -g512K " --zstd=slen=3,tlen=48,strat=6"
200roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
Przemyslaw Skibinski9b4fa0d2016-12-14 16:50:00 +0100201roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6"
Nick Terrell1fe762e2017-09-18 14:36:17 -0700202roundTripTest -g512K " --long --zstd=ldmHashLog=20,ldmSearchLength=64,ldmBucketSizeLog=1,ldmHashEveryLog=7"
203roundTripTest -g512K " --long --zstd=ldmhlog=20,ldmslen=64,ldmblog=1,ldmhevery=7"
Przemyslaw Skibinski9b4fa0d2016-12-14 16:50:00 +0100204roundTripTest -g512K 19
205
206
Yann Collet241c57a2017-10-16 14:01:42 -0700207$ECHO "\n===> Pass-Through mode "
Yann Collet743b33f2016-12-02 15:18:57 -0800208$ECHO "Hello world 1!" | $ZSTD -df
209$ECHO "Hello world 2!" | $ZSTD -dcf
210$ECHO "Hello world 3!" > tmp1
211$ZSTD -dcf tmp1
Yann Colletde95f962016-05-23 19:46:47 +0200212
Yann Collet8154c3d2016-02-13 03:12:10 +0100213
Yann Collet241c57a2017-10-16 14:01:42 -0700214$ECHO "\n===> frame concatenation "
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300215
inikep5d589562016-05-25 10:50:28 +0200216$ECHO "hello " > hello.tmp
217$ECHO "world!" > world.tmp
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300218cat hello.tmp world.tmp > helloworld.tmp
Yann Colletc8da2c92016-02-12 02:56:27 +0100219$ZSTD -c hello.tmp > hello.zstd
220$ZSTD -c world.tmp > world.zstd
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300221cat hello.zstd world.zstd > helloworld.zstd
Yann Colletc8da2c92016-02-12 02:56:27 +0100222$ZSTD -dc helloworld.zstd > result.tmp
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300223cat result.tmp
Yann Colletbd6bc222017-01-22 15:54:14 -0800224$DIFF helloworld.tmp result.tmp
Yann Collet4c5bbf62016-07-28 20:30:25 +0200225$ECHO "frame concatenation without checksum"
226$ZSTD -c hello.tmp > hello.zstd --no-check
227$ZSTD -c world.tmp > world.zstd --no-check
228cat hello.zstd world.zstd > helloworld.zstd
229$ZSTD -dc helloworld.zstd > result.tmp
230cat result.tmp
Yann Colletbd6bc222017-01-22 15:54:14 -0800231$DIFF helloworld.tmp result.tmp
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300232rm ./*.tmp ./*.zstd
inikep5d589562016-05-25 10:50:28 +0200233$ECHO "frame concatenation tests completed"
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300234
Yann Colletf0624362016-02-12 15:56:46 +0100235
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100236if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
inikep5d589562016-05-25 10:50:28 +0200237$ECHO "\n**** flush write error test **** "
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300238
inikep5d589562016-05-25 10:50:28 +0200239$ECHO "$ECHO foo | $ZSTD > /dev/full"
240$ECHO foo | $ZSTD > /dev/full && die "write error not detected!"
241$ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full"
242$ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
Sean Purcell680e4e02017-03-23 11:52:09 -0700243
Yann Collet01a1abf2017-05-05 19:15:24 -0700244
Yann Collet241c57a2017-10-16 14:01:42 -0700245$ECHO "\n===> symbolic link test "
Sean Purcell680e4e02017-03-23 11:52:09 -0700246
247rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
248$ECHO "hello world" > hello.tmp
249ln -s hello.tmp world.tmp
250$ZSTD world.tmp hello.tmp
Yann Collet01a1abf2017-05-05 19:15:24 -0700251test -f hello.tmp.zst # regular file should have been compressed!
252test ! -f world.tmp.zst # symbolic link should not have been compressed!
Sean Purcell680e4e02017-03-23 11:52:09 -0700253$ZSTD world.tmp hello.tmp -f
Yann Collet01a1abf2017-05-05 19:15:24 -0700254test -f world.tmp.zst # symbolic link should have been compressed with --force
Sean Purcell680e4e02017-03-23 11:52:09 -0700255rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
256
inikep5d589562016-05-25 10:50:28 +0200257fi
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300258
Yann Collet6a458352015-12-18 02:51:14 +0100259
Yann Collet241c57a2017-10-16 14:01:42 -0700260$ECHO "\n===> test sparse file support "
Yann Collet32990b52016-05-23 17:48:57 +0200261
262./datagen -g5M -P100 > tmpSparse
263$ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100264$DIFF -s tmpSparse tmpSparseRegen
Yann Collet32990b52016-05-23 17:48:57 +0200265$ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100266$DIFF -s tmpSparse tmpOutSparse
Yann Collet32990b52016-05-23 17:48:57 +0200267$ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100268$DIFF -s tmpSparse tmpOutNoSparse
Yann Collet01a1abf2017-05-05 19:15:24 -0700269ls -ls tmpSparse* # look at file size and block size on disk
Yann Collet32990b52016-05-23 17:48:57 +0200270./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks)
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100271./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
Yann Collet01a1abf2017-05-05 19:15:24 -0700272ls -ls tmpSparseOdd # look at file size and block size on disk
inikep5d589562016-05-25 10:50:28 +0200273$ECHO "\n Sparse Compatibility with Console :"
274$ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c
275$ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
276$ECHO "\n Sparse Compatibility with Append :"
Yann Collet32990b52016-05-23 17:48:57 +0200277./datagen -P100 -g1M > tmpSparse1M
278cat tmpSparse1M tmpSparse1M > tmpSparse2M
279$ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
280$ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
281$ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
Yann Collet01a1abf2017-05-05 19:15:24 -0700282ls -ls tmpSparse* # look at file size and block size on disk
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100283$DIFF tmpSparse2M tmpSparseRegenerated
Yann Collet33341de2016-05-29 23:09:51 +0200284rm tmpSparse*
Yann Collet32990b52016-05-23 17:48:57 +0200285
286
Yann Collet241c57a2017-10-16 14:01:42 -0700287$ECHO "\n===> multiple files tests "
Yann Collet9b998e42016-06-15 23:11:20 +0200288
Yann Collet391a1282016-06-21 17:06:25 +0200289./datagen -s1 > tmp1 2> $INTOVOID
290./datagen -s2 -g100K > tmp2 2> $INTOVOID
291./datagen -s3 -g1M > tmp3 2> $INTOVOID
Yann Collet9b998e42016-06-15 23:11:20 +0200292$ECHO "compress tmp* : "
Yann Collet60ba31c2016-07-28 19:55:09 +0200293$ZSTD -f tmp*
Yann Collet9b998e42016-06-15 23:11:20 +0200294ls -ls tmp*
295rm tmp1 tmp2 tmp3
296$ECHO "decompress tmp* : "
297$ZSTD -df *.zst
298ls -ls tmp*
299$ECHO "compress tmp* into stdout > tmpall : "
300$ZSTD -c tmp1 tmp2 tmp3 > tmpall
Yann Collet01a1abf2017-05-05 19:15:24 -0700301ls -ls tmp* # check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
Yann Collet9b998e42016-06-15 23:11:20 +0200302$ECHO "decompress tmpall* into stdout > tmpdec : "
303cp tmpall tmpall2
304$ZSTD -dc tmpall* > tmpdec
Yann Collet01a1abf2017-05-05 19:15:24 -0700305ls -ls tmp* # check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3))
Yann Collet9b998e42016-06-15 23:11:20 +0200306$ECHO "compress multiple files including a missing one (notHere) : "
307$ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
308
309
Yann Collet241c57a2017-10-16 14:01:42 -0700310$ECHO "\n===> dictionary tests "
Yann Colletf6f3d752015-12-13 13:35:21 +0100311
Yann Colletbd7fa212017-02-26 14:43:07 -0800312$ECHO "- test with raw dict (content only) "
Yann Colletf6f3d752015-12-13 13:35:21 +0100313./datagen > tmpDict
inikep93fc13e2016-05-30 10:17:55 +0200314./datagen -g1M | $MD5SUM > tmp1
315./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100316$DIFF -q tmp1 tmp2
Yann Colletbd7fa212017-02-26 14:43:07 -0800317$ECHO "- Create first dictionary "
318TESTFILE=../programs/zstdcli.c
inikepb7d34492016-08-18 15:13:41 +0200319$ZSTD --train *.c ../programs/*.c -o tmpDict
320cp $TESTFILE tmp
Yann Collet6381e992016-05-31 02:29:45 +0200321$ZSTD -f tmp -D tmpDict
Yann Collet27b5ac62016-09-21 14:20:56 +0200322$ZSTD -d tmp.zst -D tmpDict -fo result
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100323$DIFF $TESTFILE result
Yann Colletbd7fa212017-02-26 14:43:07 -0800324$ECHO "- Create second (different) dictionary "
inikepb7d34492016-08-18 15:13:41 +0200325$ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC
Yann Collet27b5ac62016-09-21 14:20:56 +0200326$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
Yann Collet531a4272016-06-15 19:02:11 +0200327$ECHO "- Create dictionary with short dictID"
Yann Collet4c41d372017-03-24 18:36:56 -0700328$ZSTD --train *.c ../programs/*.c --dictID=1 -o tmpDict1
Yann Collet290aaa72016-05-30 21:18:52 +0200329cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
Yann Collet27b5ac62016-09-21 14:20:56 +0200330$ECHO "- Create dictionary with wrong dictID parameter order (must fail)"
331$ZSTD --train *.c ../programs/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
332$ECHO "- Create dictionary with size limit"
Yann Collet4c41d372017-03-24 18:36:56 -0700333$ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict=4K -v
Nick Terrell35875562017-08-21 11:16:47 -0700334$ECHO "- Create dictionary with small size limit"
335$ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict=1K -v
Yann Collet27b5ac62016-09-21 14:20:56 +0200336$ECHO "- Create dictionary with wrong parameter order (must fail)"
Nick Terrell35875562017-08-21 11:16:47 -0700337$ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
Yann Collet531a4272016-06-15 19:02:11 +0200338$ECHO "- Compress without dictID"
Yann Collet6381e992016-05-31 02:29:45 +0200339$ZSTD -f tmp -D tmpDict1 --no-dictID
Yann Collet27b5ac62016-09-21 14:20:56 +0200340$ZSTD -d tmp.zst -D tmpDict -fo result
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100341$DIFF $TESTFILE result
Yann Collet27b5ac62016-09-21 14:20:56 +0200342$ECHO "- Compress with wrong argument order (must fail)"
Sean Purcell9a38dfa2017-03-17 12:32:18 -0700343$ZSTD tmp -Df tmpDict1 -c > $INTOVOID && die "-D must be followed by dictionary name "
Yann Collet531a4272016-06-15 19:02:11 +0200344$ECHO "- Compress multiple files with dictionary"
Yann Collet531a4272016-06-15 19:02:11 +0200345rm -rf dirTestDict
346mkdir dirTestDict
347cp *.c dirTestDict
inikepb7d34492016-08-18 15:13:41 +0200348cp ../programs/*.c dirTestDict
349cp ../programs/*.h dirTestDict
Yann Collet94376ac2016-08-25 19:09:21 +0200350$MD5SUM dirTestDict/* > tmph1
351$ZSTD -f --rm dirTestDict/* -D tmpDictC
Yann Colletbb93d772016-08-25 22:22:50 +0200352$ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
Dimitry Andric12df6da2016-12-12 19:22:47 +0100353case "$UNAME" in
354 Darwin) $ECHO "md5sum -c not supported on OS-X : test skipped" ;; # not compatible with OS-X's md5
Yann Collet94d1a932016-12-06 12:02:56 -0800355 *) $MD5SUM -c tmph1 ;;
356esac
Yann Collet531a4272016-06-15 19:02:11 +0200357rm -rf dirTestDict
Yann Colletf332ece2017-03-23 16:24:02 -0700358$ECHO "- dictionary builder on bogus input"
359$ECHO "Hello World" > tmp
Nick Terrellf376d472017-05-01 23:40:20 -0700360$ZSTD --train-legacy -q tmp && die "Dictionary training should fail : not enough input source"
Yann Colletf332ece2017-03-23 16:24:02 -0700361./datagen -P0 -g10M > tmp
Nick Terrellf376d472017-05-01 23:40:20 -0700362$ZSTD --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise"
Yann Collet6381e992016-05-31 02:29:45 +0200363rm tmp*
Yann Colletb44be742016-03-26 20:52:14 +0100364
Yann Colletf6f3d752015-12-13 13:35:21 +0100365
Yann Collet241c57a2017-10-16 14:01:42 -0700366$ECHO "\n===> cover dictionary builder : advanced options "
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500367
368TESTFILE=../programs/zstdcli.c
369./datagen > tmpDict
370$ECHO "- Create first dictionary"
Nick Terrellf376d472017-05-01 23:40:20 -0700371$ZSTD --train-cover=k=46,d=8 *.c ../programs/*.c -o tmpDict
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500372cp $TESTFILE tmp
373$ZSTD -f tmp -D tmpDict
374$ZSTD -d tmp.zst -D tmpDict -fo result
375$DIFF $TESTFILE result
376$ECHO "- Create second (different) dictionary"
Nick Terrellf376d472017-05-01 23:40:20 -0700377$ZSTD --train-cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500378$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
379$ECHO "- Create dictionary with short dictID"
Nick Terrellf376d472017-05-01 23:40:20 -0700380$ZSTD --train-cover=k=46,d=8 *.c ../programs/*.c --dictID=1 -o tmpDict1
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500381cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
382$ECHO "- Create dictionary with size limit"
Nick Terrellf376d472017-05-01 23:40:20 -0700383$ZSTD --train-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
384rm tmp*
385
Yann Collet241c57a2017-10-16 14:01:42 -0700386$ECHO "\n===> legacy dictionary builder "
Nick Terrellf376d472017-05-01 23:40:20 -0700387
388TESTFILE=../programs/zstdcli.c
389./datagen > tmpDict
390$ECHO "- Create first dictionary"
391$ZSTD --train-legacy=selectivity=8 *.c ../programs/*.c -o tmpDict
392cp $TESTFILE tmp
393$ZSTD -f tmp -D tmpDict
394$ZSTD -d tmp.zst -D tmpDict -fo result
395$DIFF $TESTFILE result
396$ECHO "- Create second (different) dictionary"
397$ZSTD --train-legacy=s=5 *.c ../programs/*.c ../programs/*.h -o tmpDictC
398$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
399$ECHO "- Create dictionary with short dictID"
400$ZSTD --train-legacy -s5 *.c ../programs/*.c --dictID=1 -o tmpDict1
401cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
402$ECHO "- Create dictionary with size limit"
403$ZSTD --train-legacy -s9 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500404rm tmp*
405
406
Yann Collet241c57a2017-10-16 14:01:42 -0700407$ECHO "\n===> integrity tests "
Yann Colletde95f962016-05-23 19:46:47 +0200408
inikep5d589562016-05-25 10:50:28 +0200409$ECHO "test one file (tmp1.zst) "
Yann Collet1a7b8fb2016-06-15 23:33:38 +0200410./datagen > tmp1
411$ZSTD tmp1
Yann Collet459a6b72016-02-15 20:37:23 +0100412$ZSTD -t tmp1.zst
Yann Collet2d08b092016-02-16 14:42:08 +0100413$ZSTD --test tmp1.zst
inikep5d589562016-05-25 10:50:28 +0200414$ECHO "test multiple files (*.zst) "
Yann Collet459a6b72016-02-15 20:37:23 +0100415$ZSTD -t *.zst
Yann Collet24a3d902016-07-26 01:26:56 +0200416$ECHO "test bad files (*) "
Yann Collet459a6b72016-02-15 20:37:23 +0100417$ZSTD -t * && die "bad files not detected !"
Yann Collet24a3d902016-07-26 01:26:56 +0200418$ZSTD -t tmp1 && die "bad file not detected !"
419cp tmp1 tmp2.zst
420$ZSTD -t tmp2.zst && die "bad file not detected !"
Yann Collet7adc2322016-07-26 15:39:31 +0200421./datagen -g0 > tmp3
422$ZSTD -t tmp3 && die "bad file not detected !" # detects 0-sized files as bad
Yann Colletb4024902016-07-26 00:49:47 +0200423$ECHO "test --rm and --test combined "
424$ZSTD -t --rm tmp1.zst
Yann Collet01a1abf2017-05-05 19:15:24 -0700425test -f tmp1.zst # check file is still present
426split -b16384 tmp1.zst tmpSplit.
427$ZSTD -t tmpSplit.* && die "bad file not detected !"
Nick Terrelld0b27482017-07-18 14:45:49 -0700428./datagen | $ZSTD -c | $ZSTD -t
Yann Colletdeb078b2015-12-17 20:30:14 +0100429
Yann Colletde95f962016-05-23 19:46:47 +0200430
Nick Terrellabe12b32017-07-28 11:54:28 -0700431
Yann Collet241c57a2017-10-16 14:01:42 -0700432$ECHO "\n===> golden files tests "
Nick Terrellabe12b32017-07-28 11:54:28 -0700433
434$ZSTD -t -r files
435$ZSTD -c -r files | $ZSTD -t
436
437
Yann Collet241c57a2017-10-16 14:01:42 -0700438$ECHO "\n===> benchmark mode tests "
Yann Colletb9550d62016-10-28 14:43:24 -0700439
440$ECHO "bench one file"
441./datagen > tmp1
Yann Colletc1c040e2017-03-01 16:49:20 -0800442$ZSTD -bi0 tmp1
Yann Colletb9550d62016-10-28 14:43:24 -0700443$ECHO "bench multiple levels"
Yann Colletc1c040e2017-03-01 16:49:20 -0800444$ZSTD -i0b0e3 tmp1
Yann Colletb9550d62016-10-28 14:43:24 -0700445$ECHO "with recursive and quiet modes"
Yann Colletc1c040e2017-03-01 16:49:20 -0800446$ZSTD -rqi1b1e2 tmp1
447
448
Yann Collet241c57a2017-10-16 14:01:42 -0700449$ECHO "\n===> gzip compatibility tests "
Yann Colletc1c040e2017-03-01 16:49:20 -0800450
451GZIPMODE=1
452$ZSTD --format=gzip -V || GZIPMODE=0
453if [ $GZIPMODE -eq 1 ]; then
Yann Collet27526c72017-03-01 17:02:49 -0800454 $ECHO "gzip support detected"
Yann Colletc1c040e2017-03-01 16:49:20 -0800455 GZIPEXE=1
Yann Collet27526c72017-03-01 17:02:49 -0800456 gzip -V || GZIPEXE=0
Yann Colletc1c040e2017-03-01 16:49:20 -0800457 if [ $GZIPEXE -eq 1 ]; then
458 ./datagen > tmp
459 $ZSTD --format=gzip -f tmp
460 gzip -t -v tmp.gz
461 gzip -f tmp
462 $ZSTD -d -f -v tmp.gz
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700463 rm tmp*
Yann Colletc1c040e2017-03-01 16:49:20 -0800464 else
465 $ECHO "gzip binary not detected"
466 fi
467else
468 $ECHO "gzip mode not supported"
469fi
Yann Colletb9550d62016-10-28 14:43:24 -0700470
471
Yann Collet241c57a2017-10-16 14:01:42 -0700472$ECHO "\n===> gzip frame tests "
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700473
474if [ $GZIPMODE -eq 1 ]; then
475 ./datagen > tmp
476 $ZSTD -f --format=gzip tmp
477 $ZSTD -f tmp
478 cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp
Sean Purcell4de86322017-04-24 16:48:25 -0700479 head -c -1 tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700480 rm tmp*
481else
482 $ECHO "gzip mode not supported"
483fi
484
485
Yann Collet241c57a2017-10-16 14:01:42 -0700486$ECHO "\n===> xz compatibility tests "
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700487
488LZMAMODE=1
489$ZSTD --format=xz -V || LZMAMODE=0
490if [ $LZMAMODE -eq 1 ]; then
491 $ECHO "xz support detected"
492 XZEXE=1
493 xz -V && lzma -V || XZEXE=0
494 if [ $XZEXE -eq 1 ]; then
Nick Terrell6aeb50e2017-06-26 11:24:36 -0700495 $ECHO "Testing zstd xz and lzma support"
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700496 ./datagen > tmp
497 $ZSTD --format=lzma -f tmp
498 $ZSTD --format=xz -f tmp
499 xz -t -v tmp.xz
500 xz -t -v tmp.lzma
501 xz -f -k tmp
502 lzma -f -k --lzma1 tmp
503 $ZSTD -d -f -v tmp.xz
504 $ZSTD -d -f -v tmp.lzma
505 rm tmp*
Nick Terrell6aeb50e2017-06-26 11:24:36 -0700506 $ECHO "Creating symlinks"
507 ln -s $ZSTD ./xz
508 ln -s $ZSTD ./unxz
509 ln -s $ZSTD ./lzma
510 ln -s $ZSTD ./unlzma
511 $ECHO "Testing xz and lzma symlinks"
512 ./datagen > tmp
513 ./xz tmp
514 xz -d tmp.xz
515 ./lzma tmp
516 lzma -d tmp.lzma
517 $ECHO "Testing unxz and unlzma symlinks"
518 xz tmp
519 ./xz -d tmp.xz
520 lzma tmp
521 ./lzma -d tmp.lzma
522 rm xz unxz lzma unlzma
523 rm tmp*
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700524 else
525 $ECHO "xz binary not detected"
526 fi
527else
528 $ECHO "xz mode not supported"
529fi
530
531
Yann Collet241c57a2017-10-16 14:01:42 -0700532$ECHO "\n===> xz frame tests "
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700533
534if [ $LZMAMODE -eq 1 ]; then
535 ./datagen > tmp
536 $ZSTD -f --format=xz tmp
537 $ZSTD -f --format=lzma tmp
538 $ZSTD -f tmp
539 cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp
Sean Purcell4de86322017-04-24 16:48:25 -0700540 head -c -1 tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
541 head -c -1 tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700542 rm tmp*
543else
544 $ECHO "xz mode not supported"
545fi
546
Yann Collet241c57a2017-10-16 14:01:42 -0700547$ECHO "\n===> lz4 compatibility tests "
Sean Purcell4de86322017-04-24 16:48:25 -0700548
549LZ4MODE=1
550$ZSTD --format=lz4 -V || LZ4MODE=0
551if [ $LZ4MODE -eq 1 ]; then
552 $ECHO "lz4 support detected"
553 LZ4EXE=1
554 lz4 -V || LZ4EXE=0
555 if [ $LZ4EXE -eq 1 ]; then
556 ./datagen > tmp
557 $ZSTD --format=lz4 -f tmp
558 lz4 -t -v tmp.lz4
559 lz4 -f tmp
560 $ZSTD -d -f -v tmp.lz4
561 rm tmp*
562 else
563 $ECHO "lz4 binary not detected"
564 fi
565else
566 $ECHO "lz4 mode not supported"
567fi
568
569
Yann Collet241c57a2017-10-16 14:01:42 -0700570$ECHO "\n===> lz4 frame tests "
Sean Purcell4de86322017-04-24 16:48:25 -0700571
572if [ $LZ4MODE -eq 1 ]; then
573 ./datagen > tmp
574 $ZSTD -f --format=lz4 tmp
575 $ZSTD -f tmp
576 cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp
577 head -c -1 tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
578 rm tmp*
579else
580 $ECHO "lz4 mode not supported"
581fi
Nick Terrellaa8bcf32017-03-13 18:11:07 -0700582
Yann Collet241c57a2017-10-16 14:01:42 -0700583$ECHO "\n===> zstd round-trip tests "
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300584
585roundTripTest
Yann Collet3b719252016-03-30 19:48:05 +0200586roundTripTest -g15K # TableID==3
587roundTripTest -g127K # TableID==2
588roundTripTest -g255K # TableID==1
Yann Colletc1c040e2017-03-01 16:49:20 -0800589roundTripTest -g522K # TableID==0
590roundTripTest -g519K 6 # greedy, hash chain
591roundTripTest -g517K 16 # btlazy2
592roundTripTest -g516K 19 # btopt
Yann Collet459a6b72016-02-15 20:37:23 +0100593
Sean Purcelleb70d212017-04-11 17:15:13 -0700594fileRoundTripTest -g500K
595
Yann Collet241c57a2017-10-16 14:01:42 -0700596$ECHO "\n===> zstd long distance matching round-trip tests "
Stella Lau6a546ef2017-07-28 15:51:33 -0700597roundTripTest -g0 "2 --long"
598roundTripTest -g1000K "1 --long"
599roundTripTest -g517K "6 --long"
600roundTripTest -g516K "16 --long"
601roundTripTest -g518K "19 --long"
602fileRoundTripTest -g5M "3 --long"
603
604
Sean Purcellc424ec22017-04-17 11:38:53 -0700605if [ -n "$hasMT" ]
606then
Yann Collet241c57a2017-10-16 14:01:42 -0700607 $ECHO "\n===> zstdmt round-trip tests "
Sean Purcelld845dab2017-04-17 12:10:58 -0700608 roundTripTest -g4M "1 -T0"
609 roundTripTest -g8M "3 -T2"
Yann Collet230d7ac2017-04-21 11:38:13 -0700610 roundTripTest -g8000K "2 --threads=2"
Sean Purcelld845dab2017-04-17 12:10:58 -0700611 fileRoundTripTest -g4M "19 -T2 -B1M"
Stella Lau6a546ef2017-07-28 15:51:33 -0700612
Yann Collet241c57a2017-10-16 14:01:42 -0700613 $ECHO "\n===> zstdmt long distance matching round-trip tests "
Stella Lau6a546ef2017-07-28 15:51:33 -0700614 roundTripTest -g8M "3 --long -T2"
Sean Purcellc424ec22017-04-17 11:38:53 -0700615else
Yann Collet241c57a2017-10-16 14:01:42 -0700616 $ECHO "\n===> no multithreading, skipping zstdmt tests "
Sean Purcellc424ec22017-04-17 11:38:53 -0700617fi
618
Yann Collet459a6b72016-02-15 20:37:23 +0100619rm tmp*
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300620
Yann Collet241c57a2017-10-16 14:01:42 -0700621$ECHO "\n===> zstd --list/-l single frame tests "
Paul Cruzddd1ab72017-06-15 16:53:03 -0700622./datagen > tmp1
623./datagen > tmp2
624./datagen > tmp3
Paul Cruzddd1ab72017-06-15 16:53:03 -0700625$ZSTD tmp*
Paul Cruz6a99de22017-06-20 10:45:06 -0700626$ZSTD -l *.zst
Yann Collet43914f62017-10-13 23:47:01 -0700627$ZSTD -lv *.zst | grep "Decompressed Size:" # check that decompressed size is present in header
Paul Cruz6a99de22017-06-20 10:45:06 -0700628$ZSTD --list *.zst
629$ZSTD --list -v *.zst
Paul Cruzddd1ab72017-06-15 16:53:03 -0700630
Yann Collet241c57a2017-10-16 14:01:42 -0700631$ECHO "\n===> zstd --list/-l multiple frame tests "
Paul Cruzddd1ab72017-06-15 16:53:03 -0700632cat tmp1.zst tmp2.zst > tmp12.zst
Yann Collet60059df2017-09-27 15:16:27 -0700633cat tmp12.zst tmp3.zst > tmp123.zst
Paul Cruz6a99de22017-06-20 10:45:06 -0700634$ZSTD -l *.zst
635$ZSTD -lv *.zst
Paul Cruzddd1ab72017-06-15 16:53:03 -0700636
Yann Collet241c57a2017-10-16 14:01:42 -0700637$ECHO "\n===> zstd --list/-l error detection tests "
Paul Cruz58c19b42017-06-20 14:14:53 -0700638! $ZSTD -l tmp1 tmp1.zst
639! $ZSTD --list tmp*
640! $ZSTD -lv tmp1*
Yann Collet60059df2017-09-27 15:16:27 -0700641! $ZSTD --list -v tmp2 tmp12.zst
Paul Cruzb07d0af2017-06-20 11:54:44 -0700642
Yann Collet241c57a2017-10-16 14:01:42 -0700643$ECHO "\n===> zstd --list/-l test with null files "
Paul Cruza73c2a42017-06-20 14:33:08 -0700644./datagen -g0 > tmp5
645$ZSTD tmp5
Yann Colletc16748b2017-06-21 12:09:53 -0700646$ZSTD -l tmp5.zst
Paul Cruza73c2a42017-06-20 14:33:08 -0700647! $ZSTD -l tmp5*
Yann Collet5891f1d2017-10-17 16:23:20 -0700648$ZSTD -lv tmp5.zst | grep "Decompressed Size: 0.00 KB (0 B)" # check that 0 size is present in header
Paul Cruza73c2a42017-06-20 14:33:08 -0700649! $ZSTD -lv tmp5*
Paul Cruza73c2a42017-06-20 14:33:08 -0700650
Yann Collet241c57a2017-10-16 14:01:42 -0700651$ECHO "\n===> zstd --list/-l test with no content size field "
Yann Collet43914f62017-10-13 23:47:01 -0700652./datagen -g513K | $ZSTD > tmp6.zst
Paul Cruzdb3606e2017-06-20 17:43:36 -0700653$ZSTD -l tmp6.zst
Yann Collet43914f62017-10-13 23:47:01 -0700654! $ZSTD -lv tmp6.zst | grep "Decompressed Size:" # must NOT be present in header
Yann Colletc16748b2017-06-21 12:09:53 -0700655
Yann Collet241c57a2017-10-16 14:01:42 -0700656$ECHO "\n===> zstd --list/-l test with no checksum "
Yann Colletc16748b2017-06-21 12:09:53 -0700657$ZSTD -f --no-check tmp1
658$ZSTD -l tmp1.zst
659$ZSTD -lv tmp1.zst
Paul Cruzdb3606e2017-06-20 17:43:36 -0700660
Paul Cruzddd1ab72017-06-15 16:53:03 -0700661rm tmp*
662
Yann Colletc16748b2017-06-21 12:09:53 -0700663
Yann Collet241c57a2017-10-16 14:01:42 -0700664$ECHO "\n===> zstd long distance matching tests "
Yann Collet02502192017-09-27 15:48:06 -0700665roundTripTest -g0 " --long"
666roundTripTest -g9M "2 --long"
667# Test parameter parsing
668roundTripTest -g1M -P50 "1 --long=29" " --memory=512MB"
669roundTripTest -g1M -P50 "1 --long=29 --zstd=wlog=28" " --memory=256MB"
670roundTripTest -g1M -P50 "1 --long=29" " --long=28 --memory=512MB"
671roundTripTest -g1M -P50 "1 --long=29" " --zstd=wlog=28 --memory=512MB"
672
673
Konstantin Tokarev0b570b52015-12-08 18:47:43 +0300674if [ "$1" != "--test-large-data" ]; then
inikep5d589562016-05-25 10:50:28 +0200675 $ECHO "Skipping large data tests"
Konstantin Tokarev0b570b52015-12-08 18:47:43 +0300676 exit 0
677fi
678
Yann Collet241c57a2017-10-16 14:01:42 -0700679$ECHO "\n===> large files tests "
Yann Collet02502192017-09-27 15:48:06 -0700680
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300681roundTripTest -g270000000 1
Yann Collet60059df2017-09-27 15:16:27 -0700682roundTripTest -g250000000 2
683roundTripTest -g230000000 3
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300684
685roundTripTest -g140000000 -P60 4
Yann Collet60059df2017-09-27 15:16:27 -0700686roundTripTest -g130000000 -P62 5
687roundTripTest -g120000000 -P65 6
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300688
689roundTripTest -g70000000 -P70 7
Yann Collet60059df2017-09-27 15:16:27 -0700690roundTripTest -g60000000 -P71 8
691roundTripTest -g50000000 -P73 9
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300692
693roundTripTest -g35000000 -P75 10
Yann Collet60059df2017-09-27 15:16:27 -0700694roundTripTest -g30000000 -P76 11
695roundTripTest -g25000000 -P78 12
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300696
Yann Collet4616fad2017-07-10 17:16:41 -0700697roundTripTest -g18000013 -P80 13
698roundTripTest -g18000014 -P80 14
Yann Collet60059df2017-09-27 15:16:27 -0700699roundTripTest -g18000015 -P81 15
700roundTripTest -g18000016 -P84 16
701roundTripTest -g18000017 -P88 17
Yann Collet4616fad2017-07-10 17:16:41 -0700702roundTripTest -g18000018 -P94 18
Yann Collet60059df2017-09-27 15:16:27 -0700703roundTripTest -g18000019 -P96 19
Konstantin Tokarev2b465842015-12-08 19:36:42 +0300704
Yann Collet60059df2017-09-27 15:16:27 -0700705roundTripTest -g5000000000 -P99 1
Yann Collet459a6b72016-02-15 20:37:23 +0100706
Sean Purcelleb70d212017-04-11 17:15:13 -0700707fileRoundTripTest -g4193M -P99 1
708
Yann Collet02502192017-09-27 15:48:06 -0700709
Yann Collet241c57a2017-10-16 14:01:42 -0700710$ECHO "\n===> zstd long, long distance matching round-trip tests "
Stella Lau6a546ef2017-07-28 15:51:33 -0700711roundTripTest -g270000000 "1 --long"
Yann Collet60059df2017-09-27 15:16:27 -0700712roundTripTest -g130000000 -P60 "5 --long"
713roundTripTest -g35000000 -P70 "8 --long"
Stella Lau6a546ef2017-07-28 15:51:33 -0700714roundTripTest -g18000001 -P80 "18 --long"
Nick Terrellc233bdb2017-09-22 14:04:39 -0700715# Test large window logs
Yann Colletf9de54a2017-09-27 15:38:27 -0700716roundTripTest -g700M -P50 "1 --long=29"
717roundTripTest -g600M -P50 "1 --long --zstd=wlog=29,clog=28"
Stella Lau6a546ef2017-07-28 15:51:33 -0700718
719
Sean Purcellc424ec22017-04-17 11:38:53 -0700720if [ -n "$hasMT" ]
721then
Yann Collet241c57a2017-10-16 14:01:42 -0700722 $ECHO "\n===> zstdmt long round-trip tests "
Yann Collet60059df2017-09-27 15:16:27 -0700723 roundTripTest -g80000000 -P99 "19 -T2" " "
724 roundTripTest -g5000000000 -P99 "1 -T2" " "
725 roundTripTest -g500000000 -P97 "1 -T999" " "
726 fileRoundTripTest -g4103M -P98 " -T0" " "
727 roundTripTest -g400000000 -P97 "1 --long=24 -T2" " "
Sean Purcellc424ec22017-04-17 11:38:53 -0700728else
729 $ECHO "\n**** no multithreading, skipping zstdmt tests **** "
730fi
731
Yann Collet459a6b72016-02-15 20:37:23 +0100732rm tmp*