blob: c465fee3c7ab59b75ef741e2739ad72ad822b845 [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
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +010010 local_c="$3"
11 local_p="$2"
Konstantin Tokarev76be3782015-12-08 18:36:37 +030012 else
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +010013 local_c="$2"
Konstantin Tokarev76be3782015-12-08 18:36:37 +030014 fi
15
16 rm -f tmp1 tmp2
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +010017 $ECHO "roundTripTest: ./datagen $1 $local_p | $ZSTD -v$local_c | $ZSTD -d"
18 ./datagen $1 $local_p | $MD5SUM > tmp1
19 ./datagen $1 $local_p | $ZSTD --ultra -v$local_c | $ZSTD -d | $MD5SUM > tmp2
20 $DIFF -q tmp1 tmp2
Konstantin Tokarev76be3782015-12-08 18:36:37 +030021}
22
inikep5d589562016-05-25 10:50:28 +020023isWindows=false
24ECHO="echo"
Yann Collet391a1282016-06-21 17:06:25 +020025INTOVOID="/dev/null"
inikep993a9df2016-05-27 10:07:46 +020026case "$OS" in
Yann Collet673f0d72016-06-06 00:26:38 +020027 Windows*)
inikep5d589562016-05-25 10:50:28 +020028 isWindows=true
29 ECHO="echo -e"
inikep993a9df2016-05-27 10:07:46 +020030 ;;
31esac
inikep5d589562016-05-25 10:50:28 +020032
Dimitry Andric12df6da2016-12-12 19:22:47 +010033UNAME=$(uname)
34case "$UNAME" in
35 Darwin) MD5SUM="md5 -r" ;;
36 FreeBSD) MD5SUM="gmd5sum" ;;
Yann Collet94d1a932016-12-06 12:02:56 -080037 *) MD5SUM="md5sum" ;;
38esac
inikep5d589562016-05-25 10:50:28 +020039
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +010040DIFF="diff"
41case "$UNAME" in
42 SunOS) DIFF="gdiff" ;;
43esac
44
45
Przemyslaw Skibinskie579ab52016-11-14 12:57:05 +010046$ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
inikep5d589562016-05-25 10:50:28 +020047
Konstantin Tokarev76be3782015-12-08 18:36:37 +030048[ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
49
inikep5d589562016-05-25 10:50:28 +020050$ECHO "\n**** simple tests **** "
Yann Colletde95f962016-05-23 19:46:47 +020051
Yann Collet8154c3d2016-02-13 03:12:10 +010052./datagen > tmp
Yann Colletb3060f72016-09-09 16:44:16 +020053$ECHO "test : basic compression "
Yann Collet673f0d72016-06-06 00:26:38 +020054$ZSTD -f tmp # trivial compression case, creates tmp.zst
Yann Colletb3060f72016-09-09 16:44:16 +020055$ECHO "test : basic decompression"
Yann Collet673f0d72016-06-06 00:26:38 +020056$ZSTD -df tmp.zst # trivial decompression case (overwrites tmp)
inikep5d589562016-05-25 10:50:28 +020057$ECHO "test : too large compression level (must fail)"
Yann Colletfab02302016-08-12 19:00:18 +020058$ZSTD -99 -f tmp # too large compression level, automatic sized down
inikep5d589562016-05-25 10:50:28 +020059$ECHO "test : compress to stdout"
Yann Collet0d348d42016-05-29 02:02:24 +020060$ZSTD tmp -c > tmpCompressed
Yann Colletd6931172016-05-10 05:56:09 +020061$ZSTD tmp --stdout > tmpCompressed # long command format
Yann Collet27b5ac62016-09-21 14:20:56 +020062$ECHO "test : compress to named file"
63rm tmpCompressed
64$ZSTD tmp -o tmpCompressed
65ls tmpCompressed # must work
66$ECHO "test : -o must be followed by filename (must fail)"
Yann Collet714464f2016-09-21 16:05:03 +020067$ZSTD tmp -of tmpCompressed && die "-o must be followed by filename "
Yann Collet27b5ac62016-09-21 14:20:56 +020068$ECHO "test : force write, correct order"
69$ZSTD tmp -fo tmpCompressed
Yann Collet714464f2016-09-21 16:05:03 +020070$ECHO "test : forgotten argument"
71cp tmp tmp2
72$ZSTD tmp2 -fo && die "-o must be followed by filename "
Yann Colletc8431422016-09-01 15:05:57 -070073$ECHO "test : implied stdout when input is stdin"
74$ECHO bob | $ZSTD | $ZSTD -d
inikep5d589562016-05-25 10:50:28 +020075$ECHO "test : null-length file roundtrip"
76$ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
77$ECHO "test : decompress file with wrong suffix (must fail)"
Yann Collet2d08b092016-02-16 14:42:08 +010078$ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
Yann Collet391a1282016-06-21 17:06:25 +020079$ZSTD -df tmp && die "should have refused : wrong extension"
80$ECHO "test : decompress into stdout"
Yann Collet0d348d42016-05-29 02:02:24 +020081$ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout
Yann Collet2d08b092016-02-16 14:42:08 +010082$ZSTD --decompress tmpCompressed -c > tmpResult
83$ZSTD --decompress tmpCompressed --stdout > tmpResult
Yann Collet391a1282016-06-21 17:06:25 +020084$ECHO "test : decompress from stdin into stdout"
85$ZSTD -dc < tmp.zst > $INTOVOID # combine decompression, stdin & stdout
86$ZSTD -dc - < tmp.zst > $INTOVOID
87$ZSTD -d < tmp.zst > $INTOVOID # implicit stdout when stdin is used
88$ZSTD -d - < tmp.zst > $INTOVOID
Yann Colletd4cda272016-10-14 13:13:13 -070089$ECHO "test : impose memory limitation (must fail)"
90$ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
Yann Collet11223492016-10-14 14:07:11 -070091$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 -070092$ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
93$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 +020094$ECHO "test : overwrite protection"
Yann Collet2d08b092016-02-16 14:42:08 +010095$ZSTD -q tmp && die "overwrite check failed!"
Yann Collet391a1282016-06-21 17:06:25 +020096$ECHO "test : force overwrite"
Yann Collet2d08b092016-02-16 14:42:08 +010097$ZSTD -q -f tmp
98$ZSTD -q --force tmp
Yann Colletb09b12c2016-06-09 22:59:51 +020099$ECHO "test : file removal"
100$ZSTD -f --rm tmp
101ls tmp && die "tmp should no longer be present"
102$ZSTD -f -d --rm tmp.zst
103ls tmp.zst && die "tmp.zst should no longer be present"
Yann Collet67d86a72017-02-27 16:09:20 -0800104$ECHO "test : --rm on stdin"
105$ECHO a | $ZSTD --rm > $INTOVOID # --rm should remain silent
Yann Colletb09b12c2016-06-09 22:59:51 +0200106rm tmp
107$ZSTD -f tmp && die "tmp not present : should have failed"
108ls tmp.zst && die "tmp.zst should not be created"
Yann Colletde95f962016-05-23 19:46:47 +0200109
110
Przemyslaw Skibinski9b4fa0d2016-12-14 16:50:00 +0100111$ECHO "\n**** Advanced compression parameters **** "
Przemyslaw Skibinski24a42362016-12-14 18:07:31 +0100112$ECHO "Hello world!" | $ZSTD --zstd=windowLog=21, - -o tmp.zst && die "wrong parameters not detected!"
113$ECHO "Hello world!" | $ZSTD --zstd=windowLo=21 - -o tmp.zst && die "wrong parameters not detected!"
Przemyslaw Skibinskif9a56662016-12-14 18:43:06 +0100114$ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!"
Przemyslaw Skibinski24a42362016-12-14 18:07:31 +0100115ls tmp.zst && die "tmp.zst should not be created"
Przemyslaw Skibinski9b4fa0d2016-12-14 16:50:00 +0100116roundTripTest -g512K
Przemyslaw Skibinskiab5ed6f2016-12-14 17:10:38 +0100117roundTripTest -g512K " --zstd=slen=3,tlen=48,strat=6"
118roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
Przemyslaw Skibinski9b4fa0d2016-12-14 16:50:00 +0100119roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6"
120roundTripTest -g512K 19
121
122
inikep5d589562016-05-25 10:50:28 +0200123$ECHO "\n**** Pass-Through mode **** "
Yann Collet743b33f2016-12-02 15:18:57 -0800124$ECHO "Hello world 1!" | $ZSTD -df
125$ECHO "Hello world 2!" | $ZSTD -dcf
126$ECHO "Hello world 3!" > tmp1
127$ZSTD -dcf tmp1
Yann Colletde95f962016-05-23 19:46:47 +0200128
Yann Collet8154c3d2016-02-13 03:12:10 +0100129
inikep5d589562016-05-25 10:50:28 +0200130$ECHO "\n**** frame concatenation **** "
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300131
inikep5d589562016-05-25 10:50:28 +0200132$ECHO "hello " > hello.tmp
133$ECHO "world!" > world.tmp
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300134cat hello.tmp world.tmp > helloworld.tmp
Yann Colletc8da2c92016-02-12 02:56:27 +0100135$ZSTD -c hello.tmp > hello.zstd
136$ZSTD -c world.tmp > world.zstd
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300137cat hello.zstd world.zstd > helloworld.zstd
Yann Colletc8da2c92016-02-12 02:56:27 +0100138$ZSTD -dc helloworld.zstd > result.tmp
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300139cat result.tmp
Yann Colletbd6bc222017-01-22 15:54:14 -0800140$DIFF helloworld.tmp result.tmp
Yann Collet4c5bbf62016-07-28 20:30:25 +0200141$ECHO "frame concatenation without checksum"
142$ZSTD -c hello.tmp > hello.zstd --no-check
143$ZSTD -c world.tmp > world.zstd --no-check
144cat hello.zstd world.zstd > helloworld.zstd
145$ZSTD -dc helloworld.zstd > result.tmp
146cat result.tmp
Yann Colletbd6bc222017-01-22 15:54:14 -0800147$DIFF helloworld.tmp result.tmp
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300148rm ./*.tmp ./*.zstd
inikep5d589562016-05-25 10:50:28 +0200149$ECHO "frame concatenation tests completed"
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300150
Yann Colletf0624362016-02-12 15:56:46 +0100151
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100152if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
inikep5d589562016-05-25 10:50:28 +0200153$ECHO "\n**** flush write error test **** "
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300154
inikep5d589562016-05-25 10:50:28 +0200155$ECHO "$ECHO foo | $ZSTD > /dev/full"
156$ECHO foo | $ZSTD > /dev/full && die "write error not detected!"
157$ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full"
158$ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
159fi
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300160
Yann Collet6a458352015-12-18 02:51:14 +0100161
inikep5d589562016-05-25 10:50:28 +0200162$ECHO "\n**** test sparse file support **** "
Yann Collet32990b52016-05-23 17:48:57 +0200163
164./datagen -g5M -P100 > tmpSparse
165$ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100166$DIFF -s tmpSparse tmpSparseRegen
Yann Collet32990b52016-05-23 17:48:57 +0200167$ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100168$DIFF -s tmpSparse tmpOutSparse
Yann Collet32990b52016-05-23 17:48:57 +0200169$ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100170$DIFF -s tmpSparse tmpOutNoSparse
Yann Collet32990b52016-05-23 17:48:57 +0200171ls -ls tmpSparse*
172./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 +0100173./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
Yann Collet32990b52016-05-23 17:48:57 +0200174ls -ls tmpSparseOdd
inikep5d589562016-05-25 10:50:28 +0200175$ECHO "\n Sparse Compatibility with Console :"
176$ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c
177$ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
178$ECHO "\n Sparse Compatibility with Append :"
Yann Collet32990b52016-05-23 17:48:57 +0200179./datagen -P100 -g1M > tmpSparse1M
180cat tmpSparse1M tmpSparse1M > tmpSparse2M
181$ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
182$ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
183$ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
184ls -ls tmpSparse*
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100185$DIFF tmpSparse2M tmpSparseRegenerated
Yann Collet33341de2016-05-29 23:09:51 +0200186rm tmpSparse*
Yann Collet32990b52016-05-23 17:48:57 +0200187
188
Yann Collet9b998e42016-06-15 23:11:20 +0200189$ECHO "\n**** multiple files tests **** "
190
Yann Collet391a1282016-06-21 17:06:25 +0200191./datagen -s1 > tmp1 2> $INTOVOID
192./datagen -s2 -g100K > tmp2 2> $INTOVOID
193./datagen -s3 -g1M > tmp3 2> $INTOVOID
Yann Collet9b998e42016-06-15 23:11:20 +0200194$ECHO "compress tmp* : "
Yann Collet60ba31c2016-07-28 19:55:09 +0200195$ZSTD -f tmp*
Yann Collet9b998e42016-06-15 23:11:20 +0200196ls -ls tmp*
197rm tmp1 tmp2 tmp3
198$ECHO "decompress tmp* : "
199$ZSTD -df *.zst
200ls -ls tmp*
201$ECHO "compress tmp* into stdout > tmpall : "
202$ZSTD -c tmp1 tmp2 tmp3 > tmpall
203ls -ls tmp*
204$ECHO "decompress tmpall* into stdout > tmpdec : "
205cp tmpall tmpall2
206$ZSTD -dc tmpall* > tmpdec
207ls -ls tmp*
208$ECHO "compress multiple files including a missing one (notHere) : "
209$ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
210
211
inikep5d589562016-05-25 10:50:28 +0200212$ECHO "\n**** dictionary tests **** "
Yann Colletf6f3d752015-12-13 13:35:21 +0100213
inikepb7d34492016-08-18 15:13:41 +0200214TESTFILE=../programs/zstdcli.c
Yann Colletf6f3d752015-12-13 13:35:21 +0100215./datagen > tmpDict
inikep93fc13e2016-05-30 10:17:55 +0200216./datagen -g1M | $MD5SUM > tmp1
217./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100218$DIFF -q tmp1 tmp2
Yann Collet531a4272016-06-15 19:02:11 +0200219$ECHO "- Create first dictionary"
inikepb7d34492016-08-18 15:13:41 +0200220$ZSTD --train *.c ../programs/*.c -o tmpDict
221cp $TESTFILE tmp
Yann Collet6381e992016-05-31 02:29:45 +0200222$ZSTD -f tmp -D tmpDict
Yann Collet27b5ac62016-09-21 14:20:56 +0200223$ZSTD -d tmp.zst -D tmpDict -fo result
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100224$DIFF $TESTFILE result
Yann Collet531a4272016-06-15 19:02:11 +0200225$ECHO "- Create second (different) dictionary"
inikepb7d34492016-08-18 15:13:41 +0200226$ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC
Yann Collet27b5ac62016-09-21 14:20:56 +0200227$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
Yann Collet531a4272016-06-15 19:02:11 +0200228$ECHO "- Create dictionary with short dictID"
inikepb7d34492016-08-18 15:13:41 +0200229$ZSTD --train *.c ../programs/*.c --dictID 1 -o tmpDict1
Yann Collet290aaa72016-05-30 21:18:52 +0200230cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
Yann Collet27b5ac62016-09-21 14:20:56 +0200231$ECHO "- Create dictionary with wrong dictID parameter order (must fail)"
232$ZSTD --train *.c ../programs/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
233$ECHO "- Create dictionary with size limit"
234$ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict 4K -v
235$ECHO "- Create dictionary with wrong parameter order (must fail)"
236$ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
Yann Collet531a4272016-06-15 19:02:11 +0200237$ECHO "- Compress without dictID"
Yann Collet6381e992016-05-31 02:29:45 +0200238$ZSTD -f tmp -D tmpDict1 --no-dictID
Yann Collet27b5ac62016-09-21 14:20:56 +0200239$ZSTD -d tmp.zst -D tmpDict -fo result
Przemyslaw Skibinski5f5a9022016-12-22 18:05:07 +0100240$DIFF $TESTFILE result
Yann Collet27b5ac62016-09-21 14:20:56 +0200241$ECHO "- Compress with wrong argument order (must fail)"
242$ZSTD tmp -Df tmpDict1 -c > /dev/null && die "-D must be followed by dictionary name "
Yann Collet531a4272016-06-15 19:02:11 +0200243$ECHO "- Compress multiple files with dictionary"
Yann Collet531a4272016-06-15 19:02:11 +0200244rm -rf dirTestDict
245mkdir dirTestDict
246cp *.c dirTestDict
inikepb7d34492016-08-18 15:13:41 +0200247cp ../programs/*.c dirTestDict
248cp ../programs/*.h dirTestDict
Yann Collet94376ac2016-08-25 19:09:21 +0200249$MD5SUM dirTestDict/* > tmph1
250$ZSTD -f --rm dirTestDict/* -D tmpDictC
Yann Colletbb93d772016-08-25 22:22:50 +0200251$ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
Dimitry Andric12df6da2016-12-12 19:22:47 +0100252case "$UNAME" in
253 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 -0800254 *) $MD5SUM -c tmph1 ;;
255esac
Yann Collet531a4272016-06-15 19:02:11 +0200256rm -rf dirTestDict
Yann Collet6381e992016-05-31 02:29:45 +0200257rm tmp*
Yann Colletb44be742016-03-26 20:52:14 +0100258
Yann Colletf6f3d752015-12-13 13:35:21 +0100259
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500260$ECHO "\n**** cover dictionary tests **** "
261
262TESTFILE=../programs/zstdcli.c
263./datagen > tmpDict
264$ECHO "- Create first dictionary"
265$ZSTD --train --cover=k=46,d=8 *.c ../programs/*.c -o tmpDict
266cp $TESTFILE tmp
267$ZSTD -f tmp -D tmpDict
268$ZSTD -d tmp.zst -D tmpDict -fo result
269$DIFF $TESTFILE result
270$ECHO "- Create second (different) dictionary"
Nick Terrell3a1fefc2017-01-02 12:40:43 -0800271$ZSTD --train --cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500272$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
273$ECHO "- Create dictionary with short dictID"
274$ZSTD --train --cover=k=46,d=8 *.c ../programs/*.c --dictID 1 -o tmpDict1
275cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
276$ECHO "- Create dictionary with size limit"
Nick Terrell3a1fefc2017-01-02 12:40:43 -0800277$ZSTD --train --optimize-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict 4K
Nick Terrellcbb3ce32017-01-01 01:59:51 -0500278rm tmp*
279
280
inikep5d589562016-05-25 10:50:28 +0200281$ECHO "\n**** integrity tests **** "
Yann Colletde95f962016-05-23 19:46:47 +0200282
inikep5d589562016-05-25 10:50:28 +0200283$ECHO "test one file (tmp1.zst) "
Yann Collet1a7b8fb2016-06-15 23:33:38 +0200284./datagen > tmp1
285$ZSTD tmp1
Yann Collet459a6b72016-02-15 20:37:23 +0100286$ZSTD -t tmp1.zst
Yann Collet2d08b092016-02-16 14:42:08 +0100287$ZSTD --test tmp1.zst
inikep5d589562016-05-25 10:50:28 +0200288$ECHO "test multiple files (*.zst) "
Yann Collet459a6b72016-02-15 20:37:23 +0100289$ZSTD -t *.zst
Yann Collet24a3d902016-07-26 01:26:56 +0200290$ECHO "test bad files (*) "
Yann Collet459a6b72016-02-15 20:37:23 +0100291$ZSTD -t * && die "bad files not detected !"
Yann Collet24a3d902016-07-26 01:26:56 +0200292$ZSTD -t tmp1 && die "bad file not detected !"
293cp tmp1 tmp2.zst
294$ZSTD -t tmp2.zst && die "bad file not detected !"
Yann Collet7adc2322016-07-26 15:39:31 +0200295./datagen -g0 > tmp3
296$ZSTD -t tmp3 && die "bad file not detected !" # detects 0-sized files as bad
Yann Colletb4024902016-07-26 00:49:47 +0200297$ECHO "test --rm and --test combined "
298$ZSTD -t --rm tmp1.zst
299ls -ls tmp1.zst # check file is still present
Yann Colletdeb078b2015-12-17 20:30:14 +0100300
Yann Colletde95f962016-05-23 19:46:47 +0200301
Yann Colletb9550d62016-10-28 14:43:24 -0700302$ECHO "\n**** benchmark mode tests **** "
303
304$ECHO "bench one file"
305./datagen > tmp1
306$ZSTD -bi1 tmp1
307$ECHO "bench multiple levels"
308$ZSTD -i1b1e3 tmp1
309$ECHO "with recursive and quiet modes"
310$ZSTD -rqi1b1e3 tmp1
311
312
inikep5d589562016-05-25 10:50:28 +0200313$ECHO "\n**** zstd round-trip tests **** "
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300314
315roundTripTest
Yann Collet3b719252016-03-30 19:48:05 +0200316roundTripTest -g15K # TableID==3
317roundTripTest -g127K # TableID==2
318roundTripTest -g255K # TableID==1
319roundTripTest -g513K # TableID==0
Yann Collet459a6b72016-02-15 20:37:23 +0100320roundTripTest -g512K 6 # greedy, hash chain
Yann Collet0d348d42016-05-29 02:02:24 +0200321roundTripTest -g512K 16 # btlazy2
Yann Collet459a6b72016-02-15 20:37:23 +0100322roundTripTest -g512K 19 # btopt
323
324rm tmp*
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300325
Konstantin Tokarev0b570b52015-12-08 18:47:43 +0300326if [ "$1" != "--test-large-data" ]; then
inikep5d589562016-05-25 10:50:28 +0200327 $ECHO "Skipping large data tests"
Konstantin Tokarev0b570b52015-12-08 18:47:43 +0300328 exit 0
329fi
330
Konstantin Tokarev76be3782015-12-08 18:36:37 +0300331roundTripTest -g270000000 1
332roundTripTest -g270000000 2
333roundTripTest -g270000000 3
334
335roundTripTest -g140000000 -P60 4
336roundTripTest -g140000000 -P60 5
337roundTripTest -g140000000 -P60 6
338
339roundTripTest -g70000000 -P70 7
340roundTripTest -g70000000 -P70 8
341roundTripTest -g70000000 -P70 9
342
343roundTripTest -g35000000 -P75 10
344roundTripTest -g35000000 -P75 11
345roundTripTest -g35000000 -P75 12
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300346
Konstantin Tokarev2b465842015-12-08 19:36:42 +0300347roundTripTest -g18000000 -P80 13
348roundTripTest -g18000000 -P80 14
349roundTripTest -g18000000 -P80 15
350roundTripTest -g18000000 -P80 16
351roundTripTest -g18000000 -P80 17
352
353roundTripTest -g50000000 -P94 18
354roundTripTest -g50000000 -P94 19
355
356roundTripTest -g99000000 -P99 20
Yann Colletecabfe32016-03-20 16:20:06 +0100357roundTripTest -g6000000000 -P99 1
Yann Collet459a6b72016-02-15 20:37:23 +0100358
359rm tmp*