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 |
Yann Collet | 4616fad | 2017-07-10 17:16:41 -0700 | [diff] [blame] | 10 | cLevel="$3" |
| 11 | proba="$2" |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 12 | else |
Yann Collet | 4616fad | 2017-07-10 17:16:41 -0700 | [diff] [blame] | 13 | cLevel="$2" |
| 14 | proba="" |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 15 | fi |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 16 | if [ -n "$4" ]; then |
| 17 | dLevel="$4" |
| 18 | else |
| 19 | dLevel="$cLevel" |
| 20 | fi |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 21 | |
| 22 | rm -f tmp1 tmp2 |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 23 | $ECHO "roundTripTest: ./datagen $1 $proba | $ZSTD -v$cLevel | $ZSTD -d$dLevel" |
Yann Collet | 4616fad | 2017-07-10 17:16:41 -0700 | [diff] [blame] | 24 | ./datagen $1 $proba | $MD5SUM > tmp1 |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 25 | ./datagen $1 $proba | $ZSTD --ultra -v$cLevel | $ZSTD -d$dLevel | $MD5SUM > tmp2 |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 26 | $DIFF -q tmp1 tmp2 |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 27 | } |
| 28 | |
Sean Purcell | eb70d21 | 2017-04-11 17:15:13 -0700 | [diff] [blame] | 29 | fileRoundTripTest() { |
| 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 Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 37 | if [ -n "$4" ]; then |
| 38 | local_d="$4" |
| 39 | else |
| 40 | local_d="$local_c" |
| 41 | fi |
Sean Purcell | eb70d21 | 2017-04-11 17:15:13 -0700 | [diff] [blame] | 42 | |
| 43 | rm -f tmp.zstd tmp.md5.1 tmp.md5.2 |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 44 | $ECHO "fileRoundTripTest: ./datagen $1 $local_p > tmp && $ZSTD -v$local_c -c tmp | $ZSTD -d$local_d" |
Sean Purcell | eb70d21 | 2017-04-11 17:15:13 -0700 | [diff] [blame] | 45 | ./datagen $1 $local_p > tmp |
Yann Collet | 4252621 | 2017-10-05 20:21:59 -0700 | [diff] [blame] | 46 | < tmp $MD5SUM > tmp.md5.1 |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 47 | $ZSTD --ultra -v$local_c -c tmp | $ZSTD -d$local_d | $MD5SUM > tmp.md5.2 |
Sean Purcell | eb70d21 | 2017-04-11 17:15:13 -0700 | [diff] [blame] | 48 | $DIFF -q tmp.md5.1 tmp.md5.2 |
| 49 | } |
| 50 | |
Björn Ketelaars | 06fd1e4 | 2018-06-30 15:42:42 +0200 | [diff] [blame] | 51 | truncateLastByte() { |
| 52 | dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1" status=none |
| 53 | } |
| 54 | |
Björn Ketelaars | 276988f | 2018-06-30 13:01:58 +0200 | [diff] [blame] | 55 | UNAME=$(uname) |
| 56 | |
Sean Purcell | 9a38dfa | 2017-03-17 12:32:18 -0700 | [diff] [blame] | 57 | isTerminal=false |
| 58 | if [ -t 0 ] && [ -t 1 ] |
| 59 | then |
| 60 | isTerminal=true |
| 61 | fi |
| 62 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 63 | isWindows=false |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 64 | INTOVOID="/dev/null" |
Björn Ketelaars | 276988f | 2018-06-30 13:01:58 +0200 | [diff] [blame] | 65 | case "$UNAME" in |
Dmitry V. Levin | 7ca12a1 | 2018-07-11 12:41:50 +0000 | [diff] [blame] | 66 | GNU) DEVDEVICE="/dev/random" ;; |
| 67 | *) DEVDEVICE="/dev/zero" ;; |
Björn Ketelaars | 276988f | 2018-06-30 13:01:58 +0200 | [diff] [blame] | 68 | esac |
inikep | 993a9df | 2016-05-27 10:07:46 +0200 | [diff] [blame] | 69 | case "$OS" in |
Yann Collet | 673f0d7 | 2016-06-06 00:26:38 +0200 | [diff] [blame] | 70 | Windows*) |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 71 | isWindows=true |
Sean Purcell | 9a38dfa | 2017-03-17 12:32:18 -0700 | [diff] [blame] | 72 | INTOVOID="NUL" |
Nick Terrell | 82bc8fe | 2017-12-13 12:04:46 -0800 | [diff] [blame] | 73 | DEVDEVICE="NUL" |
inikep | 993a9df | 2016-05-27 10:07:46 +0200 | [diff] [blame] | 74 | ;; |
| 75 | esac |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 76 | |
Dimitry Andric | 12df6da | 2016-12-12 19:22:47 +0100 | [diff] [blame] | 77 | case "$UNAME" in |
| 78 | Darwin) MD5SUM="md5 -r" ;; |
| 79 | FreeBSD) MD5SUM="gmd5sum" ;; |
bket | daf3ab0 | 2018-04-02 23:12:18 +0200 | [diff] [blame] | 80 | OpenBSD) MD5SUM="md5" ;; |
Yann Collet | 94d1a93 | 2016-12-06 12:02:56 -0800 | [diff] [blame] | 81 | *) MD5SUM="md5sum" ;; |
| 82 | esac |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 83 | |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 84 | DIFF="diff" |
| 85 | case "$UNAME" in |
| 86 | SunOS) DIFF="gdiff" ;; |
| 87 | esac |
| 88 | |
Yann Collet | 62568c9 | 2017-09-25 14:26:26 -0700 | [diff] [blame] | 89 | ECHO="echo -e" |
| 90 | case "$UNAME" in |
| 91 | Darwin) ECHO="echo" ;; |
| 92 | esac |
| 93 | |
Przemyslaw Skibinski | e579ab5 | 2016-11-14 12:57:05 +0100 | [diff] [blame] | 94 | $ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'" |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 95 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 96 | [ -n "$ZSTD" ] || die "ZSTD variable must be defined!" |
| 97 | |
Sean Purcell | c424ec2 | 2017-04-17 11:38:53 -0700 | [diff] [blame] | 98 | if [ -n "$(echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep 'multi-threading is disabled')" ] |
| 99 | then |
| 100 | hasMT="" |
| 101 | else |
| 102 | hasMT="true" |
| 103 | fi |
| 104 | |
Yann Collet | a927fae | 2018-01-06 12:31:26 +0100 | [diff] [blame] | 105 | |
Yann Collet | 6c51bf4 | 2018-09-24 18:16:08 -0700 | [diff] [blame] | 106 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 107 | $ECHO "\n===> simple tests " |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 108 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame] | 109 | ./datagen > tmp |
Yann Collet | b3060f7 | 2016-09-09 16:44:16 +0200 | [diff] [blame] | 110 | $ECHO "test : basic compression " |
Yann Collet | 673f0d7 | 2016-06-06 00:26:38 +0200 | [diff] [blame] | 111 | $ZSTD -f tmp # trivial compression case, creates tmp.zst |
Yann Collet | b3060f7 | 2016-09-09 16:44:16 +0200 | [diff] [blame] | 112 | $ECHO "test : basic decompression" |
Yann Collet | 673f0d7 | 2016-06-06 00:26:38 +0200 | [diff] [blame] | 113 | $ZSTD -df tmp.zst # trivial decompression case (overwrites tmp) |
Yann Collet | 6a9b41b | 2018-03-11 19:56:48 -0700 | [diff] [blame] | 114 | $ECHO "test : too large compression level => auto-fix" |
Yann Collet | fab0230 | 2016-08-12 19:00:18 +0200 | [diff] [blame] | 115 | $ZSTD -99 -f tmp # too large compression level, automatic sized down |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 116 | $ZSTD -5000000000 -f tmp && die "too large numeric value : must fail" |
Yann Collet | 6a9b41b | 2018-03-11 19:56:48 -0700 | [diff] [blame] | 117 | $ECHO "test : --fast aka negative compression levels" |
| 118 | $ZSTD --fast -f tmp # == -1 |
| 119 | $ZSTD --fast=3 -f tmp # == -3 |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 120 | $ZSTD --fast=200000 -f tmp # too low compression level, automatic fixed |
| 121 | $ZSTD --fast=5000000000 -f tmp && die "too large numeric value : must fail" |
| 122 | $ZSTD -c --fast=0 tmp > $INTOVOID && die "--fast must not accept value 0" |
Yann Collet | 9cd5c63 | 2018-05-12 14:29:33 -0700 | [diff] [blame] | 123 | $ECHO "test : too large numeric argument" |
| 124 | $ZSTD --fast=9999999999 -f tmp && die "should have refused numeric value" |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 125 | $ECHO "test : compress to stdout" |
Yann Collet | 0d348d4 | 2016-05-29 02:02:24 +0200 | [diff] [blame] | 126 | $ZSTD tmp -c > tmpCompressed |
Yann Collet | d693117 | 2016-05-10 05:56:09 +0200 | [diff] [blame] | 127 | $ZSTD tmp --stdout > tmpCompressed # long command format |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 128 | $ECHO "test : compress to named file" |
| 129 | rm tmpCompressed |
| 130 | $ZSTD tmp -o tmpCompressed |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 131 | test -f tmpCompressed # file must be created |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 132 | $ECHO "test : -o must be followed by filename (must fail)" |
Yann Collet | 714464f | 2016-09-21 16:05:03 +0200 | [diff] [blame] | 133 | $ZSTD tmp -of tmpCompressed && die "-o must be followed by filename " |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 134 | $ECHO "test : force write, correct order" |
| 135 | $ZSTD tmp -fo tmpCompressed |
Yann Collet | 714464f | 2016-09-21 16:05:03 +0200 | [diff] [blame] | 136 | $ECHO "test : forgotten argument" |
| 137 | cp tmp tmp2 |
| 138 | $ZSTD tmp2 -fo && die "-o must be followed by filename " |
Yann Collet | c843142 | 2016-09-01 15:05:57 -0700 | [diff] [blame] | 139 | $ECHO "test : implied stdout when input is stdin" |
| 140 | $ECHO bob | $ZSTD | $ZSTD -d |
Sean Purcell | 9a38dfa | 2017-03-17 12:32:18 -0700 | [diff] [blame] | 141 | if [ "$isTerminal" = true ]; then |
Sean Purcell | d973071 | 2017-03-16 16:25:19 -0700 | [diff] [blame] | 142 | $ECHO "test : compressed data to terminal" |
| 143 | $ECHO bob | $ZSTD && die "should have refused : compressed data to terminal" |
| 144 | $ECHO "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)" |
| 145 | $ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal" |
Sean Purcell | 9a38dfa | 2017-03-17 12:32:18 -0700 | [diff] [blame] | 146 | fi |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 147 | $ECHO "test : null-length file roundtrip" |
| 148 | $ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout |
Yann Collet | 281f06e | 2017-12-14 11:47:02 -0800 | [diff] [blame] | 149 | $ECHO "test : ensure small file doesn't add 3-bytes null block" |
Yann Collet | a0e0985 | 2017-12-14 13:32:24 -0800 | [diff] [blame] | 150 | ./datagen -g1 > tmp1 |
| 151 | $ZSTD tmp1 -c | wc -c | grep "14" |
| 152 | $ZSTD < tmp1 | wc -c | grep "14" |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 153 | $ECHO "test : decompress file with wrong suffix (must fail)" |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 154 | $ZSTD -d tmpCompressed && die "wrong suffix error not detected!" |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 155 | $ZSTD -df tmp && die "should have refused : wrong extension" |
| 156 | $ECHO "test : decompress into stdout" |
Yann Collet | 0d348d4 | 2016-05-29 02:02:24 +0200 | [diff] [blame] | 157 | $ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 158 | $ZSTD --decompress tmpCompressed -c > tmpResult |
| 159 | $ZSTD --decompress tmpCompressed --stdout > tmpResult |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 160 | $ECHO "test : decompress from stdin into stdout" |
| 161 | $ZSTD -dc < tmp.zst > $INTOVOID # combine decompression, stdin & stdout |
| 162 | $ZSTD -dc - < tmp.zst > $INTOVOID |
| 163 | $ZSTD -d < tmp.zst > $INTOVOID # implicit stdout when stdin is used |
| 164 | $ZSTD -d - < tmp.zst > $INTOVOID |
Yann Collet | d4cda27 | 2016-10-14 13:13:13 -0700 | [diff] [blame] | 165 | $ECHO "test : impose memory limitation (must fail)" |
| 166 | $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] | 167 | $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] | 168 | $ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command |
| 169 | $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] | 170 | $ECHO "test : overwrite protection" |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 171 | $ZSTD -q tmp && die "overwrite check failed!" |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 172 | $ECHO "test : force overwrite" |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 173 | $ZSTD -q -f tmp |
| 174 | $ZSTD -q --force tmp |
Sean Purcell | 9da11c6 | 2017-04-06 12:58:49 -0700 | [diff] [blame] | 175 | $ECHO "test : overwrite readonly file" |
Sean Purcell | 1652172 | 2017-04-06 17:06:30 -0700 | [diff] [blame] | 176 | rm -f tmpro tmpro.zst |
Sean Purcell | 9da11c6 | 2017-04-06 12:58:49 -0700 | [diff] [blame] | 177 | $ECHO foo > tmpro.zst |
| 178 | $ECHO foo > tmpro |
| 179 | chmod 400 tmpro.zst |
Sean Purcell | 1652172 | 2017-04-06 17:06:30 -0700 | [diff] [blame] | 180 | $ZSTD -q tmpro && die "should have refused to overwrite read-only file" |
| 181 | $ZSTD -q -f tmpro |
| 182 | rm -f tmpro tmpro.zst |
Yann Collet | 9b45db7 | 2018-09-27 16:49:08 -0700 | [diff] [blame] | 183 | |
| 184 | |
Yann Collet | b09b12c | 2016-06-09 22:59:51 +0200 | [diff] [blame] | 185 | $ECHO "test : file removal" |
| 186 | $ZSTD -f --rm tmp |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 187 | test ! -f tmp # tmp should no longer be present |
Yann Collet | b09b12c | 2016-06-09 22:59:51 +0200 | [diff] [blame] | 188 | $ZSTD -f -d --rm tmp.zst |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 189 | test ! -f tmp.zst # tmp.zst should no longer be present |
Nick Terrell | 82bc8fe | 2017-12-13 12:04:46 -0800 | [diff] [blame] | 190 | $ECHO "test : should quietly not remove non-regular file" |
| 191 | $ECHO hello > tmp |
| 192 | $ZSTD tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID" |
| 193 | grep -v "Refusing to remove non-regular file" tmplog |
| 194 | rm -f tmplog |
Nick Terrell | 263134c | 2018-05-03 13:03:08 -0700 | [diff] [blame] | 195 | $ZSTD tmp -f -o "$INTOVOID" 2>&1 | grep -v "Refusing to remove non-regular file" |
Yann Collet | 67d86a7 | 2017-02-27 16:09:20 -0800 | [diff] [blame] | 196 | $ECHO "test : --rm on stdin" |
| 197 | $ECHO a | $ZSTD --rm > $INTOVOID # --rm should remain silent |
Yann Collet | b09b12c | 2016-06-09 22:59:51 +0200 | [diff] [blame] | 198 | rm tmp |
| 199 | $ZSTD -f tmp && die "tmp not present : should have failed" |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 200 | test ! -f tmp.zst # tmp.zst should not be created |
Yann Collet | 9012b6c | 2018-10-01 17:16:34 -0700 | [diff] [blame] | 201 | $ECHO "test : -d -f do not delete destination when source is not present" |
Yann Collet | 9b45db7 | 2018-09-27 16:49:08 -0700 | [diff] [blame] | 202 | touch tmp # create destination file |
| 203 | $ZSTD -d -f tmp.zst && die "attempt to decompress a non existing file" |
Yann Collet | 9012b6c | 2018-10-01 17:16:34 -0700 | [diff] [blame] | 204 | test -f tmp # destination file should still be present |
| 205 | $ECHO "test : -f do not delete destination when source is not present" |
| 206 | rm tmp # erase source file |
| 207 | touch tmp.zst # create destination file |
| 208 | $ZSTD -f tmp && die "attempt to compress a non existing file" |
| 209 | test -f tmp.zst # destination file should still be present |
Yann Collet | 9b45db7 | 2018-09-27 16:49:08 -0700 | [diff] [blame] | 210 | rm tmp* |
| 211 | |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 212 | |
Nick Terrell | 4680e85 | 2017-12-12 18:32:50 -0800 | [diff] [blame] | 213 | $ECHO "test : compress multiple files" |
| 214 | $ECHO hello > tmp1 |
| 215 | $ECHO world > tmp2 |
| 216 | $ZSTD tmp1 tmp2 -o "$INTOVOID" |
| 217 | $ZSTD tmp1 tmp2 -c | $ZSTD -t |
| 218 | $ZSTD tmp1 tmp2 -o tmp.zst |
| 219 | test ! -f tmp1.zst |
| 220 | test ! -f tmp2.zst |
| 221 | $ZSTD tmp1 tmp2 |
| 222 | $ZSTD -t tmp1.zst tmp2.zst |
| 223 | $ZSTD -dc tmp1.zst tmp2.zst |
| 224 | $ZSTD tmp1.zst tmp2.zst -o "$INTOVOID" |
| 225 | $ZSTD -d tmp1.zst tmp2.zst -o tmp |
Nick Terrell | 8adebbd | 2018-01-03 14:02:44 -0800 | [diff] [blame] | 226 | touch tmpexists |
| 227 | $ZSTD tmp1 tmp2 -f -o tmpexists |
| 228 | $ZSTD tmp1 tmp2 -o tmpexists && die "should have refused to overwrite" |
| 229 | # Bug: PR #972 |
| 230 | if [ "$?" -eq 139 ]; then |
| 231 | die "should not have segfaulted" |
| 232 | fi |
Nick Terrell | 4680e85 | 2017-12-12 18:32:50 -0800 | [diff] [blame] | 233 | rm tmp* |
| 234 | |
| 235 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 236 | $ECHO "\n===> Advanced compression parameters " |
Przemyslaw Skibinski | 24a4236 | 2016-12-14 18:07:31 +0100 | [diff] [blame] | 237 | $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21, - -o tmp.zst && die "wrong parameters not detected!" |
| 238 | $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] | 239 | $ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!" |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 240 | test ! -f tmp.zst # tmp.zst should not be created |
Przemyslaw Skibinski | 9b4fa0d | 2016-12-14 16:50:00 +0100 | [diff] [blame] | 241 | roundTripTest -g512K |
Przemyslaw Skibinski | ab5ed6f | 2016-12-14 17:10:38 +0100 | [diff] [blame] | 242 | roundTripTest -g512K " --zstd=slen=3,tlen=48,strat=6" |
| 243 | 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] | 244 | roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6" |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 245 | roundTripTest -g512K " --single-thread --long --zstd=ldmHashLog=20,ldmSearchLength=64,ldmBucketSizeLog=1,ldmHashEveryLog=7" |
| 246 | roundTripTest -g512K " --single-thread --long --zstd=ldmhlog=20,ldmslen=64,ldmblog=1,ldmhevery=7" |
Przemyslaw Skibinski | 9b4fa0d | 2016-12-14 16:50:00 +0100 | [diff] [blame] | 247 | roundTripTest -g512K 19 |
| 248 | |
| 249 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 250 | $ECHO "\n===> Pass-Through mode " |
Yann Collet | 743b33f | 2016-12-02 15:18:57 -0800 | [diff] [blame] | 251 | $ECHO "Hello world 1!" | $ZSTD -df |
| 252 | $ECHO "Hello world 2!" | $ZSTD -dcf |
| 253 | $ECHO "Hello world 3!" > tmp1 |
| 254 | $ZSTD -dcf tmp1 |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 255 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame] | 256 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 257 | $ECHO "\n===> frame concatenation " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 258 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 259 | $ECHO "hello " > hello.tmp |
| 260 | $ECHO "world!" > world.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 261 | cat hello.tmp world.tmp > helloworld.tmp |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 262 | $ZSTD -c hello.tmp > hello.zstd |
| 263 | $ZSTD -c world.tmp > world.zstd |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 264 | cat hello.zstd world.zstd > helloworld.zstd |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 265 | $ZSTD -dc helloworld.zstd > result.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 266 | cat result.tmp |
Yann Collet | bd6bc22 | 2017-01-22 15:54:14 -0800 | [diff] [blame] | 267 | $DIFF helloworld.tmp result.tmp |
Yann Collet | 4c5bbf6 | 2016-07-28 20:30:25 +0200 | [diff] [blame] | 268 | $ECHO "frame concatenation without checksum" |
| 269 | $ZSTD -c hello.tmp > hello.zstd --no-check |
| 270 | $ZSTD -c world.tmp > world.zstd --no-check |
| 271 | cat hello.zstd world.zstd > helloworld.zstd |
| 272 | $ZSTD -dc helloworld.zstd > result.tmp |
Yann Collet | bd6bc22 | 2017-01-22 15:54:14 -0800 | [diff] [blame] | 273 | $DIFF helloworld.tmp result.tmp |
Yann Collet | cb5eba8 | 2018-01-19 11:26:35 -0800 | [diff] [blame] | 274 | $ECHO "testing zstdcat symlink" |
| 275 | ln -sf $ZSTD zstdcat |
| 276 | ./zstdcat helloworld.zstd > result.tmp |
| 277 | $DIFF helloworld.tmp result.tmp |
| 278 | rm zstdcat |
| 279 | rm result.tmp |
| 280 | $ECHO "testing zcat symlink" |
| 281 | ln -sf $ZSTD zcat |
| 282 | ./zcat helloworld.zstd > result.tmp |
| 283 | $DIFF helloworld.tmp result.tmp |
| 284 | rm zcat |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 285 | rm ./*.tmp ./*.zstd |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 286 | $ECHO "frame concatenation tests completed" |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 287 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 288 | |
bket | daf3ab0 | 2018-04-02 23:12:18 +0200 | [diff] [blame] | 289 | if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] && [ "$UNAME" != "OpenBSD" ] ; then |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 290 | $ECHO "\n**** flush write error test **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 291 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 292 | $ECHO "$ECHO foo | $ZSTD > /dev/full" |
| 293 | $ECHO foo | $ZSTD > /dev/full && die "write error not detected!" |
| 294 | $ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full" |
| 295 | $ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!" |
Sean Purcell | 680e4e0 | 2017-03-23 11:52:09 -0700 | [diff] [blame] | 296 | |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 297 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 298 | $ECHO "\n===> symbolic link test " |
Sean Purcell | 680e4e0 | 2017-03-23 11:52:09 -0700 | [diff] [blame] | 299 | |
| 300 | rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst |
| 301 | $ECHO "hello world" > hello.tmp |
| 302 | ln -s hello.tmp world.tmp |
| 303 | $ZSTD world.tmp hello.tmp |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 304 | test -f hello.tmp.zst # regular file should have been compressed! |
| 305 | test ! -f world.tmp.zst # symbolic link should not have been compressed! |
Sean Purcell | 680e4e0 | 2017-03-23 11:52:09 -0700 | [diff] [blame] | 306 | $ZSTD world.tmp hello.tmp -f |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 307 | test -f world.tmp.zst # symbolic link should have been compressed with --force |
Sean Purcell | 680e4e0 | 2017-03-23 11:52:09 -0700 | [diff] [blame] | 308 | rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst |
| 309 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 310 | fi |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 311 | |
Yann Collet | 6a45835 | 2015-12-18 02:51:14 +0100 | [diff] [blame] | 312 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 313 | $ECHO "\n===> test sparse file support " |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 314 | |
| 315 | ./datagen -g5M -P100 > tmpSparse |
| 316 | $ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 317 | $DIFF -s tmpSparse tmpSparseRegen |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 318 | $ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 319 | $DIFF -s tmpSparse tmpOutSparse |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 320 | $ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 321 | $DIFF -s tmpSparse tmpOutNoSparse |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 322 | ls -ls tmpSparse* # look at file size and block size on disk |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 323 | ./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] | 324 | ./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 325 | ls -ls tmpSparseOdd # look at file size and block size on disk |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 326 | $ECHO "\n Sparse Compatibility with Console :" |
| 327 | $ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c |
| 328 | $ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat |
| 329 | $ECHO "\n Sparse Compatibility with Append :" |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 330 | ./datagen -P100 -g1M > tmpSparse1M |
| 331 | cat tmpSparse1M tmpSparse1M > tmpSparse2M |
| 332 | $ZSTD -v -f tmpSparse1M -o tmpSparseCompressed |
| 333 | $ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated |
| 334 | $ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 335 | ls -ls tmpSparse* # look at file size and block size on disk |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 336 | $DIFF tmpSparse2M tmpSparseRegenerated |
Yann Collet | 33341de | 2016-05-29 23:09:51 +0200 | [diff] [blame] | 337 | rm tmpSparse* |
Yann Collet | 32990b5 | 2016-05-23 17:48:57 +0200 | [diff] [blame] | 338 | |
| 339 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 340 | $ECHO "\n===> multiple files tests " |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 341 | |
Yann Collet | 391a128 | 2016-06-21 17:06:25 +0200 | [diff] [blame] | 342 | ./datagen -s1 > tmp1 2> $INTOVOID |
| 343 | ./datagen -s2 -g100K > tmp2 2> $INTOVOID |
| 344 | ./datagen -s3 -g1M > tmp3 2> $INTOVOID |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 345 | $ECHO "compress tmp* : " |
Yann Collet | 60ba31c | 2016-07-28 19:55:09 +0200 | [diff] [blame] | 346 | $ZSTD -f tmp* |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 347 | ls -ls tmp* |
| 348 | rm tmp1 tmp2 tmp3 |
| 349 | $ECHO "decompress tmp* : " |
| 350 | $ZSTD -df *.zst |
| 351 | ls -ls tmp* |
| 352 | $ECHO "compress tmp* into stdout > tmpall : " |
| 353 | $ZSTD -c tmp1 tmp2 tmp3 > tmpall |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 354 | ls -ls tmp* # check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst) |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 355 | $ECHO "decompress tmpall* into stdout > tmpdec : " |
| 356 | cp tmpall tmpall2 |
| 357 | $ZSTD -dc tmpall* > tmpdec |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 358 | ls -ls tmp* # check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3)) |
Yann Collet | 9b998e4 | 2016-06-15 23:11:20 +0200 | [diff] [blame] | 359 | $ECHO "compress multiple files including a missing one (notHere) : " |
| 360 | $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!" |
| 361 | |
| 362 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 363 | $ECHO "\n===> dictionary tests " |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 364 | |
Yann Collet | bd7fa21 | 2017-02-26 14:43:07 -0800 | [diff] [blame] | 365 | $ECHO "- test with raw dict (content only) " |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 366 | ./datagen > tmpDict |
inikep | 93fc13e | 2016-05-30 10:17:55 +0200 | [diff] [blame] | 367 | ./datagen -g1M | $MD5SUM > tmp1 |
| 368 | ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2 |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 369 | $DIFF -q tmp1 tmp2 |
Yann Collet | bd7fa21 | 2017-02-26 14:43:07 -0800 | [diff] [blame] | 370 | $ECHO "- Create first dictionary " |
| 371 | TESTFILE=../programs/zstdcli.c |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 372 | $ZSTD --train *.c ../programs/*.c -o tmpDict |
| 373 | cp $TESTFILE tmp |
Yann Collet | d228b6b | 2017-12-29 19:14:18 +0100 | [diff] [blame] | 374 | $ECHO "- Dictionary compression roundtrip" |
Yann Collet | 6381e99 | 2016-05-31 02:29:45 +0200 | [diff] [blame] | 375 | $ZSTD -f tmp -D tmpDict |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 376 | $ZSTD -d tmp.zst -D tmpDict -fo result |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 377 | $DIFF $TESTFILE result |
Yann Collet | d228b6b | 2017-12-29 19:14:18 +0100 | [diff] [blame] | 378 | $ECHO "- Dictionary compression with btlazy2 strategy" |
| 379 | $ZSTD -f tmp -D tmpDict --zstd=strategy=6 |
| 380 | $ZSTD -d tmp.zst -D tmpDict -fo result |
| 381 | $DIFF $TESTFILE result |
Yann Collet | 311878d | 2017-12-13 11:48:30 -0800 | [diff] [blame] | 382 | if [ -n "$hasMT" ] |
| 383 | then |
| 384 | $ECHO "- Test dictionary compression with multithreading " |
Yann Collet | 281f06e | 2017-12-14 11:47:02 -0800 | [diff] [blame] | 385 | ./datagen -g5M | $ZSTD -T2 -D tmpDict | $ZSTD -t -D tmpDict # fails with v1.3.2 |
Yann Collet | 311878d | 2017-12-13 11:48:30 -0800 | [diff] [blame] | 386 | fi |
Yann Collet | bd7fa21 | 2017-02-26 14:43:07 -0800 | [diff] [blame] | 387 | $ECHO "- Create second (different) dictionary " |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 388 | $ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 389 | $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] | 390 | $ECHO "- Create dictionary with short dictID" |
Yann Collet | 4c41d37 | 2017-03-24 18:36:56 -0700 | [diff] [blame] | 391 | $ZSTD --train *.c ../programs/*.c --dictID=1 -o tmpDict1 |
Yann Collet | 290aaa7 | 2016-05-30 21:18:52 +0200 | [diff] [blame] | 392 | cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 393 | $ECHO "- Create dictionary with wrong dictID parameter order (must fail)" |
| 394 | $ZSTD --train *.c ../programs/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument " |
| 395 | $ECHO "- Create dictionary with size limit" |
Yann Collet | 4c41d37 | 2017-03-24 18:36:56 -0700 | [diff] [blame] | 396 | $ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict=4K -v |
Nick Terrell | 3587556 | 2017-08-21 11:16:47 -0700 | [diff] [blame] | 397 | $ECHO "- Create dictionary with small size limit" |
| 398 | $ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict=1K -v |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 399 | $ECHO "- Create dictionary with wrong parameter order (must fail)" |
Nick Terrell | 3587556 | 2017-08-21 11:16:47 -0700 | [diff] [blame] | 400 | $ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument " |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 401 | $ECHO "- Compress without dictID" |
Yann Collet | 6381e99 | 2016-05-31 02:29:45 +0200 | [diff] [blame] | 402 | $ZSTD -f tmp -D tmpDict1 --no-dictID |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 403 | $ZSTD -d tmp.zst -D tmpDict -fo result |
Przemyslaw Skibinski | 5f5a902 | 2016-12-22 18:05:07 +0100 | [diff] [blame] | 404 | $DIFF $TESTFILE result |
Yann Collet | 27b5ac6 | 2016-09-21 14:20:56 +0200 | [diff] [blame] | 405 | $ECHO "- Compress with wrong argument order (must fail)" |
Sean Purcell | 9a38dfa | 2017-03-17 12:32:18 -0700 | [diff] [blame] | 406 | $ZSTD tmp -Df tmpDict1 -c > $INTOVOID && die "-D must be followed by dictionary name " |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 407 | $ECHO "- Compress multiple files with dictionary" |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 408 | rm -rf dirTestDict |
| 409 | mkdir dirTestDict |
| 410 | cp *.c dirTestDict |
inikep | b7d3449 | 2016-08-18 15:13:41 +0200 | [diff] [blame] | 411 | cp ../programs/*.c dirTestDict |
| 412 | cp ../programs/*.h dirTestDict |
Yann Collet | 94376ac | 2016-08-25 19:09:21 +0200 | [diff] [blame] | 413 | $MD5SUM dirTestDict/* > tmph1 |
| 414 | $ZSTD -f --rm dirTestDict/* -D tmpDictC |
Yann Collet | bb93d77 | 2016-08-25 22:22:50 +0200 | [diff] [blame] | 415 | $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] | 416 | case "$UNAME" in |
| 417 | 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] | 418 | *) $MD5SUM -c tmph1 ;; |
| 419 | esac |
Yann Collet | 531a427 | 2016-06-15 19:02:11 +0200 | [diff] [blame] | 420 | rm -rf dirTestDict |
Yann Collet | f332ece | 2017-03-23 16:24:02 -0700 | [diff] [blame] | 421 | $ECHO "- dictionary builder on bogus input" |
| 422 | $ECHO "Hello World" > tmp |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 423 | $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : not enough input source" |
Yann Collet | f332ece | 2017-03-23 16:24:02 -0700 | [diff] [blame] | 424 | ./datagen -P0 -g10M > tmp |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 425 | $ZSTD --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise" |
Nick Terrell | 58b8219 | 2018-07-09 18:24:07 -0700 | [diff] [blame] | 426 | $ECHO "- Test -o before --train" |
| 427 | rm -f tmpDict dictionary |
| 428 | $ZSTD -o tmpDict --train *.c ../programs/*.c |
| 429 | test -f tmpDict |
| 430 | $ZSTD --train *.c ../programs/*.c |
| 431 | test -f dictionary |
| 432 | rm tmp* dictionary |
Yann Collet | b44be74 | 2016-03-26 20:52:14 +0100 | [diff] [blame] | 433 | |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 434 | |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 435 | $ECHO "\n===> fastCover dictionary builder : advanced options " |
| 436 | |
| 437 | TESTFILE=../programs/zstdcli.c |
| 438 | ./datagen > tmpDict |
| 439 | $ECHO "- Create first dictionary" |
| 440 | $ZSTD --train-fastcover=k=46,d=8,f=15,split=80 *.c ../programs/*.c -o tmpDict |
| 441 | cp $TESTFILE tmp |
| 442 | $ZSTD -f tmp -D tmpDict |
| 443 | $ZSTD -d tmp.zst -D tmpDict -fo result |
| 444 | $DIFF $TESTFILE result |
| 445 | $ECHO "- Create second (different) dictionary" |
| 446 | $ZSTD --train-fastcover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC |
| 447 | $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!" |
| 448 | $ECHO "- Create dictionary with short dictID" |
| 449 | $ZSTD --train-fastcover=k=46,d=8,f=15,split=80 *.c ../programs/*.c --dictID=1 -o tmpDict1 |
| 450 | cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" |
| 451 | $ECHO "- Create dictionary with size limit" |
| 452 | $ZSTD --train-fastcover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K |
| 453 | $ECHO "- Compare size of dictionary from 90% training samples with 80% training samples" |
| 454 | $ZSTD --train-fastcover=split=90 -r *.c ../programs/*.c |
| 455 | $ZSTD --train-fastcover=split=80 -r *.c ../programs/*.c |
| 456 | $ECHO "- Create dictionary using all samples for both training and testing" |
| 457 | $ZSTD --train-fastcover=split=100 -r *.c ../programs/*.c |
| 458 | $ECHO "- Create dictionary using f=16" |
| 459 | $ZSTD --train-fastcover=f=16 -r *.c ../programs/*.c |
| 460 | $ECHO "- Create dictionary using accel=2" |
| 461 | $ZSTD --train-fastcover=accel=2 -r *.c ../programs/*.c |
| 462 | $ECHO "- Create dictionary using accel=10" |
| 463 | $ZSTD --train-fastcover=accel=10 -r *.c ../programs/*.c |
| 464 | $ECHO "- Create dictionary with multithreading" |
| 465 | $ZSTD --train-fastcover -T4 -r *.c ../programs/*.c |
| 466 | $ECHO "- Test -o before --train-fastcover" |
| 467 | rm -f tmpDict dictionary |
| 468 | $ZSTD -o tmpDict --train-fastcover *.c ../programs/*.c |
| 469 | test -f tmpDict |
| 470 | $ZSTD --train-fastcover *.c ../programs/*.c |
| 471 | test -f dictionary |
| 472 | rm tmp* dictionary |
| 473 | |
| 474 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 475 | $ECHO "\n===> legacy dictionary builder " |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 476 | |
| 477 | TESTFILE=../programs/zstdcli.c |
| 478 | ./datagen > tmpDict |
| 479 | $ECHO "- Create first dictionary" |
| 480 | $ZSTD --train-legacy=selectivity=8 *.c ../programs/*.c -o tmpDict |
| 481 | cp $TESTFILE tmp |
| 482 | $ZSTD -f tmp -D tmpDict |
| 483 | $ZSTD -d tmp.zst -D tmpDict -fo result |
| 484 | $DIFF $TESTFILE result |
| 485 | $ECHO "- Create second (different) dictionary" |
| 486 | $ZSTD --train-legacy=s=5 *.c ../programs/*.c ../programs/*.h -o tmpDictC |
| 487 | $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!" |
| 488 | $ECHO "- Create dictionary with short dictID" |
| 489 | $ZSTD --train-legacy -s5 *.c ../programs/*.c --dictID=1 -o tmpDict1 |
| 490 | cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" |
| 491 | $ECHO "- Create dictionary with size limit" |
| 492 | $ZSTD --train-legacy -s9 *.c ../programs/*.c -o tmpDict2 --maxdict=4K |
Nick Terrell | 58b8219 | 2018-07-09 18:24:07 -0700 | [diff] [blame] | 493 | $ECHO "- Test -o before --train-legacy" |
| 494 | rm -f tmpDict dictionary |
| 495 | $ZSTD -o tmpDict --train-legacy *.c ../programs/*.c |
| 496 | test -f tmpDict |
| 497 | $ZSTD --train-legacy *.c ../programs/*.c |
| 498 | test -f dictionary |
| 499 | rm tmp* dictionary |
Nick Terrell | cbb3ce3 | 2017-01-01 01:59:51 -0500 | [diff] [blame] | 500 | |
| 501 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 502 | $ECHO "\n===> integrity tests " |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 503 | |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 504 | $ECHO "test one file (tmp1.zst) " |
Yann Collet | 1a7b8fb | 2016-06-15 23:33:38 +0200 | [diff] [blame] | 505 | ./datagen > tmp1 |
| 506 | $ZSTD tmp1 |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 507 | $ZSTD -t tmp1.zst |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 508 | $ZSTD --test tmp1.zst |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 509 | $ECHO "test multiple files (*.zst) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 510 | $ZSTD -t *.zst |
Yann Collet | 24a3d90 | 2016-07-26 01:26:56 +0200 | [diff] [blame] | 511 | $ECHO "test bad files (*) " |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 512 | $ZSTD -t * && die "bad files not detected !" |
Yann Collet | 24a3d90 | 2016-07-26 01:26:56 +0200 | [diff] [blame] | 513 | $ZSTD -t tmp1 && die "bad file not detected !" |
| 514 | cp tmp1 tmp2.zst |
| 515 | $ZSTD -t tmp2.zst && die "bad file not detected !" |
Yann Collet | 7adc232 | 2016-07-26 15:39:31 +0200 | [diff] [blame] | 516 | ./datagen -g0 > tmp3 |
| 517 | $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] | 518 | $ECHO "test --rm and --test combined " |
| 519 | $ZSTD -t --rm tmp1.zst |
Yann Collet | 01a1abf | 2017-05-05 19:15:24 -0700 | [diff] [blame] | 520 | test -f tmp1.zst # check file is still present |
| 521 | split -b16384 tmp1.zst tmpSplit. |
| 522 | $ZSTD -t tmpSplit.* && die "bad file not detected !" |
Nick Terrell | d0b2748 | 2017-07-18 14:45:49 -0700 | [diff] [blame] | 523 | ./datagen | $ZSTD -c | $ZSTD -t |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 524 | |
Yann Collet | de95f96 | 2016-05-23 19:46:47 +0200 | [diff] [blame] | 525 | |
Nick Terrell | abe12b3 | 2017-07-28 11:54:28 -0700 | [diff] [blame] | 526 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 527 | $ECHO "\n===> golden files tests " |
Nick Terrell | abe12b3 | 2017-07-28 11:54:28 -0700 | [diff] [blame] | 528 | |
| 529 | $ZSTD -t -r files |
| 530 | $ZSTD -c -r files | $ZSTD -t |
| 531 | |
| 532 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 533 | $ECHO "\n===> benchmark mode tests " |
Yann Collet | b9550d6 | 2016-10-28 14:43:24 -0700 | [diff] [blame] | 534 | |
| 535 | $ECHO "bench one file" |
| 536 | ./datagen > tmp1 |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 537 | $ZSTD -bi0 tmp1 |
Yann Collet | b9550d6 | 2016-10-28 14:43:24 -0700 | [diff] [blame] | 538 | $ECHO "bench multiple levels" |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 539 | $ZSTD -i0b0e3 tmp1 |
Yann Collet | 6a9b41b | 2018-03-11 19:56:48 -0700 | [diff] [blame] | 540 | $ECHO "bench negative level" |
| 541 | $ZSTD -bi0 --fast tmp1 |
Yann Collet | b9550d6 | 2016-10-28 14:43:24 -0700 | [diff] [blame] | 542 | $ECHO "with recursive and quiet modes" |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 543 | $ZSTD -rqi1b1e2 tmp1 |
Yann Collet | f40c6b4 | 2018-11-08 12:51:42 -0800 | [diff] [blame] | 544 | $ECHO "benchmark decompression only" |
| 545 | $ZSTD -f tmp1 |
| 546 | $ZSTD -b -d -i1 tmp1.zst |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 547 | |
George Lu | cfc3451 | 2018-06-01 09:52:25 -0700 | [diff] [blame] | 548 | $ECHO "\n===> zstd compatibility tests " |
| 549 | |
| 550 | ./datagen > tmp |
George Lu | 41249bf | 2018-06-01 10:54:51 -0700 | [diff] [blame] | 551 | rm -f tmp.zst |
| 552 | $ZSTD --format=zstd -f tmp |
| 553 | test -f tmp.zst |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 554 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 555 | $ECHO "\n===> gzip compatibility tests " |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 556 | |
| 557 | GZIPMODE=1 |
| 558 | $ZSTD --format=gzip -V || GZIPMODE=0 |
| 559 | if [ $GZIPMODE -eq 1 ]; then |
Yann Collet | 27526c7 | 2017-03-01 17:02:49 -0800 | [diff] [blame] | 560 | $ECHO "gzip support detected" |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 561 | GZIPEXE=1 |
Yann Collet | 27526c7 | 2017-03-01 17:02:49 -0800 | [diff] [blame] | 562 | gzip -V || GZIPEXE=0 |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 563 | if [ $GZIPEXE -eq 1 ]; then |
| 564 | ./datagen > tmp |
| 565 | $ZSTD --format=gzip -f tmp |
| 566 | gzip -t -v tmp.gz |
| 567 | gzip -f tmp |
| 568 | $ZSTD -d -f -v tmp.gz |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 569 | rm tmp* |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 570 | else |
| 571 | $ECHO "gzip binary not detected" |
| 572 | fi |
| 573 | else |
| 574 | $ECHO "gzip mode not supported" |
| 575 | fi |
Yann Collet | b9550d6 | 2016-10-28 14:43:24 -0700 | [diff] [blame] | 576 | |
| 577 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 578 | $ECHO "\n===> gzip frame tests " |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 579 | |
| 580 | if [ $GZIPMODE -eq 1 ]; then |
| 581 | ./datagen > tmp |
| 582 | $ZSTD -f --format=gzip tmp |
| 583 | $ZSTD -f tmp |
| 584 | cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp |
Björn Ketelaars | 06fd1e4 | 2018-06-30 15:42:42 +0200 | [diff] [blame] | 585 | truncateLastByte tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 586 | rm tmp* |
| 587 | else |
| 588 | $ECHO "gzip mode not supported" |
| 589 | fi |
| 590 | |
George Lu | 41249bf | 2018-06-01 10:54:51 -0700 | [diff] [blame] | 591 | if [ $GZIPMODE -eq 1 ]; then |
| 592 | ./datagen > tmp |
| 593 | rm -f tmp.zst |
Jennifer Liu | aef8486 | 2018-06-27 14:27:27 -0700 | [diff] [blame] | 594 | $ZSTD --format=gzip --format=zstd -f tmp |
George Lu | 41249bf | 2018-06-01 10:54:51 -0700 | [diff] [blame] | 595 | test -f tmp.zst |
| 596 | fi |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 597 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 598 | $ECHO "\n===> xz compatibility tests " |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 599 | |
| 600 | LZMAMODE=1 |
| 601 | $ZSTD --format=xz -V || LZMAMODE=0 |
| 602 | if [ $LZMAMODE -eq 1 ]; then |
| 603 | $ECHO "xz support detected" |
| 604 | XZEXE=1 |
Björn Ketelaars | 527dbf8 | 2018-06-30 13:22:14 +0200 | [diff] [blame] | 605 | xz -Q -V && lzma -Q -V || XZEXE=0 |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 606 | if [ $XZEXE -eq 1 ]; then |
Nick Terrell | 6aeb50e | 2017-06-26 11:24:36 -0700 | [diff] [blame] | 607 | $ECHO "Testing zstd xz and lzma support" |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 608 | ./datagen > tmp |
| 609 | $ZSTD --format=lzma -f tmp |
| 610 | $ZSTD --format=xz -f tmp |
Björn Ketelaars | 527dbf8 | 2018-06-30 13:22:14 +0200 | [diff] [blame] | 611 | xz -Q -t -v tmp.xz |
| 612 | xz -Q -t -v tmp.lzma |
| 613 | xz -Q -f -k tmp |
| 614 | lzma -Q -f -k --lzma1 tmp |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 615 | $ZSTD -d -f -v tmp.xz |
| 616 | $ZSTD -d -f -v tmp.lzma |
| 617 | rm tmp* |
Nick Terrell | 6aeb50e | 2017-06-26 11:24:36 -0700 | [diff] [blame] | 618 | $ECHO "Creating symlinks" |
| 619 | ln -s $ZSTD ./xz |
| 620 | ln -s $ZSTD ./unxz |
| 621 | ln -s $ZSTD ./lzma |
| 622 | ln -s $ZSTD ./unlzma |
| 623 | $ECHO "Testing xz and lzma symlinks" |
| 624 | ./datagen > tmp |
| 625 | ./xz tmp |
Björn Ketelaars | 527dbf8 | 2018-06-30 13:22:14 +0200 | [diff] [blame] | 626 | xz -Q -d tmp.xz |
Nick Terrell | 6aeb50e | 2017-06-26 11:24:36 -0700 | [diff] [blame] | 627 | ./lzma tmp |
Björn Ketelaars | 527dbf8 | 2018-06-30 13:22:14 +0200 | [diff] [blame] | 628 | lzma -Q -d tmp.lzma |
Nick Terrell | 6aeb50e | 2017-06-26 11:24:36 -0700 | [diff] [blame] | 629 | $ECHO "Testing unxz and unlzma symlinks" |
Björn Ketelaars | 527dbf8 | 2018-06-30 13:22:14 +0200 | [diff] [blame] | 630 | xz -Q tmp |
Nick Terrell | 6aeb50e | 2017-06-26 11:24:36 -0700 | [diff] [blame] | 631 | ./xz -d tmp.xz |
Björn Ketelaars | 527dbf8 | 2018-06-30 13:22:14 +0200 | [diff] [blame] | 632 | lzma -Q tmp |
Nick Terrell | 6aeb50e | 2017-06-26 11:24:36 -0700 | [diff] [blame] | 633 | ./lzma -d tmp.lzma |
| 634 | rm xz unxz lzma unlzma |
| 635 | rm tmp* |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 636 | else |
| 637 | $ECHO "xz binary not detected" |
| 638 | fi |
| 639 | else |
| 640 | $ECHO "xz mode not supported" |
| 641 | fi |
| 642 | |
| 643 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 644 | $ECHO "\n===> xz frame tests " |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 645 | |
| 646 | if [ $LZMAMODE -eq 1 ]; then |
| 647 | ./datagen > tmp |
| 648 | $ZSTD -f --format=xz tmp |
| 649 | $ZSTD -f --format=lzma tmp |
| 650 | $ZSTD -f tmp |
| 651 | cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp |
Björn Ketelaars | 06fd1e4 | 2018-06-30 15:42:42 +0200 | [diff] [blame] | 652 | truncateLastByte tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" |
| 653 | truncateLastByte tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 654 | rm tmp* |
| 655 | else |
| 656 | $ECHO "xz mode not supported" |
| 657 | fi |
| 658 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 659 | $ECHO "\n===> lz4 compatibility tests " |
Sean Purcell | 4de8632 | 2017-04-24 16:48:25 -0700 | [diff] [blame] | 660 | |
| 661 | LZ4MODE=1 |
| 662 | $ZSTD --format=lz4 -V || LZ4MODE=0 |
| 663 | if [ $LZ4MODE -eq 1 ]; then |
| 664 | $ECHO "lz4 support detected" |
| 665 | LZ4EXE=1 |
| 666 | lz4 -V || LZ4EXE=0 |
| 667 | if [ $LZ4EXE -eq 1 ]; then |
| 668 | ./datagen > tmp |
| 669 | $ZSTD --format=lz4 -f tmp |
| 670 | lz4 -t -v tmp.lz4 |
| 671 | lz4 -f tmp |
| 672 | $ZSTD -d -f -v tmp.lz4 |
| 673 | rm tmp* |
| 674 | else |
| 675 | $ECHO "lz4 binary not detected" |
| 676 | fi |
| 677 | else |
| 678 | $ECHO "lz4 mode not supported" |
| 679 | fi |
| 680 | |
| 681 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 682 | $ECHO "\n===> lz4 frame tests " |
Sean Purcell | 4de8632 | 2017-04-24 16:48:25 -0700 | [diff] [blame] | 683 | |
| 684 | if [ $LZ4MODE -eq 1 ]; then |
| 685 | ./datagen > tmp |
| 686 | $ZSTD -f --format=lz4 tmp |
| 687 | $ZSTD -f tmp |
| 688 | cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp |
Björn Ketelaars | 06fd1e4 | 2018-06-30 15:42:42 +0200 | [diff] [blame] | 689 | truncateLastByte tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" |
Sean Purcell | 4de8632 | 2017-04-24 16:48:25 -0700 | [diff] [blame] | 690 | rm tmp* |
| 691 | else |
| 692 | $ECHO "lz4 mode not supported" |
| 693 | fi |
Nick Terrell | aa8bcf3 | 2017-03-13 18:11:07 -0700 | [diff] [blame] | 694 | |
George Lu | 53ea32c | 2018-06-01 10:43:06 -0700 | [diff] [blame] | 695 | $ECHO "\n===> suffix list test" |
| 696 | |
George Lu | 110ec90 | 2018-06-01 12:45:02 -0700 | [diff] [blame] | 697 | ! $ZSTD -d tmp.abc 2> tmplg |
George Lu | 53ea32c | 2018-06-01 10:43:06 -0700 | [diff] [blame] | 698 | |
Jennifer Liu | aef8486 | 2018-06-27 14:27:27 -0700 | [diff] [blame] | 699 | if [ $GZIPMODE -ne 1 ]; then |
George Lu | 53ea32c | 2018-06-01 10:43:06 -0700 | [diff] [blame] | 700 | grep ".gz" tmplg > $INTOVOID && die "Unsupported suffix listed" |
| 701 | fi |
| 702 | |
Jennifer Liu | aef8486 | 2018-06-27 14:27:27 -0700 | [diff] [blame] | 703 | if [ $LZMAMODE -ne 1 ]; then |
George Lu | 53ea32c | 2018-06-01 10:43:06 -0700 | [diff] [blame] | 704 | grep ".lzma" tmplg > $INTOVOID && die "Unsupported suffix listed" |
| 705 | grep ".xz" tmplg > $INTOVOID && die "Unsupported suffix listed" |
| 706 | fi |
| 707 | |
| 708 | if [ $LZ4MODE -ne 1 ]; then |
| 709 | grep ".lz4" tmplg > $INTOVOID && die "Unsupported suffix listed" |
| 710 | fi |
| 711 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 712 | $ECHO "\n===> zstd round-trip tests " |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 713 | |
| 714 | roundTripTest |
Yann Collet | 3b71925 | 2016-03-30 19:48:05 +0200 | [diff] [blame] | 715 | roundTripTest -g15K # TableID==3 |
| 716 | roundTripTest -g127K # TableID==2 |
| 717 | roundTripTest -g255K # TableID==1 |
Yann Collet | c1c040e | 2017-03-01 16:49:20 -0800 | [diff] [blame] | 718 | roundTripTest -g522K # TableID==0 |
| 719 | roundTripTest -g519K 6 # greedy, hash chain |
| 720 | roundTripTest -g517K 16 # btlazy2 |
| 721 | roundTripTest -g516K 19 # btopt |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 722 | |
Sean Purcell | eb70d21 | 2017-04-11 17:15:13 -0700 | [diff] [blame] | 723 | fileRoundTripTest -g500K |
| 724 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 725 | $ECHO "\n===> zstd long distance matching round-trip tests " |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 726 | roundTripTest -g0 "2 --single-thread --long" |
| 727 | roundTripTest -g1000K "1 --single-thread --long" |
| 728 | roundTripTest -g517K "6 --single-thread --long" |
| 729 | roundTripTest -g516K "16 --single-thread --long" |
| 730 | roundTripTest -g518K "19 --single-thread --long" |
| 731 | fileRoundTripTest -g5M "3 --single-thread --long" |
Stella Lau | 6a546ef | 2017-07-28 15:51:33 -0700 | [diff] [blame] | 732 | |
| 733 | |
Yann Collet | 7568983 | 2018-02-09 15:53:27 -0800 | [diff] [blame] | 734 | roundTripTest -g96K "5 --single-thread" |
Sean Purcell | c424ec2 | 2017-04-17 11:38:53 -0700 | [diff] [blame] | 735 | if [ -n "$hasMT" ] |
| 736 | then |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 737 | $ECHO "\n===> zstdmt round-trip tests " |
Sean Purcell | d845dab | 2017-04-17 12:10:58 -0700 | [diff] [blame] | 738 | roundTripTest -g4M "1 -T0" |
| 739 | roundTripTest -g8M "3 -T2" |
Yann Collet | 230d7ac | 2017-04-21 11:38:13 -0700 | [diff] [blame] | 740 | roundTripTest -g8000K "2 --threads=2" |
Sean Purcell | d845dab | 2017-04-17 12:10:58 -0700 | [diff] [blame] | 741 | fileRoundTripTest -g4M "19 -T2 -B1M" |
Stella Lau | 6a546ef | 2017-07-28 15:51:33 -0700 | [diff] [blame] | 742 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 743 | $ECHO "\n===> zstdmt long distance matching round-trip tests " |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 744 | roundTripTest -g8M "3 --long=24 -T2" |
Yann Collet | 96b480a | 2018-03-29 13:07:28 -0600 | [diff] [blame] | 745 | |
| 746 | $ECHO "\n===> ovLog tests " |
| 747 | ./datagen -g2MB > tmp |
| 748 | refSize=$($ZSTD tmp -6 -c --zstd=wlog=18 | wc -c) |
| 749 | ov9Size=$($ZSTD tmp -6 -c --zstd=wlog=18,ovlog=9 | wc -c) |
| 750 | ov0Size=$($ZSTD tmp -6 -c --zstd=wlog=18,ovlog=0 | wc -c) |
| 751 | if [ $refSize -eq $ov9Size ]; then |
| 752 | echo ov9Size should be different from refSize |
| 753 | exit 1 |
| 754 | fi |
| 755 | if [ $refSize -eq $ov0Size ]; then |
| 756 | echo ov0Size should be different from refSize |
| 757 | exit 1 |
| 758 | fi |
| 759 | if [ $ov9Size -ge $ov0Size ]; then |
| 760 | echo ov9Size=$ov9Size should be smaller than ov0Size=$ov0Size |
| 761 | exit 1 |
| 762 | fi |
| 763 | |
Sean Purcell | c424ec2 | 2017-04-17 11:38:53 -0700 | [diff] [blame] | 764 | else |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 765 | $ECHO "\n===> no multithreading, skipping zstdmt tests " |
Sean Purcell | c424ec2 | 2017-04-17 11:38:53 -0700 | [diff] [blame] | 766 | fi |
| 767 | |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 768 | rm tmp* |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 769 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 770 | $ECHO "\n===> zstd --list/-l single frame tests " |
Paul Cruz | ddd1ab7 | 2017-06-15 16:53:03 -0700 | [diff] [blame] | 771 | ./datagen > tmp1 |
| 772 | ./datagen > tmp2 |
| 773 | ./datagen > tmp3 |
Paul Cruz | ddd1ab7 | 2017-06-15 16:53:03 -0700 | [diff] [blame] | 774 | $ZSTD tmp* |
Paul Cruz | 6a99de2 | 2017-06-20 10:45:06 -0700 | [diff] [blame] | 775 | $ZSTD -l *.zst |
Yann Collet | 43914f6 | 2017-10-13 23:47:01 -0700 | [diff] [blame] | 776 | $ZSTD -lv *.zst | grep "Decompressed Size:" # check that decompressed size is present in header |
Paul Cruz | 6a99de2 | 2017-06-20 10:45:06 -0700 | [diff] [blame] | 777 | $ZSTD --list *.zst |
| 778 | $ZSTD --list -v *.zst |
Paul Cruz | ddd1ab7 | 2017-06-15 16:53:03 -0700 | [diff] [blame] | 779 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 780 | $ECHO "\n===> zstd --list/-l multiple frame tests " |
Paul Cruz | ddd1ab7 | 2017-06-15 16:53:03 -0700 | [diff] [blame] | 781 | cat tmp1.zst tmp2.zst > tmp12.zst |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 782 | cat tmp12.zst tmp3.zst > tmp123.zst |
Paul Cruz | 6a99de2 | 2017-06-20 10:45:06 -0700 | [diff] [blame] | 783 | $ZSTD -l *.zst |
| 784 | $ZSTD -lv *.zst |
Paul Cruz | ddd1ab7 | 2017-06-15 16:53:03 -0700 | [diff] [blame] | 785 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 786 | $ECHO "\n===> zstd --list/-l error detection tests " |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 787 | $ZSTD -l tmp1 tmp1.zst && die "-l must fail on non-zstd file" |
| 788 | $ZSTD --list tmp* && die "-l must fail on non-zstd file" |
| 789 | $ZSTD -lv tmp1* && die "-l must fail on non-zstd file" |
| 790 | $ZSTD --list -v tmp2 tmp12.zst && die "-l must fail on non-zstd file" |
Paul Cruz | b07d0af | 2017-06-20 11:54:44 -0700 | [diff] [blame] | 791 | |
W. Felix Handte | 8e7bdc1 | 2018-06-29 16:31:22 -0400 | [diff] [blame] | 792 | $ECHO "\n===> zstd --list/-l errors when presented with stdin / no files" |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 793 | $ZSTD -l && die "-l must fail on empty list of files" |
| 794 | $ZSTD -l - && die "-l does not work on stdin" |
| 795 | $ZSTD -l < tmp1.zst && die "-l does not work on stdin" |
| 796 | $ZSTD -l - < tmp1.zst && die "-l does not work on stdin" |
| 797 | $ZSTD -l - tmp1.zst && die "-l does not work on stdin" |
| 798 | $ZSTD -l - tmp1.zst < tmp1.zst && die "-l does not work on stdin" |
| 799 | $ZSTD -l tmp1.zst < tmp2.zst # this will check tmp1.zst, but not tmp2.zst, which is not an error : zstd simply doesn't read stdin in this case. It must not error just because stdin is not a tty |
Topher Lubaway | 5bac1db | 2018-06-19 09:56:37 -0700 | [diff] [blame] | 800 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 801 | $ECHO "\n===> zstd --list/-l test with null files " |
Paul Cruz | a73c2a4 | 2017-06-20 14:33:08 -0700 | [diff] [blame] | 802 | ./datagen -g0 > tmp5 |
| 803 | $ZSTD tmp5 |
Yann Collet | c16748b | 2017-06-21 12:09:53 -0700 | [diff] [blame] | 804 | $ZSTD -l tmp5.zst |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 805 | $ZSTD -l tmp5* && die "-l must fail on non-zstd file" |
Yann Collet | 5891f1d | 2017-10-17 16:23:20 -0700 | [diff] [blame] | 806 | $ZSTD -lv tmp5.zst | grep "Decompressed Size: 0.00 KB (0 B)" # check that 0 size is present in header |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 807 | $ZSTD -lv tmp5* && die "-l must fail on non-zstd file" |
Paul Cruz | a73c2a4 | 2017-06-20 14:33:08 -0700 | [diff] [blame] | 808 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 809 | $ECHO "\n===> zstd --list/-l test with no content size field " |
Yann Collet | 43914f6 | 2017-10-13 23:47:01 -0700 | [diff] [blame] | 810 | ./datagen -g513K | $ZSTD > tmp6.zst |
Paul Cruz | db3606e | 2017-06-20 17:43:36 -0700 | [diff] [blame] | 811 | $ZSTD -l tmp6.zst |
Yann Collet | 63abaf2 | 2018-09-25 15:57:28 -0700 | [diff] [blame] | 812 | $ZSTD -lv tmp6.zst | grep "Decompressed Size:" && die "Field :Decompressed Size: should not be available in this compressed file" |
Yann Collet | c16748b | 2017-06-21 12:09:53 -0700 | [diff] [blame] | 813 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 814 | $ECHO "\n===> zstd --list/-l test with no checksum " |
Yann Collet | c16748b | 2017-06-21 12:09:53 -0700 | [diff] [blame] | 815 | $ZSTD -f --no-check tmp1 |
| 816 | $ZSTD -l tmp1.zst |
| 817 | $ZSTD -lv tmp1.zst |
Paul Cruz | db3606e | 2017-06-20 17:43:36 -0700 | [diff] [blame] | 818 | |
Paul Cruz | ddd1ab7 | 2017-06-15 16:53:03 -0700 | [diff] [blame] | 819 | rm tmp* |
| 820 | |
Yann Collet | c16748b | 2017-06-21 12:09:53 -0700 | [diff] [blame] | 821 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 822 | $ECHO "\n===> zstd long distance matching tests " |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 823 | roundTripTest -g0 " --single-thread --long" |
| 824 | roundTripTest -g9M "2 --single-thread --long" |
Yann Collet | 0250219 | 2017-09-27 15:48:06 -0700 | [diff] [blame] | 825 | # Test parameter parsing |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 826 | roundTripTest -g1M -P50 "1 --single-thread --long=29" " --memory=512MB" |
| 827 | roundTripTest -g1M -P50 "1 --single-thread --long=29 --zstd=wlog=28" " --memory=256MB" |
| 828 | roundTripTest -g1M -P50 "1 --single-thread --long=29" " --long=28 --memory=512MB" |
| 829 | roundTripTest -g1M -P50 "1 --single-thread --long=29" " --zstd=wlog=28 --memory=512MB" |
Yann Collet | 0250219 | 2017-09-27 15:48:06 -0700 | [diff] [blame] | 830 | |
| 831 | |
Yann Collet | 6c51bf4 | 2018-09-24 18:16:08 -0700 | [diff] [blame] | 832 | $ECHO "\n===> adaptive mode " |
| 833 | roundTripTest -g270000000 " --adapt" |
| 834 | roundTripTest -g27000000 " --adapt=min=1,max=4" |
Yann Collet | 9012b6c | 2018-10-01 17:16:34 -0700 | [diff] [blame] | 835 | $ECHO "===> test: --adapt must fail on incoherent bounds " |
Yann Collet | 6c51bf4 | 2018-09-24 18:16:08 -0700 | [diff] [blame] | 836 | ./datagen > tmp |
| 837 | $ZSTD -f -vv --adapt=min=10,max=9 tmp && die "--adapt must fail on incoherent bounds" |
| 838 | |
Nick Terrell | 71fe78c | 2018-11-14 13:53:14 -0800 | [diff] [blame^] | 839 | $ECHO "\n===> rsyncable mode " |
| 840 | roundTripTest -g10M " --rsyncable" |
| 841 | roundTripTest -g10M " --rsyncable -B100K" |
| 842 | $ECHO "===> test: --rsyncable must fail with --single-thread" |
| 843 | $ZSTD -f -vv --rsyncable --single-thread tmp && die "--rsyncable must fail with --single-thread" |
| 844 | |
Yann Collet | 6c51bf4 | 2018-09-24 18:16:08 -0700 | [diff] [blame] | 845 | |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 846 | if [ "$1" != "--test-large-data" ]; then |
inikep | 5d58956 | 2016-05-25 10:50:28 +0200 | [diff] [blame] | 847 | $ECHO "Skipping large data tests" |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 848 | exit 0 |
| 849 | fi |
| 850 | |
Yann Collet | 6c51bf4 | 2018-09-24 18:16:08 -0700 | [diff] [blame] | 851 | |
Yann Collet | 9012b6c | 2018-10-01 17:16:34 -0700 | [diff] [blame] | 852 | ############################################################################# |
Yann Collet | 6c51bf4 | 2018-09-24 18:16:08 -0700 | [diff] [blame] | 853 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 854 | $ECHO "\n===> large files tests " |
Yann Collet | 0250219 | 2017-09-27 15:48:06 -0700 | [diff] [blame] | 855 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 856 | roundTripTest -g270000000 1 |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 857 | roundTripTest -g250000000 2 |
| 858 | roundTripTest -g230000000 3 |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 859 | |
| 860 | roundTripTest -g140000000 -P60 4 |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 861 | roundTripTest -g130000000 -P62 5 |
| 862 | roundTripTest -g120000000 -P65 6 |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 863 | |
| 864 | roundTripTest -g70000000 -P70 7 |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 865 | roundTripTest -g60000000 -P71 8 |
| 866 | roundTripTest -g50000000 -P73 9 |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 867 | |
| 868 | roundTripTest -g35000000 -P75 10 |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 869 | roundTripTest -g30000000 -P76 11 |
| 870 | roundTripTest -g25000000 -P78 12 |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 871 | |
Yann Collet | 4616fad | 2017-07-10 17:16:41 -0700 | [diff] [blame] | 872 | roundTripTest -g18000013 -P80 13 |
| 873 | roundTripTest -g18000014 -P80 14 |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 874 | roundTripTest -g18000015 -P81 15 |
| 875 | roundTripTest -g18000016 -P84 16 |
| 876 | roundTripTest -g18000017 -P88 17 |
Yann Collet | 4616fad | 2017-07-10 17:16:41 -0700 | [diff] [blame] | 877 | roundTripTest -g18000018 -P94 18 |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 878 | roundTripTest -g18000019 -P96 19 |
Konstantin Tokarev | 2b46584 | 2015-12-08 19:36:42 +0300 | [diff] [blame] | 879 | |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 880 | roundTripTest -g5000000000 -P99 1 |
Yann Collet | 4c7f137 | 2017-12-29 17:40:36 +0100 | [diff] [blame] | 881 | roundTripTest -g1700000000 -P0 "1 --zstd=strategy=6" # ensure btlazy2 can survive an overflow rescale |
Yann Collet | 459a6b7 | 2016-02-15 20:37:23 +0100 | [diff] [blame] | 882 | |
Sean Purcell | eb70d21 | 2017-04-11 17:15:13 -0700 | [diff] [blame] | 883 | fileRoundTripTest -g4193M -P99 1 |
| 884 | |
Yann Collet | 0250219 | 2017-09-27 15:48:06 -0700 | [diff] [blame] | 885 | |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 886 | $ECHO "\n===> zstd long, long distance matching round-trip tests " |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 887 | roundTripTest -g270000000 "1 --single-thread --long" |
| 888 | roundTripTest -g130000000 -P60 "5 --single-thread --long" |
| 889 | roundTripTest -g35000000 -P70 "8 --single-thread --long" |
| 890 | roundTripTest -g18000001 -P80 "18 --single-thread --long" |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 891 | # Test large window logs |
Nick Terrell | f15a17e | 2018-02-27 20:09:18 -0800 | [diff] [blame] | 892 | roundTripTest -g700M -P50 "1 --single-thread --long=29" |
| 893 | roundTripTest -g600M -P50 "1 --single-thread --long --zstd=wlog=29,clog=28" |
Stella Lau | 6a546ef | 2017-07-28 15:51:33 -0700 | [diff] [blame] | 894 | |
| 895 | |
Sean Purcell | c424ec2 | 2017-04-17 11:38:53 -0700 | [diff] [blame] | 896 | if [ -n "$hasMT" ] |
| 897 | then |
Yann Collet | 241c57a | 2017-10-16 14:01:42 -0700 | [diff] [blame] | 898 | $ECHO "\n===> zstdmt long round-trip tests " |
Yann Collet | 60059df | 2017-09-27 15:16:27 -0700 | [diff] [blame] | 899 | roundTripTest -g80000000 -P99 "19 -T2" " " |
| 900 | roundTripTest -g5000000000 -P99 "1 -T2" " " |
| 901 | roundTripTest -g500000000 -P97 "1 -T999" " " |
| 902 | fileRoundTripTest -g4103M -P98 " -T0" " " |
| 903 | roundTripTest -g400000000 -P97 "1 --long=24 -T2" " " |
Sean Purcell | c424ec2 | 2017-04-17 11:38:53 -0700 | [diff] [blame] | 904 | else |
| 905 | $ECHO "\n**** no multithreading, skipping zstdmt tests **** " |
| 906 | fi |
| 907 | |
Yann Collet | 45010da | 2018-09-19 17:37:22 -0700 | [diff] [blame] | 908 | |
| 909 | $ECHO "\n===> cover dictionary builder : advanced options " |
| 910 | |
| 911 | TESTFILE=../programs/zstdcli.c |
| 912 | ./datagen > tmpDict |
| 913 | $ECHO "- Create first dictionary" |
| 914 | $ZSTD --train-cover=k=46,d=8,split=80 *.c ../programs/*.c -o tmpDict |
| 915 | cp $TESTFILE tmp |
| 916 | $ZSTD -f tmp -D tmpDict |
| 917 | $ZSTD -d tmp.zst -D tmpDict -fo result |
| 918 | $DIFF $TESTFILE result |
| 919 | $ECHO "- Create second (different) dictionary" |
| 920 | $ZSTD --train-cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC |
| 921 | $ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!" |
| 922 | $ECHO "- Create dictionary with short dictID" |
| 923 | $ZSTD --train-cover=k=46,d=8,split=80 *.c ../programs/*.c --dictID=1 -o tmpDict1 |
| 924 | cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" |
| 925 | $ECHO "- Create dictionary with size limit" |
| 926 | $ZSTD --train-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K |
| 927 | $ECHO "- Compare size of dictionary from 90% training samples with 80% training samples" |
| 928 | $ZSTD --train-cover=split=90 -r *.c ../programs/*.c |
| 929 | $ZSTD --train-cover=split=80 -r *.c ../programs/*.c |
| 930 | $ECHO "- Create dictionary using all samples for both training and testing" |
| 931 | $ZSTD --train-cover=split=100 -r *.c ../programs/*.c |
| 932 | $ECHO "- Test -o before --train-cover" |
| 933 | rm -f tmpDict dictionary |
| 934 | $ZSTD -o tmpDict --train-cover *.c ../programs/*.c |
| 935 | test -f tmpDict |
| 936 | $ZSTD --train-cover *.c ../programs/*.c |
| 937 | test -f dictionary |
Yann Collet | 1551947 | 2018-09-20 13:00:11 -0700 | [diff] [blame] | 938 | rm -f tmp* dictionary |
Yann Collet | 45010da | 2018-09-19 17:37:22 -0700 | [diff] [blame] | 939 | |
| 940 | |
Yann Collet | 1551947 | 2018-09-20 13:00:11 -0700 | [diff] [blame] | 941 | rm -f tmp* |