Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | |
| 3 | die() { |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 4 | $ECHO "$@" 1>&2 |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 5 | exit 1 |
| 6 | } |
| 7 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 8 | roundTripTest() { |
| 9 | if [ -n "$3" ]; then |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 10 | local_c="$3" |
| 11 | local_p="$2" |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 12 | else |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 13 | local_c="$2" |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 14 | fi |
| 15 | |
| 16 | rm -f tmp1 tmp2 |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 17 | $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 Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 21 | } |
| 22 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 23 | isWindows=false |
| 24 | ECHO="echo" |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 25 | INTOVOID="/dev/null" |
inikep | 993a9df | 2016-05-27 10:07:46 +0200 | [diff] [blame] | 26 | case "$OS" in |
Yann Collet | 673f0d7 | 2016-06-06 00:26:38 +0200 | [diff] [blame] | 27 | Windows*) |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 28 | isWindows=true |
| 29 | ECHO="echo -e" |
inikep | 993a9df | 2016-05-27 10:07:46 +0200 | [diff] [blame] | 30 | ;; |
| 31 | esac |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 32 | |
Dimitry Andric | 12df6da | 2016-12-12 19:22:47 +0100 | [diff] [blame] | 33 | UNAME=$(uname) |
| 34 | case "$UNAME" in |
| 35 | Darwin) MD5SUM="md5 -r" ;; |
| 36 | FreeBSD) MD5SUM="gmd5sum" ;; |
Yann Collet | 94d1a93 | 2016-12-06 12:02:56 -0800 | [diff] [blame] | 37 | *) MD5SUM="md5sum" ;; |
| 38 | esac |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 39 | |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 40 | DIFF="diff" |
| 41 | case "$UNAME" in |
| 42 | SunOS) DIFF="gdiff" ;; |
| 43 | esac |
| 44 | |
| 45 | |
Przemyslaw Skibinski | e579ab5 | 2016-11-14 12:57:05 +0100 | [diff] [blame] | 46 | $ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'" |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 47 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 48 | [ -n "$ZSTD" ] || die "ZSTD variable must be defined!" |
| 49 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 50 | $ECHO "\n**** simple tests **** " |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 51 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame] | 52 | ./datagen > tmp |
Yann Collet | b3060f7 | 2016-09-09 16:44:16 +0200 | [diff] [blame] | 53 | $ECHO "test : basic compression " |
Yann Collet | 673f0d7 | 2016-06-06 00:26:38 +0200 | [diff] [blame] | 54 | $ZSTD -f tmp # trivial compression case, creates tmp.zst |
Yann Collet | b3060f7 | 2016-09-09 16:44:16 +0200 | [diff] [blame] | 55 | $ECHO "test : basic decompression" |
Yann Collet | 673f0d7 | 2016-06-06 00:26:38 +0200 | [diff] [blame] | 56 | $ZSTD -df tmp.zst # trivial decompression case (overwrites tmp) |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 57 | $ECHO "test : too large compression level (must fail)" |
Yann Collet | fab0230 | 2016-08-12 19:00:18 +0200 | [diff] [blame] | 58 | $ZSTD -99 -f tmp # too large compression level, automatic sized down |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 59 | $ECHO "test : compress to stdout" |
Yann Collet | 0d348d4 | 2016-05-29 02:02:24 +0200 | [diff] [blame] | 60 | $ZSTD tmp -c > tmpCompressed |
Yann Collet | d693117 | 2016-05-10 05:56:09 +0200 | [diff] [blame] | 61 | $ZSTD tmp --stdout > tmpCompressed # long command format |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 62 | $ECHO "test : compress to named file" |
| 63 | rm tmpCompressed |
| 64 | $ZSTD tmp -o tmpCompressed |
| 65 | ls tmpCompressed # must work |
| 66 | $ECHO "test : -o must be followed by filename (must fail)" |
Yann Collet | 714464f | 2016-09-21 16:05:03 +0200 | [diff] [blame] | 67 | $ZSTD tmp -of tmpCompressed && die "-o must be followed by filename " |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 68 | $ECHO "test : force write, correct order" |
| 69 | $ZSTD tmp -fo tmpCompressed |
Yann Collet | 714464f | 2016-09-21 16:05:03 +0200 | [diff] [blame] | 70 | $ECHO "test : forgotten argument" |
| 71 | cp tmp tmp2 |
| 72 | $ZSTD tmp2 -fo && die "-o must be followed by filename " |
Yann Collet | c843142 | 2016-09-01 15:05:57 -0700 | [diff] [blame] | 73 | $ECHO "test : implied stdout when input is stdin" |
| 74 | $ECHO bob | $ZSTD | $ZSTD -d |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 75 | $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 Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 78 | $ZSTD -d tmpCompressed && die "wrong suffix error not detected!" |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 79 | $ZSTD -df tmp && die "should have refused : wrong extension" |
| 80 | $ECHO "test : decompress into stdout" |
Yann Collet | 0d348d4 | 2016-05-29 02:02:24 +0200 | [diff] [blame] | 81 | $ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 82 | $ZSTD --decompress tmpCompressed -c > tmpResult |
| 83 | $ZSTD --decompress tmpCompressed --stdout > tmpResult |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 84 | $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 Collet | d4cda27 | 2016-10-14 13:13:13 -0700 | [diff] [blame] | 89 | $ECHO "test : impose memory limitation (must fail)" |
| 90 | $ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed" |
Yann Collet | 1122349 | 2016-10-14 14:07:11 -0700 | [diff] [blame] | 91 | $ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command |
Yann Collet | d7b120a | 2016-10-14 14:22:32 -0700 | [diff] [blame] | 92 | $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 Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 94 | $ECHO "test : overwrite protection" |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 95 | $ZSTD -q tmp && die "overwrite check failed!" |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 96 | $ECHO "test : force overwrite" |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 97 | $ZSTD -q -f tmp |
| 98 | $ZSTD -q --force tmp |
Yann Collet | b09b12c | 2016-06-09 22:59:51 +0200 | [diff] [blame] | 99 | $ECHO "test : file removal" |
| 100 | $ZSTD -f --rm tmp |
| 101 | ls tmp && die "tmp should no longer be present" |
| 102 | $ZSTD -f -d --rm tmp.zst |
| 103 | ls tmp.zst && die "tmp.zst should no longer be present" |
Yann Collet | 67d86a7 | 2017-02-27 16:09:20 -0800 | [diff] [blame^] | 104 | $ECHO "test : --rm on stdin" |
| 105 | $ECHO a | $ZSTD --rm > $INTOVOID # --rm should remain silent |
Yann Collet | b09b12c | 2016-06-09 22:59:51 +0200 | [diff] [blame] | 106 | rm tmp |
| 107 | $ZSTD -f tmp && die "tmp not present : should have failed" |
| 108 | ls tmp.zst && die "tmp.zst should not be created" |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 109 | |
| 110 | |
Przemyslaw Skibinski | 9b4fa0d | 2016-12-14 16:50:00 +0100 | [diff] [blame] | 111 | $ECHO "\n**** Advanced compression parameters **** " |
Przemyslaw Skibinski | 24a4236 | 2016-12-14 18:07:31 +0100 | [diff] [blame] | 112 | $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 Skibinski | f9a5666 | 2016-12-14 18:43:06 +0100 | [diff] [blame] | 114 | $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!" |
Przemyslaw Skibinski | 24a4236 | 2016-12-14 18:07:31 +0100 | [diff] [blame] | 115 | ls tmp.zst && die "tmp.zst should not be created" |
Przemyslaw Skibinski | 9b4fa0d | 2016-12-14 16:50:00 +0100 | [diff] [blame] | 116 | roundTripTest -g512K |
Przemyslaw Skibinski | ab5ed6f | 2016-12-14 17:10:38 +0100 | [diff] [blame] | 117 | roundTripTest -g512K " --zstd=slen=3,tlen=48,strat=6" |
| 118 | roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6" |
Przemyslaw Skibinski | 9b4fa0d | 2016-12-14 16:50:00 +0100 | [diff] [blame] | 119 | roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6" |
| 120 | roundTripTest -g512K 19 |
| 121 | |
| 122 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 123 | $ECHO "\n**** Pass-Through mode **** " |
Yann Collet | 743b33f | 2016-12-02 15:18:57 -0800 | [diff] [blame] | 124 | $ECHO "Hello world 1!" | $ZSTD -df |
| 125 | $ECHO "Hello world 2!" | $ZSTD -dcf |
| 126 | $ECHO "Hello world 3!" > tmp1 |
| 127 | $ZSTD -dcf tmp1 |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 128 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame] | 129 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 130 | $ECHO "\n**** frame concatenation **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 131 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 132 | $ECHO "hello " > hello.tmp |
| 133 | $ECHO "world!" > world.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 134 | cat hello.tmp world.tmp > helloworld.tmp |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 135 | $ZSTD -c hello.tmp > hello.zstd |
| 136 | $ZSTD -c world.tmp > world.zstd |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 137 | cat hello.zstd world.zstd > helloworld.zstd |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 138 | $ZSTD -dc helloworld.zstd > result.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 139 | cat result.tmp |
Yann Collet | bd6bc22 | 2017-01-22 15:54:14 -0800 | [diff] [blame] | 140 | $DIFF helloworld.tmp result.tmp |
Yann Collet | 4c5bbf6 | 2016-07-28 20:30:25 +0200 | [diff] [blame] | 141 | $ECHO "frame concatenation without checksum" |
| 142 | $ZSTD -c hello.tmp > hello.zstd --no-check |
| 143 | $ZSTD -c world.tmp > world.zstd --no-check |
| 144 | cat hello.zstd world.zstd > helloworld.zstd |
| 145 | $ZSTD -dc helloworld.zstd > result.tmp |
| 146 | cat result.tmp |
Yann Collet | bd6bc22 | 2017-01-22 15:54:14 -0800 | [diff] [blame] | 147 | $DIFF helloworld.tmp result.tmp |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 148 | rm ./*.tmp ./*.zstd |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 149 | $ECHO "frame concatenation tests completed" |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 150 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 151 | |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 152 | if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 153 | $ECHO "\n**** flush write error test **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 154 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 155 | $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!" |
| 159 | fi |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 160 | |
Yann Collet | 6a45835 | 2015-12-18 02:51:14 +0100 | [diff] [blame] | 161 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 162 | $ECHO "\n**** test sparse file support **** " |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 163 | |
| 164 | ./datagen -g5M -P100 > tmpSparse |
| 165 | $ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 166 | $DIFF -s tmpSparse tmpSparseRegen |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 167 | $ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 168 | $DIFF -s tmpSparse tmpOutSparse |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 169 | $ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 170 | $DIFF -s tmpSparse tmpOutNoSparse |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 171 | ls -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 Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 173 | ./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 174 | ls -ls tmpSparseOdd |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 175 | $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 Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 179 | ./datagen -P100 -g1M > tmpSparse1M |
| 180 | cat 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 |
| 184 | ls -ls tmpSparse* |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 185 | $DIFF tmpSparse2M tmpSparseRegenerated |
Yann Collet | 33341de | 2016-05-29 23:09:51 +0200 | [diff] [blame] | 186 | rm tmpSparse* |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 187 | |
| 188 | |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 189 | $ECHO "\n**** multiple files tests **** " |
| 190 | |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 191 | ./datagen -s1 > tmp1 2> $INTOVOID |
| 192 | ./datagen -s2 -g100K > tmp2 2> $INTOVOID |
| 193 | ./datagen -s3 -g1M > tmp3 2> $INTOVOID |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 194 | $ECHO "compress tmp* : " |
Yann Collet | 60ba31c | 2016-07-28 19:55:09 +0200 | [diff] [blame] | 195 | $ZSTD -f tmp* |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 196 | ls -ls tmp* |
| 197 | rm tmp1 tmp2 tmp3 |
| 198 | $ECHO "decompress tmp* : " |
| 199 | $ZSTD -df *.zst |
| 200 | ls -ls tmp* |
| 201 | $ECHO "compress tmp* into stdout > tmpall : " |
| 202 | $ZSTD -c tmp1 tmp2 tmp3 > tmpall |
| 203 | ls -ls tmp* |
| 204 | $ECHO "decompress tmpall* into stdout > tmpdec : " |
| 205 | cp tmpall tmpall2 |
| 206 | $ZSTD -dc tmpall* > tmpdec |
| 207 | ls -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 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 212 | $ECHO "\n**** dictionary tests **** " |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 213 | |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 214 | TESTFILE=../programs/zstdcli.c |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 215 | ./datagen > tmpDict |
inikep | 93fc13e | 2016-05-30 10:17:55 +0200 | [diff] [blame] | 216 | ./datagen -g1M | $MD5SUM > tmp1 |
| 217 | ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2 |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 218 | $DIFF -q tmp1 tmp2 |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 219 | $ECHO "- Create first dictionary" |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 220 | $ZSTD --train *.c ../programs/*.c -o tmpDict |
| 221 | cp $TESTFILE tmp |
Yann Collet | 6381e99 | 2016-05-31 02:29:45 +0200 | [diff] [blame] | 222 | $ZSTD -f tmp -D tmpDict |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 223 | $ZSTD -d tmp.zst -D tmpDict -fo result |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 224 | $DIFF $TESTFILE result |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 225 | $ECHO "- Create second (different) dictionary" |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 226 | $ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 227 | $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!" |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 228 | $ECHO "- Create dictionary with short dictID" |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 229 | $ZSTD --train *.c ../programs/*.c --dictID 1 -o tmpDict1 |
Yann Collet | 290aaa7 | 2016-05-30 21:18:52 +0200 | [diff] [blame] | 230 | cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 231 | $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 Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 237 | $ECHO "- Compress without dictID" |
Yann Collet | 6381e99 | 2016-05-31 02:29:45 +0200 | [diff] [blame] | 238 | $ZSTD -f tmp -D tmpDict1 --no-dictID |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 239 | $ZSTD -d tmp.zst -D tmpDict -fo result |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 240 | $DIFF $TESTFILE result |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 241 | $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 Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 243 | $ECHO "- Compress multiple files with dictionary" |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 244 | rm -rf dirTestDict |
| 245 | mkdir dirTestDict |
| 246 | cp *.c dirTestDict |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 247 | cp ../programs/*.c dirTestDict |
| 248 | cp ../programs/*.h dirTestDict |
Yann Collet | 94376ac | 2016-08-25 19:09:21 +0200 | [diff] [blame] | 249 | $MD5SUM dirTestDict/* > tmph1 |
| 250 | $ZSTD -f --rm dirTestDict/* -D tmpDictC |
Yann Collet | bb93d77 | 2016-08-25 22:22:50 +0200 | [diff] [blame] | 251 | $ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default |
Dimitry Andric | 12df6da | 2016-12-12 19:22:47 +0100 | [diff] [blame] | 252 | case "$UNAME" in |
| 253 | Darwin) $ECHO "md5sum -c not supported on OS-X : test skipped" ;; # not compatible with OS-X's md5 |
Yann Collet | 94d1a93 | 2016-12-06 12:02:56 -0800 | [diff] [blame] | 254 | *) $MD5SUM -c tmph1 ;; |
| 255 | esac |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 256 | rm -rf dirTestDict |
Yann Collet | 6381e99 | 2016-05-31 02:29:45 +0200 | [diff] [blame] | 257 | rm tmp* |
Yann Collet | b44be74 | 2016-03-26 20:52:14 +0100 | [diff] [blame] | 258 | |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 259 | |
Nick Terrell | cbb3ce3 | 2017-01-01 01:59:51 -0500 | [diff] [blame] | 260 | $ECHO "\n**** cover dictionary tests **** " |
| 261 | |
| 262 | TESTFILE=../programs/zstdcli.c |
| 263 | ./datagen > tmpDict |
| 264 | $ECHO "- Create first dictionary" |
| 265 | $ZSTD --train --cover=k=46,d=8 *.c ../programs/*.c -o tmpDict |
| 266 | cp $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 Terrell | 3a1fefc | 2017-01-02 12:40:43 -0800 | [diff] [blame] | 271 | $ZSTD --train --cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC |
Nick Terrell | cbb3ce3 | 2017-01-01 01:59:51 -0500 | [diff] [blame] | 272 | $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 |
| 275 | cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" |
| 276 | $ECHO "- Create dictionary with size limit" |
Nick Terrell | 3a1fefc | 2017-01-02 12:40:43 -0800 | [diff] [blame] | 277 | $ZSTD --train --optimize-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict 4K |
Nick Terrell | cbb3ce3 | 2017-01-01 01:59:51 -0500 | [diff] [blame] | 278 | rm tmp* |
| 279 | |
| 280 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 281 | $ECHO "\n**** integrity tests **** " |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 282 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 283 | $ECHO "test one file (tmp1.zst) " |
Yann Collet | 1a7b8fb | 2016-06-15 23:33:38 +0200 | [diff] [blame] | 284 | ./datagen > tmp1 |
| 285 | $ZSTD tmp1 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 286 | $ZSTD -t tmp1.zst |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 287 | $ZSTD --test tmp1.zst |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 288 | $ECHO "test multiple files (*.zst) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 289 | $ZSTD -t *.zst |
Yann Collet | 24a3d90 | 2016-07-26 01:26:56 +0200 | [diff] [blame] | 290 | $ECHO "test bad files (*) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 291 | $ZSTD -t * && die "bad files not detected !" |
Yann Collet | 24a3d90 | 2016-07-26 01:26:56 +0200 | [diff] [blame] | 292 | $ZSTD -t tmp1 && die "bad file not detected !" |
| 293 | cp tmp1 tmp2.zst |
| 294 | $ZSTD -t tmp2.zst && die "bad file not detected !" |
Yann Collet | 7adc232 | 2016-07-26 15:39:31 +0200 | [diff] [blame] | 295 | ./datagen -g0 > tmp3 |
| 296 | $ZSTD -t tmp3 && die "bad file not detected !" # detects 0-sized files as bad |
Yann Collet | b402490 | 2016-07-26 00:49:47 +0200 | [diff] [blame] | 297 | $ECHO "test --rm and --test combined " |
| 298 | $ZSTD -t --rm tmp1.zst |
| 299 | ls -ls tmp1.zst # check file is still present |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 300 | |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 301 | |
Yann Collet | b9550d6 | 2016-10-28 14:43:24 -0700 | [diff] [blame] | 302 | $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 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 313 | $ECHO "\n**** zstd round-trip tests **** " |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 314 | |
| 315 | roundTripTest |
Yann Collet | 3b71925 | 2016-03-30 19:48:05 +0200 | [diff] [blame] | 316 | roundTripTest -g15K # TableID==3 |
| 317 | roundTripTest -g127K # TableID==2 |
| 318 | roundTripTest -g255K # TableID==1 |
| 319 | roundTripTest -g513K # TableID==0 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 320 | roundTripTest -g512K 6 # greedy, hash chain |
Yann Collet | 0d348d4 | 2016-05-29 02:02:24 +0200 | [diff] [blame] | 321 | roundTripTest -g512K 16 # btlazy2 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 322 | roundTripTest -g512K 19 # btopt |
| 323 | |
| 324 | rm tmp* |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 325 | |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 326 | if [ "$1" != "--test-large-data" ]; then |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 327 | $ECHO "Skipping large data tests" |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 328 | exit 0 |
| 329 | fi |
| 330 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 331 | roundTripTest -g270000000 1 |
| 332 | roundTripTest -g270000000 2 |
| 333 | roundTripTest -g270000000 3 |
| 334 | |
| 335 | roundTripTest -g140000000 -P60 4 |
| 336 | roundTripTest -g140000000 -P60 5 |
| 337 | roundTripTest -g140000000 -P60 6 |
| 338 | |
| 339 | roundTripTest -g70000000 -P70 7 |
| 340 | roundTripTest -g70000000 -P70 8 |
| 341 | roundTripTest -g70000000 -P70 9 |
| 342 | |
| 343 | roundTripTest -g35000000 -P75 10 |
| 344 | roundTripTest -g35000000 -P75 11 |
| 345 | roundTripTest -g35000000 -P75 12 |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 346 | |
Konstantin Tokarev | 2b46584 | 2015-12-08 19:36:42 +0300 | [diff] [blame] | 347 | roundTripTest -g18000000 -P80 13 |
| 348 | roundTripTest -g18000000 -P80 14 |
| 349 | roundTripTest -g18000000 -P80 15 |
| 350 | roundTripTest -g18000000 -P80 16 |
| 351 | roundTripTest -g18000000 -P80 17 |
| 352 | |
| 353 | roundTripTest -g50000000 -P94 18 |
| 354 | roundTripTest -g50000000 -P94 19 |
| 355 | |
| 356 | roundTripTest -g99000000 -P99 20 |
Yann Collet | ecabfe3 | 2016-03-20 16:20:06 +0100 | [diff] [blame] | 357 | roundTripTest -g6000000000 -P99 1 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 358 | |
| 359 | rm tmp* |