blob: 069acc134fc2dfd004080fc7f0a18137e7fdc76e [file] [log] [blame]
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +03001#!/bin/sh -e
2
3die() {
4 echo "$@" 1>&2
5 exit 1
6}
7
Konstantin Tokarev76be3782015-12-08 18:36:37 +03008roundTripTest() {
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 Colletef370632016-02-07 03:53:12 +010019 ./datagen $1 $p | $ZSTD -vq$c | $ZSTD -d | md5sum > tmp2
Konstantin Tokarev76be3782015-12-08 18:36:37 +030020 diff -q tmp1 tmp2
21}
22
23[ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
24
Yann Colletf0624362016-02-12 15:56:46 +010025
Yann Collet8154c3d2016-02-13 03:12:10 +010026echo "\n**** simple test **** "
27./datagen > tmp
28$ZSTD tmp
29
Yann Colletf0624362016-02-12 15:56:46 +010030echo "\n**** frame concatenation **** "
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030031
32echo "hello " > hello.tmp
33echo "world!" > world.tmp
34cat hello.tmp world.tmp > helloworld.tmp
Yann Colletc8da2c92016-02-12 02:56:27 +010035$ZSTD -c hello.tmp > hello.zstd
36$ZSTD -c world.tmp > world.zstd
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030037cat hello.zstd world.zstd > helloworld.zstd
Yann Colletc8da2c92016-02-12 02:56:27 +010038$ZSTD -dc helloworld.zstd > result.tmp
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030039cat result.tmp
40sdiff helloworld.tmp result.tmp
Konstantin Tokarev76be3782015-12-08 18:36:37 +030041rm ./*.tmp ./*.zstd
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030042
43echo frame concatenation test completed
44
Yann Colletf0624362016-02-12 15:56:46 +010045
46echo "\n**** flush write error test **** "
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030047
Yann Collet6a458352015-12-18 02:51:14 +010048echo "echo foo | $ZSTD > /dev/full"
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030049echo foo | $ZSTD > /dev/full && die "write error not detected!"
Yann Collet6a458352015-12-18 02:51:14 +010050echo "echo foo | $ZSTD | $ZSTD -d > /dev/full"
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +030051echo foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
52
Yann Collet6a458352015-12-18 02:51:14 +010053
Yann Colletf0624362016-02-12 15:56:46 +010054echo "\n**** dictionary tests **** "
Yann Colletf6f3d752015-12-13 13:35:21 +010055
56./datagen > tmpDict
57./datagen -g1M | md5sum > tmp1
Yann Colletf0624362016-02-12 15:56:46 +010058./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | md5sum > tmp2
Yann Colletf6f3d752015-12-13 13:35:21 +010059diff -q tmp1 tmp2
60
Yann Colletf0624362016-02-12 15:56:46 +010061echo "\n**** multiple files tests **** "
Yann Colletdeb078b2015-12-17 20:30:14 +010062
63./datagen -s1 > tmp1 2> /dev/null
64./datagen -s2 -g100K > tmp2 2> /dev/null
65./datagen -s3 -g1M > tmp3 2> /dev/null
Yann Colletc8da2c92016-02-12 02:56:27 +010066$ZSTD -f tmp*
Yann Colletf0624362016-02-12 15:56:46 +010067echo "compress tmp* : "
Yann Colletdeb078b2015-12-17 20:30:14 +010068ls -ls tmp*
69rm tmp1 tmp2 tmp3
Yann Colletf0624362016-02-12 15:56:46 +010070echo "decompress tmp* : "
Yann Colletc8da2c92016-02-12 02:56:27 +010071$ZSTD -df *.zst
Yann Colletdeb078b2015-12-17 20:30:14 +010072ls -ls tmp*
Yann Collet1f1f2392016-02-12 18:33:26 +010073echo "compress tmp* into stdout > tmpall : "
Yann Colletf0624362016-02-12 15:56:46 +010074$ZSTD -c tmp1 tmp2 tmp3 > tmpall
75ls -ls tmp*
Yann Collet1f1f2392016-02-12 18:33:26 +010076echo "decompress tmpall* into stdout > tmpdec : "
77cp tmpall tmpall2
78$ZSTD -dc tmpall* > tmpdec
79ls -ls tmp*
Yann Colletc8da2c92016-02-12 02:56:27 +010080$ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
Yann Colletdeb078b2015-12-17 20:30:14 +010081rm tmp*
82
Yann Colletf0624362016-02-12 15:56:46 +010083echo "\n**** zstd round-trip tests **** "
Konstantin Tokarev76be3782015-12-08 18:36:37 +030084
85roundTripTest
86roundTripTest '' 6
Yann Colletee602ce2016-02-08 18:46:26 +010087roundTripTest '' 16
Konstantin Tokarev76be3782015-12-08 18:36:37 +030088
Konstantin Tokarev0b570b52015-12-08 18:47:43 +030089if [ "$1" != "--test-large-data" ]; then
90 echo "Skipping large data tests"
91 exit 0
92fi
93
Konstantin Tokarev76be3782015-12-08 18:36:37 +030094roundTripTest -g270000000 1
95roundTripTest -g270000000 2
96roundTripTest -g270000000 3
97
98roundTripTest -g140000000 -P60 4
99roundTripTest -g140000000 -P60 5
100roundTripTest -g140000000 -P60 6
101
102roundTripTest -g70000000 -P70 7
103roundTripTest -g70000000 -P70 8
104roundTripTest -g70000000 -P70 9
105
106roundTripTest -g35000000 -P75 10
107roundTripTest -g35000000 -P75 11
108roundTripTest -g35000000 -P75 12
Konstantin Tokarevd66db2f2015-12-08 18:11:10 +0300109
Konstantin Tokarev2b465842015-12-08 19:36:42 +0300110roundTripTest -g18000000 -P80 13
111roundTripTest -g18000000 -P80 14
112roundTripTest -g18000000 -P80 15
113roundTripTest -g18000000 -P80 16
114roundTripTest -g18000000 -P80 17
115
116roundTripTest -g50000000 -P94 18
117roundTripTest -g50000000 -P94 19
118
119roundTripTest -g99000000 -P99 20
120roundTripTest -g6000000000 -P99 q