Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | |
| 3 | die() { |
| 4 | echo "$@" 1>&2 |
| 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 |
| 17 | echo "roundTripTest: ./datagen $1 $p | $ZSTD -v$c | $ZSTD -d" |
| 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 | |
| 23 | [ -n "$ZSTD" ] || die "ZSTD variable must be defined!" |
| 24 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 25 | |
Yann Collet | 8154c3d | 2016-02-13 03:12:10 +0100 | [diff] [blame^] | 26 | echo "\n**** simple test **** " |
| 27 | ./datagen > tmp |
| 28 | $ZSTD tmp |
| 29 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 30 | echo "\n**** frame concatenation **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 31 | |
| 32 | echo "hello " > hello.tmp |
| 33 | echo "world!" > world.tmp |
| 34 | cat hello.tmp world.tmp > helloworld.tmp |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 35 | $ZSTD -c hello.tmp > hello.zstd |
| 36 | $ZSTD -c world.tmp > world.zstd |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 37 | cat hello.zstd world.zstd > helloworld.zstd |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 38 | $ZSTD -dc helloworld.zstd > result.tmp |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 39 | cat result.tmp |
| 40 | sdiff helloworld.tmp result.tmp |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 41 | rm ./*.tmp ./*.zstd |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 42 | |
| 43 | echo frame concatenation test completed |
| 44 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 45 | |
| 46 | echo "\n**** flush write error test **** " |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 47 | |
Yann Collet | 6a45835 | 2015-12-18 02:51:14 +0100 | [diff] [blame] | 48 | echo "echo foo | $ZSTD > /dev/full" |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 49 | echo foo | $ZSTD > /dev/full && die "write error not detected!" |
Yann Collet | 6a45835 | 2015-12-18 02:51:14 +0100 | [diff] [blame] | 50 | echo "echo foo | $ZSTD | $ZSTD -d > /dev/full" |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 51 | echo foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!" |
| 52 | |
Yann Collet | 6a45835 | 2015-12-18 02:51:14 +0100 | [diff] [blame] | 53 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 54 | echo "\n**** dictionary tests **** " |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 55 | |
| 56 | ./datagen > tmpDict |
| 57 | ./datagen -g1M | md5sum > tmp1 |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 58 | ./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | md5sum > tmp2 |
Yann Collet | f6f3d75 | 2015-12-13 13:35:21 +0100 | [diff] [blame] | 59 | diff -q tmp1 tmp2 |
| 60 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 61 | echo "\n**** multiple files tests **** " |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 62 | |
| 63 | ./datagen -s1 > tmp1 2> /dev/null |
| 64 | ./datagen -s2 -g100K > tmp2 2> /dev/null |
| 65 | ./datagen -s3 -g1M > tmp3 2> /dev/null |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 66 | $ZSTD -f tmp* |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 67 | echo "compress tmp* : " |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 68 | ls -ls tmp* |
| 69 | rm tmp1 tmp2 tmp3 |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 70 | echo "decompress tmp* : " |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 71 | $ZSTD -df *.zst |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 72 | ls -ls tmp* |
Yann Collet | 1f1f239 | 2016-02-12 18:33:26 +0100 | [diff] [blame] | 73 | echo "compress tmp* into stdout > tmpall : " |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 74 | $ZSTD -c tmp1 tmp2 tmp3 > tmpall |
| 75 | ls -ls tmp* |
Yann Collet | 1f1f239 | 2016-02-12 18:33:26 +0100 | [diff] [blame] | 76 | echo "decompress tmpall* into stdout > tmpdec : " |
| 77 | cp tmpall tmpall2 |
| 78 | $ZSTD -dc tmpall* > tmpdec |
| 79 | ls -ls tmp* |
Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 80 | $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!" |
Yann Collet | deb078b | 2015-12-17 20:30:14 +0100 | [diff] [blame] | 81 | rm tmp* |
| 82 | |
Yann Collet | f062436 | 2016-02-12 15:56:46 +0100 | [diff] [blame] | 83 | echo "\n**** zstd round-trip tests **** " |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 84 | |
| 85 | roundTripTest |
| 86 | roundTripTest '' 6 |
Yann Collet | ee602ce | 2016-02-08 18:46:26 +0100 | [diff] [blame] | 87 | roundTripTest '' 16 |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 88 | |
Konstantin Tokarev | 0b570b5 | 2015-12-08 18:47:43 +0300 | [diff] [blame] | 89 | if [ "$1" != "--test-large-data" ]; then |
| 90 | echo "Skipping large data tests" |
| 91 | exit 0 |
| 92 | fi |
| 93 | |
Konstantin Tokarev | 76be378 | 2015-12-08 18:36:37 +0300 | [diff] [blame] | 94 | roundTripTest -g270000000 1 |
| 95 | roundTripTest -g270000000 2 |
| 96 | roundTripTest -g270000000 3 |
| 97 | |
| 98 | roundTripTest -g140000000 -P60 4 |
| 99 | roundTripTest -g140000000 -P60 5 |
| 100 | roundTripTest -g140000000 -P60 6 |
| 101 | |
| 102 | roundTripTest -g70000000 -P70 7 |
| 103 | roundTripTest -g70000000 -P70 8 |
| 104 | roundTripTest -g70000000 -P70 9 |
| 105 | |
| 106 | roundTripTest -g35000000 -P75 10 |
| 107 | roundTripTest -g35000000 -P75 11 |
| 108 | roundTripTest -g35000000 -P75 12 |
Konstantin Tokarev | d66db2f | 2015-12-08 18:11:10 +0300 | [diff] [blame] | 109 | |
Konstantin Tokarev | 2b46584 | 2015-12-08 19:36:42 +0300 | [diff] [blame] | 110 | roundTripTest -g18000000 -P80 13 |
| 111 | roundTripTest -g18000000 -P80 14 |
| 112 | roundTripTest -g18000000 -P80 15 |
| 113 | roundTripTest -g18000000 -P80 16 |
| 114 | roundTripTest -g18000000 -P80 17 |
| 115 | |
| 116 | roundTripTest -g50000000 -P94 18 |
| 117 | roundTripTest -g50000000 -P94 19 |
| 118 | |
| 119 | roundTripTest -g99000000 -P99 20 |
| 120 | roundTripTest -g6000000000 -P99 q |