2015-12-08 15:11:10 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo "$@" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2015-12-08 15:36:37 +00:00
|
|
|
roundTripTest() {
|
|
|
|
if [ -n "$3" ]; then
|
|
|
|
local c="$3"
|
|
|
|
local p="$2"
|
|
|
|
else
|
|
|
|
local c="$2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f tmp1 tmp2
|
|
|
|
echo "roundTripTest: ./datagen $1 $p | $ZSTD -v$c | $ZSTD -d"
|
|
|
|
./datagen $1 $p | md5sum > tmp1
|
2016-02-07 02:53:12 +00:00
|
|
|
./datagen $1 $p | $ZSTD -vq$c | $ZSTD -d | md5sum > tmp2
|
2015-12-08 15:36:37 +00:00
|
|
|
diff -q tmp1 tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
|
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
|
2016-02-16 13:42:08 +00:00
|
|
|
echo "\n**** simple tests **** "
|
2016-02-13 02:12:10 +00:00
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD tmp
|
2016-02-16 15:35:28 +00:00
|
|
|
$ZSTD -99 tmp && die "too large compression level undetected"
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD tmp -c > tmpCompressed
|
|
|
|
$ZSTD tmp --stdout > tmpCompressed
|
|
|
|
$ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
|
|
|
|
$ZSTD -d tmpCompressed -c > tmpResult
|
|
|
|
$ZSTD --decompress tmpCompressed -c > tmpResult
|
|
|
|
$ZSTD --decompress tmpCompressed --stdout > tmpResult
|
|
|
|
$ZSTD -q tmp && die "overwrite check failed!"
|
|
|
|
$ZSTD -q -f tmp
|
|
|
|
$ZSTD -q --force tmp
|
|
|
|
|
2016-02-13 02:12:10 +00:00
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
echo "\n**** frame concatenation **** "
|
2015-12-08 15:11:10 +00:00
|
|
|
|
|
|
|
echo "hello " > hello.tmp
|
|
|
|
echo "world!" > world.tmp
|
|
|
|
cat hello.tmp world.tmp > helloworld.tmp
|
2016-02-12 01:56:27 +00:00
|
|
|
$ZSTD -c hello.tmp > hello.zstd
|
|
|
|
$ZSTD -c world.tmp > world.zstd
|
2015-12-08 15:11:10 +00:00
|
|
|
cat hello.zstd world.zstd > helloworld.zstd
|
2016-02-12 01:56:27 +00:00
|
|
|
$ZSTD -dc helloworld.zstd > result.tmp
|
2015-12-08 15:11:10 +00:00
|
|
|
cat result.tmp
|
|
|
|
sdiff helloworld.tmp result.tmp
|
2015-12-08 15:36:37 +00:00
|
|
|
rm ./*.tmp ./*.zstd
|
2015-12-08 15:11:10 +00:00
|
|
|
|
|
|
|
echo frame concatenation test completed
|
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
|
|
|
|
echo "\n**** flush write error test **** "
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2015-12-18 01:51:14 +00:00
|
|
|
echo "echo foo | $ZSTD > /dev/full"
|
2015-12-08 15:11:10 +00:00
|
|
|
echo foo | $ZSTD > /dev/full && die "write error not detected!"
|
2015-12-18 01:51:14 +00:00
|
|
|
echo "echo foo | $ZSTD | $ZSTD -d > /dev/full"
|
2015-12-08 15:11:10 +00:00
|
|
|
echo foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
|
|
|
|
|
2015-12-18 01:51:14 +00:00
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
echo "\n**** dictionary tests **** "
|
2015-12-13 12:35:21 +00:00
|
|
|
|
|
|
|
./datagen > tmpDict
|
|
|
|
./datagen -g1M | md5sum > tmp1
|
2016-02-12 14:56:46 +00:00
|
|
|
./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | md5sum > tmp2
|
2015-12-13 12:35:21 +00:00
|
|
|
diff -q tmp1 tmp2
|
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
echo "\n**** multiple files tests **** "
|
2015-12-17 19:30:14 +00:00
|
|
|
|
|
|
|
./datagen -s1 > tmp1 2> /dev/null
|
|
|
|
./datagen -s2 -g100K > tmp2 2> /dev/null
|
|
|
|
./datagen -s3 -g1M > tmp3 2> /dev/null
|
2016-02-12 01:56:27 +00:00
|
|
|
$ZSTD -f tmp*
|
2016-02-12 14:56:46 +00:00
|
|
|
echo "compress tmp* : "
|
2015-12-17 19:30:14 +00:00
|
|
|
ls -ls tmp*
|
|
|
|
rm tmp1 tmp2 tmp3
|
2016-02-12 14:56:46 +00:00
|
|
|
echo "decompress tmp* : "
|
2016-02-12 01:56:27 +00:00
|
|
|
$ZSTD -df *.zst
|
2015-12-17 19:30:14 +00:00
|
|
|
ls -ls tmp*
|
2016-02-12 17:33:26 +00:00
|
|
|
echo "compress tmp* into stdout > tmpall : "
|
2016-02-12 14:56:46 +00:00
|
|
|
$ZSTD -c tmp1 tmp2 tmp3 > tmpall
|
|
|
|
ls -ls tmp*
|
2016-02-12 17:33:26 +00:00
|
|
|
echo "decompress tmpall* into stdout > tmpdec : "
|
|
|
|
cp tmpall tmpall2
|
|
|
|
$ZSTD -dc tmpall* > tmpdec
|
|
|
|
ls -ls tmp*
|
2016-02-15 19:37:23 +00:00
|
|
|
echo "compress multiple files including a missing one (notHere) : "
|
2016-02-12 01:56:27 +00:00
|
|
|
$ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
|
2016-02-15 19:37:23 +00:00
|
|
|
|
|
|
|
echo "\n**** integrity tests **** "
|
|
|
|
echo "test one file (tmp1.zst) "
|
|
|
|
$ZSTD -t tmp1.zst
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD --test tmp1.zst
|
2016-02-15 19:37:23 +00:00
|
|
|
echo "test multiple files (*.zst) "
|
|
|
|
$ZSTD -t *.zst
|
|
|
|
echo "test good and bad files (*) "
|
|
|
|
$ZSTD -t * && die "bad files not detected !"
|
2015-12-17 19:30:14 +00:00
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
echo "\n**** zstd round-trip tests **** "
|
2015-12-08 15:36:37 +00:00
|
|
|
|
|
|
|
roundTripTest
|
2016-02-15 19:37:23 +00:00
|
|
|
roundTripTest -g512K 6 # greedy, hash chain
|
|
|
|
roundTripTest -g512K 16 # btlazy2
|
|
|
|
roundTripTest -g512K 19 # btopt
|
|
|
|
|
|
|
|
rm tmp*
|
2015-12-08 15:36:37 +00:00
|
|
|
|
2015-12-08 15:47:43 +00:00
|
|
|
if [ "$1" != "--test-large-data" ]; then
|
|
|
|
echo "Skipping large data tests"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-12-08 15:36:37 +00:00
|
|
|
roundTripTest -g270000000 1
|
|
|
|
roundTripTest -g270000000 2
|
|
|
|
roundTripTest -g270000000 3
|
|
|
|
|
|
|
|
roundTripTest -g140000000 -P60 4
|
|
|
|
roundTripTest -g140000000 -P60 5
|
|
|
|
roundTripTest -g140000000 -P60 6
|
|
|
|
|
|
|
|
roundTripTest -g70000000 -P70 7
|
|
|
|
roundTripTest -g70000000 -P70 8
|
|
|
|
roundTripTest -g70000000 -P70 9
|
|
|
|
|
|
|
|
roundTripTest -g35000000 -P75 10
|
|
|
|
roundTripTest -g35000000 -P75 11
|
|
|
|
roundTripTest -g35000000 -P75 12
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2015-12-08 16:36:42 +00:00
|
|
|
roundTripTest -g18000000 -P80 13
|
|
|
|
roundTripTest -g18000000 -P80 14
|
|
|
|
roundTripTest -g18000000 -P80 15
|
|
|
|
roundTripTest -g18000000 -P80 16
|
|
|
|
roundTripTest -g18000000 -P80 17
|
|
|
|
|
|
|
|
roundTripTest -g50000000 -P94 18
|
|
|
|
roundTripTest -g50000000 -P94 19
|
|
|
|
|
|
|
|
roundTripTest -g99000000 -P99 20
|
|
|
|
roundTripTest -g6000000000 -P99 q
|
2016-02-15 19:37:23 +00:00
|
|
|
|
|
|
|
rm tmp*
|
|
|
|
|