2015-12-08 15:11:10 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
die() {
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "$@" 1>&2
|
2015-12-08 15:11:10 +00:00
|
|
|
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
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "roundTripTest: ./datagen $1 $p | $ZSTD -v$c | $ZSTD -d"
|
2016-05-30 08:17:55 +00:00
|
|
|
./datagen $1 $p | $MD5SUM > tmp1
|
2016-07-18 02:06:43 +00:00
|
|
|
./datagen $1 $p | $ZSTD -v$c | $ZSTD -d | $MD5SUM > tmp2
|
2015-12-08 15:36:37 +00:00
|
|
|
diff -q tmp1 tmp2
|
|
|
|
}
|
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
isWindows=false
|
|
|
|
ECHO="echo"
|
2016-06-21 15:06:25 +00:00
|
|
|
INTOVOID="/dev/null"
|
2016-05-27 08:07:46 +00:00
|
|
|
case "$OS" in
|
2016-06-05 22:26:38 +00:00
|
|
|
Windows*)
|
2016-05-25 08:50:28 +00:00
|
|
|
isWindows=true
|
|
|
|
ECHO="echo -e"
|
2016-06-21 15:06:25 +00:00
|
|
|
INTOVOID="nul"
|
2016-05-27 08:07:46 +00:00
|
|
|
;;
|
|
|
|
esac
|
2016-05-25 08:50:28 +00:00
|
|
|
|
2016-05-30 08:17:55 +00:00
|
|
|
MD5SUM="md5sum"
|
2016-05-30 09:33:52 +00:00
|
|
|
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
2016-05-30 08:17:55 +00:00
|
|
|
MD5SUM="md5 -r"
|
2016-05-25 08:50:28 +00:00
|
|
|
fi
|
|
|
|
|
2016-05-30 09:33:52 +00:00
|
|
|
$ECHO "\nStarting playTests.sh isWindows=$isWindows TRAVIS_OS_NAME=$TRAVIS_OS_NAME"
|
2015-12-08 15:36:37 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
[ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
|
2016-02-12 14:56:46 +00:00
|
|
|
|
2016-05-30 09:33:52 +00:00
|
|
|
file $ZSTD
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** simple tests **** "
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2016-02-13 02:12:10 +00:00
|
|
|
./datagen > tmp
|
2016-06-05 22:26:38 +00:00
|
|
|
$ZSTD -f tmp # trivial compression case, creates tmp.zst
|
|
|
|
$ZSTD -df tmp.zst # trivial decompression case (overwrites tmp)
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "test : too large compression level (must fail)"
|
2016-08-12 17:00:18 +00:00
|
|
|
$ZSTD -99 -f tmp # too large compression level, automatic sized down
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "test : compress to stdout"
|
2016-05-29 00:02:24 +00:00
|
|
|
$ZSTD tmp -c > tmpCompressed
|
2016-05-10 03:56:09 +00:00
|
|
|
$ZSTD tmp --stdout > tmpCompressed # long command format
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "test : null-length file roundtrip"
|
|
|
|
$ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
|
|
|
|
$ECHO "test : decompress file with wrong suffix (must fail)"
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
|
2016-06-21 15:06:25 +00:00
|
|
|
$ZSTD -df tmp && die "should have refused : wrong extension"
|
|
|
|
$ECHO "test : decompress into stdout"
|
2016-05-29 00:02:24 +00:00
|
|
|
$ZSTD -d tmpCompressed -c > tmpResult # decompression using stdout
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD --decompress tmpCompressed -c > tmpResult
|
|
|
|
$ZSTD --decompress tmpCompressed --stdout > tmpResult
|
2016-06-21 15:06:25 +00:00
|
|
|
$ECHO "test : decompress from stdin into stdout"
|
|
|
|
$ZSTD -dc < tmp.zst > $INTOVOID # combine decompression, stdin & stdout
|
|
|
|
$ZSTD -dc - < tmp.zst > $INTOVOID
|
|
|
|
$ZSTD -d < tmp.zst > $INTOVOID # implicit stdout when stdin is used
|
|
|
|
$ZSTD -d - < tmp.zst > $INTOVOID
|
|
|
|
$ECHO "test : overwrite protection"
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD -q tmp && die "overwrite check failed!"
|
2016-06-21 15:06:25 +00:00
|
|
|
$ECHO "test : force overwrite"
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD -q -f tmp
|
|
|
|
$ZSTD -q --force tmp
|
2016-06-09 20:59:51 +00:00
|
|
|
$ECHO "test : file removal"
|
|
|
|
$ZSTD -f --rm tmp
|
|
|
|
ls tmp && die "tmp should no longer be present"
|
|
|
|
$ZSTD -f -d --rm tmp.zst
|
|
|
|
ls tmp.zst && die "tmp.zst should no longer be present"
|
|
|
|
rm tmp
|
|
|
|
$ZSTD -f tmp && die "tmp not present : should have failed"
|
|
|
|
ls tmp.zst && die "tmp.zst should not be created"
|
2016-05-23 17:46:47 +00:00
|
|
|
|
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** Pass-Through mode **** "
|
|
|
|
$ECHO "Hello world !" | $ZSTD -df
|
|
|
|
$ECHO "Hello world !" | $ZSTD -dcf
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2016-02-13 02:12:10 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** frame concatenation **** "
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "hello " > hello.tmp
|
|
|
|
$ECHO "world!" > world.tmp
|
2015-12-08 15:11:10 +00:00
|
|
|
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
|
2016-07-28 18:30:25 +00:00
|
|
|
$ECHO "frame concatenation without checksum"
|
|
|
|
$ZSTD -c hello.tmp > hello.zstd --no-check
|
|
|
|
$ZSTD -c world.tmp > world.zstd --no-check
|
|
|
|
cat hello.zstd world.zstd > helloworld.zstd
|
|
|
|
$ZSTD -dc helloworld.zstd > result.tmp
|
|
|
|
cat result.tmp
|
|
|
|
sdiff helloworld.tmp result.tmp
|
2015-12-08 15:36:37 +00:00
|
|
|
rm ./*.tmp ./*.zstd
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "frame concatenation tests completed"
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2016-02-12 14:56:46 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
if [ "$isWindows" = false ] ; then
|
|
|
|
$ECHO "\n**** flush write error test **** "
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "$ECHO foo | $ZSTD > /dev/full"
|
|
|
|
$ECHO foo | $ZSTD > /dev/full && die "write error not detected!"
|
|
|
|
$ECHO "$ECHO foo | $ZSTD | $ZSTD -d > /dev/full"
|
|
|
|
$ECHO foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
|
|
|
|
fi
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2015-12-18 01:51:14 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** test sparse file support **** "
|
2016-05-23 15:48:57 +00:00
|
|
|
|
|
|
|
./datagen -g5M -P100 > tmpSparse
|
|
|
|
$ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
|
|
|
|
diff -s tmpSparse tmpSparseRegen
|
|
|
|
$ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
|
|
|
|
diff -s tmpSparse tmpOutSparse
|
|
|
|
$ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
|
|
|
|
diff -s tmpSparse tmpOutNoSparse
|
|
|
|
ls -ls tmpSparse*
|
|
|
|
./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks)
|
|
|
|
./datagen -s1 -g1200007 -P100 | diff -s - tmpSparseOdd
|
|
|
|
ls -ls tmpSparseOdd
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n Sparse Compatibility with Console :"
|
|
|
|
$ECHO "Hello World 1 !" | $ZSTD | $ZSTD -d -c
|
|
|
|
$ECHO "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
|
|
|
|
$ECHO "\n Sparse Compatibility with Append :"
|
2016-05-23 15:48:57 +00:00
|
|
|
./datagen -P100 -g1M > tmpSparse1M
|
|
|
|
cat tmpSparse1M tmpSparse1M > tmpSparse2M
|
|
|
|
$ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
|
|
|
|
$ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
|
|
|
|
$ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
|
|
|
|
ls -ls tmpSparse*
|
|
|
|
diff tmpSparse2M tmpSparseRegenerated
|
2016-05-29 21:09:51 +00:00
|
|
|
rm tmpSparse*
|
2016-05-23 15:48:57 +00:00
|
|
|
|
|
|
|
|
2016-06-15 21:11:20 +00:00
|
|
|
$ECHO "\n**** multiple files tests **** "
|
|
|
|
|
2016-06-21 15:06:25 +00:00
|
|
|
./datagen -s1 > tmp1 2> $INTOVOID
|
|
|
|
./datagen -s2 -g100K > tmp2 2> $INTOVOID
|
|
|
|
./datagen -s3 -g1M > tmp3 2> $INTOVOID
|
2016-06-15 21:11:20 +00:00
|
|
|
$ECHO "compress tmp* : "
|
2016-07-28 17:55:09 +00:00
|
|
|
$ZSTD -f tmp*
|
2016-06-15 21:11:20 +00:00
|
|
|
ls -ls tmp*
|
|
|
|
rm tmp1 tmp2 tmp3
|
|
|
|
$ECHO "decompress tmp* : "
|
|
|
|
$ZSTD -df *.zst
|
|
|
|
ls -ls tmp*
|
|
|
|
$ECHO "compress tmp* into stdout > tmpall : "
|
|
|
|
$ZSTD -c tmp1 tmp2 tmp3 > tmpall
|
|
|
|
ls -ls tmp*
|
|
|
|
$ECHO "decompress tmpall* into stdout > tmpdec : "
|
|
|
|
cp tmpall tmpall2
|
|
|
|
$ZSTD -dc tmpall* > tmpdec
|
|
|
|
ls -ls tmp*
|
|
|
|
$ECHO "compress multiple files including a missing one (notHere) : "
|
|
|
|
$ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
|
|
|
|
|
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** dictionary tests **** "
|
2015-12-13 12:35:21 +00:00
|
|
|
|
|
|
|
./datagen > tmpDict
|
2016-05-30 08:17:55 +00:00
|
|
|
./datagen -g1M | $MD5SUM > tmp1
|
|
|
|
./datagen -g1M | $ZSTD -D tmpDict | $ZSTD -D tmpDict -dvq | $MD5SUM > tmp2
|
2015-12-13 12:35:21 +00:00
|
|
|
diff -q tmp1 tmp2
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Create first dictionary"
|
2016-05-29 21:09:51 +00:00
|
|
|
$ZSTD --train *.c -o tmpDict
|
2016-05-31 00:29:45 +00:00
|
|
|
cp zstdcli.c tmp
|
|
|
|
$ZSTD -f tmp -D tmpDict
|
|
|
|
$ZSTD -d tmp.zst -D tmpDict -of result
|
2016-05-29 03:01:04 +00:00
|
|
|
diff zstdcli.c result
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Create second (different) dictionary"
|
2016-05-29 21:09:51 +00:00
|
|
|
$ZSTD --train *.c *.h -o tmpDictC
|
2016-05-31 00:29:45 +00:00
|
|
|
$ZSTD -d tmp.zst -D tmpDictC -of result && die "wrong dictionary not detected!"
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Create dictionary with short dictID"
|
2016-05-30 19:18:52 +00:00
|
|
|
$ZSTD --train *.c --dictID 1 -o tmpDict1
|
|
|
|
cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Compress without dictID"
|
2016-05-31 00:29:45 +00:00
|
|
|
$ZSTD -f tmp -D tmpDict1 --no-dictID
|
|
|
|
$ZSTD -d tmp.zst -D tmpDict -of result
|
|
|
|
diff zstdcli.c result
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Compress multiple files with dictionary"
|
|
|
|
rm -rf dirTestDict
|
|
|
|
mkdir dirTestDict
|
|
|
|
cp *.c dirTestDict
|
|
|
|
cp *.h dirTestDict
|
2016-06-15 21:33:38 +00:00
|
|
|
cat dirTestDict/* | $MD5SUM > tmph1 # note : we expect same file order to generate same hash
|
2016-06-15 17:02:11 +00:00
|
|
|
$ZSTD -f dirTestDict/* -D tmpDictC
|
2016-06-15 21:33:38 +00:00
|
|
|
$ZSTD -d dirTestDict/*.zst -D tmpDictC -c | $MD5SUM > tmph2
|
|
|
|
diff -q tmph1 tmph2
|
2016-06-15 17:02:11 +00:00
|
|
|
rm -rf dirTestDict
|
2016-05-31 00:29:45 +00:00
|
|
|
rm tmp*
|
2016-03-26 19:52:14 +00:00
|
|
|
|
2015-12-13 12:35:21 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** integrity tests **** "
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "test one file (tmp1.zst) "
|
2016-06-15 21:33:38 +00:00
|
|
|
./datagen > tmp1
|
|
|
|
$ZSTD tmp1
|
2016-02-15 19:37:23 +00:00
|
|
|
$ZSTD -t tmp1.zst
|
2016-02-16 13:42:08 +00:00
|
|
|
$ZSTD --test tmp1.zst
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "test multiple files (*.zst) "
|
2016-02-15 19:37:23 +00:00
|
|
|
$ZSTD -t *.zst
|
2016-07-25 23:26:56 +00:00
|
|
|
$ECHO "test bad files (*) "
|
2016-02-15 19:37:23 +00:00
|
|
|
$ZSTD -t * && die "bad files not detected !"
|
2016-07-25 23:26:56 +00:00
|
|
|
$ZSTD -t tmp1 && die "bad file not detected !"
|
|
|
|
cp tmp1 tmp2.zst
|
|
|
|
$ZSTD -t tmp2.zst && die "bad file not detected !"
|
2016-07-26 13:39:31 +00:00
|
|
|
./datagen -g0 > tmp3
|
|
|
|
$ZSTD -t tmp3 && die "bad file not detected !" # detects 0-sized files as bad
|
2016-07-25 22:49:47 +00:00
|
|
|
$ECHO "test --rm and --test combined "
|
|
|
|
$ZSTD -t --rm tmp1.zst
|
|
|
|
ls -ls tmp1.zst # check file is still present
|
2015-12-17 19:30:14 +00:00
|
|
|
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "\n**** zstd round-trip tests **** "
|
2015-12-08 15:36:37 +00:00
|
|
|
|
|
|
|
roundTripTest
|
2016-03-30 17:48:05 +00:00
|
|
|
roundTripTest -g15K # TableID==3
|
|
|
|
roundTripTest -g127K # TableID==2
|
|
|
|
roundTripTest -g255K # TableID==1
|
|
|
|
roundTripTest -g513K # TableID==0
|
2016-02-15 19:37:23 +00:00
|
|
|
roundTripTest -g512K 6 # greedy, hash chain
|
2016-05-29 00:02:24 +00:00
|
|
|
roundTripTest -g512K 16 # btlazy2
|
2016-02-15 19:37:23 +00:00
|
|
|
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
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "Skipping large data tests"
|
2015-12-08 15:47:43 +00:00
|
|
|
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
|
2016-03-20 15:20:06 +00:00
|
|
|
roundTripTest -g6000000000 -P99 1
|
2016-02-15 19:37:23 +00:00
|
|
|
|
|
|
|
rm tmp*
|