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 |
| 10 | local c="$3" |
| 11 | local p="$2" |
| 12 | else |
| 13 | local c="$2" |
| 14 | fi |
| 15 | |
| 16 | rm -f tmp1 tmp2 |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 17 | $ECHO "roundTripTest: ./datagen $1 $p | $ZSTD -v$c | $ZSTD -d" |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 18 | ./datagen $1 $p | md5sum > tmp1 |
Yann Collet | ef37063 | 2016-02-07 03:53:12 +0100 | [diff] [blame] | 19 | ./datagen $1 $p | $ZSTD -vq$c | $ZSTD -d | md5sum > tmp2 |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 20 | diff -q tmp1 tmp2 |
| 21 | } |
| 22 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 23 | isWindows=false |
| 24 | ECHO="echo" |
inikep | 993a9df | 2016-05-27 10:07:46 +0200 | [diff] [blame^] | 25 | case "$OS" in |
| 26 | Windows*) |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 27 | isWindows=true |
| 28 | ECHO="echo -e" |
inikep | 993a9df | 2016-05-27 10:07:46 +0200 | [diff] [blame^] | 29 | ;; |
| 30 | esac |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 31 | |
| 32 | $ECHO "\nStarting playTests.sh isWindows=$isWindows" |
| 33 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 34 | [ -n "$ZSTD" ] || die "ZSTD variable must be defined!" |
| 35 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 36 | $ECHO "\n**** simple tests **** " |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 37 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame] | 38 | ./datagen > tmp |
Yann Collet | 7928f6f | 2016-04-10 20:40:26 +0200 | [diff] [blame] | 39 | $ZSTD -f tmp # trivial compression case, creates tmp.zst |
| 40 | $ZSTD -df tmp.zst # trivial decompression case (overwrites tmp) |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 41 | $ECHO "test : too large compression level (must fail)" |
Yann Collet | 9abc358 | 2016-02-16 16:35:28 +0100 | [diff] [blame] | 42 | $ZSTD -99 tmp && die "too large compression level undetected" |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 43 | $ECHO "test : compress to stdout" |
Yann Collet | d693117 | 2016-05-10 05:56:09 +0200 | [diff] [blame] | 44 | $ZSTD tmp -c > tmpCompressed |
| 45 | $ZSTD tmp --stdout > tmpCompressed # long command format |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 46 | $ECHO "test : null-length file roundtrip" |
| 47 | $ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout |
| 48 | $ECHO "test : decompress file with wrong suffix (must fail)" |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 49 | $ZSTD -d tmpCompressed && die "wrong suffix error not detected!" |
Yann Collet | 7928f6f | 2016-04-10 20:40:26 +0200 | [diff] [blame] | 50 | $ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 51 | $ZSTD --decompress tmpCompressed -c > tmpResult |
| 52 | $ZSTD --decompress tmpCompressed --stdout > tmpResult |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 53 | if [ "$isWindows" = false ] ; then |
| 54 | $ZSTD -d < tmp.zst > /dev/null # combine decompression, stdin & stdout |
| 55 | $ZSTD -d - < tmp.zst > /dev/null |
| 56 | fi |
Yann Collet | 7928f6f | 2016-04-10 20:40:26 +0200 | [diff] [blame] | 57 | $ZSTD -dc < tmp.zst > /dev/null |
| 58 | $ZSTD -dc - < tmp.zst > /dev/null |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 59 | $ZSTD -q tmp && die "overwrite check failed!" |
| 60 | $ZSTD -q -f tmp |
| 61 | $ZSTD -q --force tmp |
Yann Collet | 97406c9 | 2016-03-14 17:05:40 +0100 | [diff] [blame] | 62 | $ZSTD -df tmp && die "should have refused : wrong extension" |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 63 | |
| 64 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 65 | $ECHO "\n**** Pass-Through mode **** " |
| 66 | $ECHO "Hello world !" | $ZSTD -df |
| 67 | $ECHO "Hello world !" | $ZSTD -dcf |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 68 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame] | 69 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 70 | $ECHO "\n**** frame concatenation **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 71 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 72 | $ECHO "hello " > hello.tmp |
| 73 | $ECHO "world!" > world.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 74 | cat hello.tmp world.tmp > helloworld.tmp |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 75 | $ZSTD -c hello.tmp > hello.zstd |
| 76 | $ZSTD -c world.tmp > world.zstd |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 77 | cat hello.zstd world.zstd > helloworld.zstd |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 78 | $ZSTD -dc helloworld.zstd > result.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 79 | cat result.tmp |
| 80 | sdiff helloworld.tmp result.tmp |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 81 | rm ./*.tmp ./*.zstd |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 82 | $ECHO "frame concatenation tests completed" |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 83 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 84 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 85 | if [ "$isWindows" = false ] ; then |
| 86 | $ECHO "\n**** flush write error test **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 87 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 88 | $ECHO "$ECHO foo | $ZSTD > /dev/full" |
| 89 | $ECHO foo | $ZSTD > /dev/full && die "write error not detected!" |
| 90 | $ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full" |
| 91 | $ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!" |
| 92 | fi |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 93 | |
Yann Collet | 6a45835 | 2015-12-18 02:51:14 +0100 | [diff] [blame] | 94 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 95 | $ECHO "\n**** test sparse file support **** " |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 96 | |
| 97 | ./datagen -g5M -P100 > tmpSparse |
| 98 | $ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen |
| 99 | diff -s tmpSparse tmpSparseRegen |
| 100 | $ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse |
| 101 | diff -s tmpSparse tmpOutSparse |
| 102 | $ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse |
| 103 | diff -s tmpSparse tmpOutNoSparse |
| 104 | ls -ls tmpSparse* |
| 105 | ./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks) |
| 106 | ./datagen -s1 -g1200007 -P100 | diff -s - tmpSparseOdd |
| 107 | ls -ls tmpSparseOdd |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 108 | $ECHO "\n Sparse Compatibility with Console :" |
| 109 | $ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c |
| 110 | $ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat |
| 111 | $ECHO "\n Sparse Compatibility with Append :" |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 112 | ./datagen -P100 -g1M > tmpSparse1M |
| 113 | cat tmpSparse1M tmpSparse1M > tmpSparse2M |
| 114 | $ZSTD -v -f tmpSparse1M -o tmpSparseCompressed |
| 115 | $ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated |
| 116 | $ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated |
| 117 | ls -ls tmpSparse* |
| 118 | diff tmpSparse2M tmpSparseRegenerated |
| 119 | # rm tmpSparse* |
| 120 | |
| 121 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 122 | $ECHO "\n**** dictionary tests **** " |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 123 | |
| 124 | ./datagen > tmpDict |
| 125 | ./datagen -g1M | md5sum > tmp1 |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 126 | ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | md5sum > tmp2 |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 127 | diff -q tmp1 tmp2 |
Yann Collet | b44be74 | 2016-03-26 20:52:14 +0100 | [diff] [blame] | 128 | $ZSTD --train *.c *.h -o tmpDict |
| 129 | $ZSTD xxhash.c -D tmpDict -of tmp |
| 130 | $ZSTD -d tmp -D tmpDict -of result |
| 131 | diff xxhash.c result |
| 132 | |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 133 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 134 | $ECHO "\n**** multiple files tests **** " |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 135 | |
| 136 | ./datagen -s1 > tmp1 2> /dev/null |
| 137 | ./datagen -s2 -g100K > tmp2 2> /dev/null |
| 138 | ./datagen -s3 -g1M > tmp3 2> /dev/null |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 139 | $ZSTD -f tmp* |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 140 | $ECHO "compress tmp* : " |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 141 | ls -ls tmp* |
| 142 | rm tmp1 tmp2 tmp3 |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 143 | $ECHO "decompress tmp* : " |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 144 | $ZSTD -df *.zst |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 145 | ls -ls tmp* |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 146 | $ECHO "compress tmp* into stdout > tmpall : " |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 147 | $ZSTD -c tmp1 tmp2 tmp3 > tmpall |
| 148 | ls -ls tmp* |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 149 | $ECHO "decompress tmpall* into stdout > tmpdec : " |
Yann Collet | 1f1f239 | 2016-02-12 18:33:26 +0100 | [diff] [blame] | 150 | cp tmpall tmpall2 |
| 151 | $ZSTD -dc tmpall* > tmpdec |
| 152 | ls -ls tmp* |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 153 | $ECHO "compress multiple files including a missing one (notHere) : " |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 154 | $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!" |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 155 | |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 156 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 157 | $ECHO "\n**** integrity tests **** " |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 158 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 159 | $ECHO "test one file (tmp1.zst) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 160 | $ZSTD -t tmp1.zst |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 161 | $ZSTD --test tmp1.zst |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 162 | $ECHO "test multiple files (*.zst) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 163 | $ZSTD -t *.zst |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 164 | $ECHO "test good and bad files (*) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 165 | $ZSTD -t * && die "bad files not detected !" |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 166 | |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 167 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 168 | $ECHO "\n**** zstd round-trip tests **** " |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 169 | |
| 170 | roundTripTest |
Yann Collet | 3b71925 | 2016-03-30 19:48:05 +0200 | [diff] [blame] | 171 | roundTripTest -g15K # TableID==3 |
| 172 | roundTripTest -g127K # TableID==2 |
| 173 | roundTripTest -g255K # TableID==1 |
| 174 | roundTripTest -g513K # TableID==0 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 175 | roundTripTest -g512K 6 # greedy, hash chain |
| 176 | roundTripTest -g512K 16 # btlazy2 |
| 177 | roundTripTest -g512K 19 # btopt |
| 178 | |
| 179 | rm tmp* |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 180 | |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 181 | if [ "$1" != "--test-large-data" ]; then |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 182 | $ECHO "Skipping large data tests" |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 183 | exit 0 |
| 184 | fi |
| 185 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 186 | roundTripTest -g270000000 1 |
| 187 | roundTripTest -g270000000 2 |
| 188 | roundTripTest -g270000000 3 |
| 189 | |
| 190 | roundTripTest -g140000000 -P60 4 |
| 191 | roundTripTest -g140000000 -P60 5 |
| 192 | roundTripTest -g140000000 -P60 6 |
| 193 | |
| 194 | roundTripTest -g70000000 -P70 7 |
| 195 | roundTripTest -g70000000 -P70 8 |
| 196 | roundTripTest -g70000000 -P70 9 |
| 197 | |
| 198 | roundTripTest -g35000000 -P75 10 |
| 199 | roundTripTest -g35000000 -P75 11 |
| 200 | roundTripTest -g35000000 -P75 12 |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 201 | |
Konstantin Tokarev | 2b46584 | 2015-12-08 19:36:42 +0300 | [diff] [blame] | 202 | roundTripTest -g18000000 -P80 13 |
| 203 | roundTripTest -g18000000 -P80 14 |
| 204 | roundTripTest -g18000000 -P80 15 |
| 205 | roundTripTest -g18000000 -P80 16 |
| 206 | roundTripTest -g18000000 -P80 17 |
| 207 | |
| 208 | roundTripTest -g50000000 -P94 18 |
| 209 | roundTripTest -g50000000 -P94 19 |
| 210 | |
| 211 | roundTripTest -g99000000 -P99 20 |
Yann Collet | ecabfe3 | 2016-03-20 16:20:06 +0100 | [diff] [blame] | 212 | roundTripTest -g6000000000 -P99 1 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 213 | |
| 214 | rm tmp* |
| 215 | |