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