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
|
2017-07-11 00:16:41 +00:00
|
|
|
cLevel="$3"
|
|
|
|
proba="$2"
|
2015-12-08 15:36:37 +00:00
|
|
|
else
|
2017-07-11 00:16:41 +00:00
|
|
|
cLevel="$2"
|
|
|
|
proba=""
|
2015-12-08 15:36:37 +00:00
|
|
|
fi
|
2017-09-22 21:04:39 +00:00
|
|
|
if [ -n "$4" ]; then
|
|
|
|
dLevel="$4"
|
|
|
|
else
|
|
|
|
dLevel="$cLevel"
|
|
|
|
fi
|
2015-12-08 15:36:37 +00:00
|
|
|
|
|
|
|
rm -f tmp1 tmp2
|
2017-09-22 21:04:39 +00:00
|
|
|
$ECHO "roundTripTest: ./datagen $1 $proba | $ZSTD -v$cLevel | $ZSTD -d$dLevel"
|
2017-07-11 00:16:41 +00:00
|
|
|
./datagen $1 $proba | $MD5SUM > tmp1
|
2017-09-22 21:04:39 +00:00
|
|
|
./datagen $1 $proba | $ZSTD --ultra -v$cLevel | $ZSTD -d$dLevel | $MD5SUM > tmp2
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF -q tmp1 tmp2
|
2015-12-08 15:36:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-12 00:15:13 +00:00
|
|
|
fileRoundTripTest() {
|
|
|
|
if [ -n "$3" ]; then
|
|
|
|
local_c="$3"
|
|
|
|
local_p="$2"
|
|
|
|
else
|
|
|
|
local_c="$2"
|
|
|
|
local_p=""
|
|
|
|
fi
|
2017-09-22 21:04:39 +00:00
|
|
|
if [ -n "$4" ]; then
|
|
|
|
local_d="$4"
|
|
|
|
else
|
|
|
|
local_d="$local_c"
|
|
|
|
fi
|
2017-04-12 00:15:13 +00:00
|
|
|
|
|
|
|
rm -f tmp.zstd tmp.md5.1 tmp.md5.2
|
2017-09-22 21:04:39 +00:00
|
|
|
$ECHO "fileRoundTripTest: ./datagen $1 $local_p > tmp && $ZSTD -v$local_c -c tmp | $ZSTD -d$local_d"
|
2017-04-12 00:15:13 +00:00
|
|
|
./datagen $1 $local_p > tmp
|
2017-10-06 03:21:59 +00:00
|
|
|
< tmp $MD5SUM > tmp.md5.1
|
2017-09-22 21:04:39 +00:00
|
|
|
$ZSTD --ultra -v$local_c -c tmp | $ZSTD -d$local_d | $MD5SUM > tmp.md5.2
|
2017-04-12 00:15:13 +00:00
|
|
|
$DIFF -q tmp.md5.1 tmp.md5.2
|
|
|
|
}
|
|
|
|
|
2017-03-17 19:32:18 +00:00
|
|
|
isTerminal=false
|
|
|
|
if [ -t 0 ] && [ -t 1 ]
|
|
|
|
then
|
|
|
|
isTerminal=true
|
|
|
|
fi
|
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
isWindows=false
|
2016-06-21 15:06:25 +00:00
|
|
|
INTOVOID="/dev/null"
|
2017-12-13 20:04:46 +00:00
|
|
|
DEVDEVICE="/dev/zero"
|
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
|
2017-03-17 19:32:18 +00:00
|
|
|
INTOVOID="NUL"
|
2017-12-13 20:04:46 +00:00
|
|
|
DEVDEVICE="NUL"
|
2016-05-27 08:07:46 +00:00
|
|
|
;;
|
|
|
|
esac
|
2016-05-25 08:50:28 +00:00
|
|
|
|
2016-12-12 18:22:47 +00:00
|
|
|
UNAME=$(uname)
|
|
|
|
case "$UNAME" in
|
|
|
|
Darwin) MD5SUM="md5 -r" ;;
|
|
|
|
FreeBSD) MD5SUM="gmd5sum" ;;
|
2016-12-06 20:02:56 +00:00
|
|
|
*) MD5SUM="md5sum" ;;
|
|
|
|
esac
|
2016-05-25 08:50:28 +00:00
|
|
|
|
2016-12-22 17:05:07 +00:00
|
|
|
DIFF="diff"
|
|
|
|
case "$UNAME" in
|
|
|
|
SunOS) DIFF="gdiff" ;;
|
|
|
|
esac
|
|
|
|
|
2017-09-25 21:26:26 +00:00
|
|
|
ECHO="echo -e"
|
|
|
|
case "$UNAME" in
|
|
|
|
Darwin) ECHO="echo" ;;
|
|
|
|
esac
|
|
|
|
|
2016-11-14 11:57:05 +00:00
|
|
|
$ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
|
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
|
|
|
|
2017-04-17 18:38:53 +00:00
|
|
|
if [ -n "$(echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep 'multi-threading is disabled')" ]
|
|
|
|
then
|
|
|
|
hasMT=""
|
|
|
|
else
|
|
|
|
hasMT="true"
|
|
|
|
fi
|
|
|
|
|
2018-01-06 11:31:26 +00:00
|
|
|
|
2017-10-16 21:01:42 +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-09-09 14:44:16 +00:00
|
|
|
$ECHO "test : basic compression "
|
2016-06-05 22:26:38 +00:00
|
|
|
$ZSTD -f tmp # trivial compression case, creates tmp.zst
|
2016-09-09 14:44:16 +00:00
|
|
|
$ECHO "test : basic decompression"
|
2016-06-05 22:26:38 +00:00
|
|
|
$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-09-21 12:20:56 +00:00
|
|
|
$ECHO "test : compress to named file"
|
|
|
|
rm tmpCompressed
|
|
|
|
$ZSTD tmp -o tmpCompressed
|
2017-05-06 02:15:24 +00:00
|
|
|
test -f tmpCompressed # file must be created
|
2016-09-21 12:20:56 +00:00
|
|
|
$ECHO "test : -o must be followed by filename (must fail)"
|
2016-09-21 14:05:03 +00:00
|
|
|
$ZSTD tmp -of tmpCompressed && die "-o must be followed by filename "
|
2016-09-21 12:20:56 +00:00
|
|
|
$ECHO "test : force write, correct order"
|
|
|
|
$ZSTD tmp -fo tmpCompressed
|
2016-09-21 14:05:03 +00:00
|
|
|
$ECHO "test : forgotten argument"
|
|
|
|
cp tmp tmp2
|
|
|
|
$ZSTD tmp2 -fo && die "-o must be followed by filename "
|
2016-09-01 22:05:57 +00:00
|
|
|
$ECHO "test : implied stdout when input is stdin"
|
|
|
|
$ECHO bob | $ZSTD | $ZSTD -d
|
2017-03-17 19:32:18 +00:00
|
|
|
if [ "$isTerminal" = true ]; then
|
2017-03-16 23:25:19 +00:00
|
|
|
$ECHO "test : compressed data to terminal"
|
|
|
|
$ECHO bob | $ZSTD && die "should have refused : compressed data to terminal"
|
|
|
|
$ECHO "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)"
|
|
|
|
$ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal"
|
2017-03-17 19:32:18 +00:00
|
|
|
fi
|
2016-05-25 08:50:28 +00:00
|
|
|
$ECHO "test : null-length file roundtrip"
|
|
|
|
$ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
|
saves 3-bytes on small input with streaming API
zstd streaming API was adding a null-block at end of frame for small input.
Reason is : on small input, a single block is enough.
ZSTD_CStream would size its input buffer to expect a single block of this size,
automatically triggering a flush on reaching this size.
Unfortunately, that last byte was generally received before the "end" directive (at least in `fileio`).
The later "end" directive would force the creation of a 3-bytes last block to indicate end of frame.
The solution is to not flush automatically, which is btw the expected behavior.
It happens in this case because blocksize is defined with exactly the same size as input.
Just adding one-byte is enough to stop triggering the automatic flush.
I initially looked at another solution, solving the problem directly in the compression context.
But it felt awkward.
Now, the underlying compression API `ZSTD_compressContinue()` would take the decision the close a frame
on reaching its expected end (`pledgedSrcSize`).
This feels awkward, a responsability over-reach, beyond the definition of this API.
ZSTD_compressContinue() is clearly documented as a guaranteed flush,
with ZSTD_compressEnd() generating a guaranteed end.
I faced similar issue when trying to port a similar mechanism at the higher streaming layer.
Having ZSTD_CStream end a frame automatically on reaching `pledgedSrcSize` can surprise the caller,
since it did not explicitly requested an end of frame.
The only sensible action remaining after that is to end the frame with no additional input.
This adds additional logic in the ZSTD_CStream state to check this condition.
Plus some potential confusion on the meaning of ZSTD_endStream() with no additional input (ending confirmation ? new 0-size frame ?)
In the end, just enlarging input buffer by 1 byte feels the least intrusive change.
It's also a contract remaining inside the streaming layer, so the logic is contained in this part of the code.
The patch also introduces a new test checking that size of small frame is as expected, without additional 3-bytes null block.
2017-12-14 19:47:02 +00:00
|
|
|
$ECHO "test : ensure small file doesn't add 3-bytes null block"
|
2017-12-14 21:32:24 +00:00
|
|
|
./datagen -g1 > tmp1
|
|
|
|
$ZSTD tmp1 -c | wc -c | grep "14"
|
|
|
|
$ZSTD < tmp1 | wc -c | grep "14"
|
2016-05-25 08:50:28 +00:00
|
|
|
$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
|
2016-10-14 20:13:13 +00:00
|
|
|
$ECHO "test : impose memory limitation (must fail)"
|
|
|
|
$ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
|
2016-10-14 21:07:11 +00:00
|
|
|
$ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
|
2016-10-14 21:22:32 +00:00
|
|
|
$ZSTD -d -f tmp.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
|
|
|
|
$ZSTD -d -f tmp.zst --memlimit-decompress=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
|
2016-06-21 15:06:25 +00:00
|
|
|
$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
|
2017-04-06 19:58:49 +00:00
|
|
|
$ECHO "test : overwrite readonly file"
|
2017-04-07 00:06:30 +00:00
|
|
|
rm -f tmpro tmpro.zst
|
2017-04-06 19:58:49 +00:00
|
|
|
$ECHO foo > tmpro.zst
|
|
|
|
$ECHO foo > tmpro
|
|
|
|
chmod 400 tmpro.zst
|
2017-04-07 00:06:30 +00:00
|
|
|
$ZSTD -q tmpro && die "should have refused to overwrite read-only file"
|
|
|
|
$ZSTD -q -f tmpro
|
|
|
|
rm -f tmpro tmpro.zst
|
2016-06-09 20:59:51 +00:00
|
|
|
$ECHO "test : file removal"
|
|
|
|
$ZSTD -f --rm tmp
|
2017-05-06 02:15:24 +00:00
|
|
|
test ! -f tmp # tmp should no longer be present
|
2016-06-09 20:59:51 +00:00
|
|
|
$ZSTD -f -d --rm tmp.zst
|
2017-05-06 02:15:24 +00:00
|
|
|
test ! -f tmp.zst # tmp.zst should no longer be present
|
2017-12-13 20:04:46 +00:00
|
|
|
$ECHO "test : should quietly not remove non-regular file"
|
|
|
|
$ECHO hello > tmp
|
|
|
|
$ZSTD tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID"
|
|
|
|
grep -v "Refusing to remove non-regular file" tmplog
|
|
|
|
rm -f tmplog
|
|
|
|
$ZSTD tmp -f -o "$INTONULL" 2>&1 | grep -v "Refusing to remove non-regular file"
|
2017-02-28 00:09:20 +00:00
|
|
|
$ECHO "test : --rm on stdin"
|
|
|
|
$ECHO a | $ZSTD --rm > $INTOVOID # --rm should remain silent
|
2016-06-09 20:59:51 +00:00
|
|
|
rm tmp
|
|
|
|
$ZSTD -f tmp && die "tmp not present : should have failed"
|
2017-05-06 02:15:24 +00:00
|
|
|
test ! -f tmp.zst # tmp.zst should not be created
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2017-12-13 02:32:50 +00:00
|
|
|
$ECHO "test : compress multiple files"
|
|
|
|
$ECHO hello > tmp1
|
|
|
|
$ECHO world > tmp2
|
|
|
|
$ZSTD tmp1 tmp2 -o "$INTOVOID"
|
|
|
|
$ZSTD tmp1 tmp2 -c | $ZSTD -t
|
|
|
|
$ZSTD tmp1 tmp2 -o tmp.zst
|
|
|
|
test ! -f tmp1.zst
|
|
|
|
test ! -f tmp2.zst
|
|
|
|
$ZSTD tmp1 tmp2
|
|
|
|
$ZSTD -t tmp1.zst tmp2.zst
|
|
|
|
$ZSTD -dc tmp1.zst tmp2.zst
|
|
|
|
$ZSTD tmp1.zst tmp2.zst -o "$INTOVOID"
|
|
|
|
$ZSTD -d tmp1.zst tmp2.zst -o tmp
|
2018-01-03 22:02:44 +00:00
|
|
|
touch tmpexists
|
|
|
|
$ZSTD tmp1 tmp2 -f -o tmpexists
|
|
|
|
$ZSTD tmp1 tmp2 -o tmpexists && die "should have refused to overwrite"
|
|
|
|
# Bug: PR #972
|
|
|
|
if [ "$?" -eq 139 ]; then
|
|
|
|
die "should not have segfaulted"
|
|
|
|
fi
|
2017-12-13 02:32:50 +00:00
|
|
|
rm tmp*
|
|
|
|
|
|
|
|
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> Advanced compression parameters "
|
2016-12-14 17:07:31 +00:00
|
|
|
$ECHO "Hello world!" | $ZSTD --zstd=windowLog=21, - -o tmp.zst && die "wrong parameters not detected!"
|
|
|
|
$ECHO "Hello world!" | $ZSTD --zstd=windowLo=21 - -o tmp.zst && die "wrong parameters not detected!"
|
2016-12-14 17:43:06 +00:00
|
|
|
$ECHO "Hello world!" | $ZSTD --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!"
|
2017-05-06 02:15:24 +00:00
|
|
|
test ! -f tmp.zst # tmp.zst should not be created
|
2016-12-14 15:50:00 +00:00
|
|
|
roundTripTest -g512K
|
2016-12-14 16:10:38 +00:00
|
|
|
roundTripTest -g512K " --zstd=slen=3,tlen=48,strat=6"
|
|
|
|
roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
|
2016-12-14 15:50:00 +00:00
|
|
|
roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6"
|
2017-09-18 21:36:17 +00:00
|
|
|
roundTripTest -g512K " --long --zstd=ldmHashLog=20,ldmSearchLength=64,ldmBucketSizeLog=1,ldmHashEveryLog=7"
|
|
|
|
roundTripTest -g512K " --long --zstd=ldmhlog=20,ldmslen=64,ldmblog=1,ldmhevery=7"
|
2016-12-14 15:50:00 +00:00
|
|
|
roundTripTest -g512K 19
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> Pass-Through mode "
|
2016-12-02 23:18:57 +00:00
|
|
|
$ECHO "Hello world 1!" | $ZSTD -df
|
|
|
|
$ECHO "Hello world 2!" | $ZSTD -dcf
|
|
|
|
$ECHO "Hello world 3!" > tmp1
|
|
|
|
$ZSTD -dcf tmp1
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2016-02-13 02:12:10 +00:00
|
|
|
|
2017-10-16 21:01:42 +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
|
2017-01-22 23:54:14 +00:00
|
|
|
$DIFF 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
|
2017-01-22 23:54:14 +00:00
|
|
|
$DIFF 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-12-22 17:05:07 +00:00
|
|
|
if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
|
2016-05-25 08:50:28 +00:00
|
|
|
$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!"
|
2017-03-23 18:52:09 +00:00
|
|
|
|
2017-05-06 02:15:24 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> symbolic link test "
|
2017-03-23 18:52:09 +00:00
|
|
|
|
|
|
|
rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
|
|
|
|
$ECHO "hello world" > hello.tmp
|
|
|
|
ln -s hello.tmp world.tmp
|
|
|
|
$ZSTD world.tmp hello.tmp
|
2017-05-06 02:15:24 +00:00
|
|
|
test -f hello.tmp.zst # regular file should have been compressed!
|
|
|
|
test ! -f world.tmp.zst # symbolic link should not have been compressed!
|
2017-03-23 18:52:09 +00:00
|
|
|
$ZSTD world.tmp hello.tmp -f
|
2017-05-06 02:15:24 +00:00
|
|
|
test -f world.tmp.zst # symbolic link should have been compressed with --force
|
2017-03-23 18:52:09 +00:00
|
|
|
rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
|
|
|
|
|
2016-05-25 08:50:28 +00:00
|
|
|
fi
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2015-12-18 01:51:14 +00:00
|
|
|
|
2017-10-16 21:01:42 +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
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF -s tmpSparse tmpSparseRegen
|
2016-05-23 15:48:57 +00:00
|
|
|
$ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF -s tmpSparse tmpOutSparse
|
2016-05-23 15:48:57 +00:00
|
|
|
$ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF -s tmpSparse tmpOutNoSparse
|
2017-05-06 02:15:24 +00:00
|
|
|
ls -ls tmpSparse* # look at file size and block size on disk
|
2016-05-23 15:48:57 +00:00
|
|
|
./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks)
|
2016-12-22 17:05:07 +00:00
|
|
|
./datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
|
2017-05-06 02:15:24 +00:00
|
|
|
ls -ls tmpSparseOdd # look at file size and block size on disk
|
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
|
2017-05-06 02:15:24 +00:00
|
|
|
ls -ls tmpSparse* # look at file size and block size on disk
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF tmpSparse2M tmpSparseRegenerated
|
2016-05-29 21:09:51 +00:00
|
|
|
rm tmpSparse*
|
2016-05-23 15:48:57 +00:00
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> multiple files tests "
|
2016-06-15 21:11:20 +00:00
|
|
|
|
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
|
2017-05-06 02:15:24 +00:00
|
|
|
ls -ls tmp* # check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
|
2016-06-15 21:11:20 +00:00
|
|
|
$ECHO "decompress tmpall* into stdout > tmpdec : "
|
|
|
|
cp tmpall tmpall2
|
|
|
|
$ZSTD -dc tmpall* > tmpdec
|
2017-05-06 02:15:24 +00:00
|
|
|
ls -ls tmp* # check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3))
|
2016-06-15 21:11:20 +00:00
|
|
|
$ECHO "compress multiple files including a missing one (notHere) : "
|
|
|
|
$ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!"
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> dictionary tests "
|
2015-12-13 12:35:21 +00:00
|
|
|
|
2017-02-26 22:43:07 +00:00
|
|
|
$ECHO "- test with raw dict (content only) "
|
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
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF -q tmp1 tmp2
|
2017-02-26 22:43:07 +00:00
|
|
|
$ECHO "- Create first dictionary "
|
|
|
|
TESTFILE=../programs/zstdcli.c
|
2016-08-18 13:13:41 +00:00
|
|
|
$ZSTD --train *.c ../programs/*.c -o tmpDict
|
|
|
|
cp $TESTFILE tmp
|
2017-12-29 18:14:18 +00:00
|
|
|
$ECHO "- Dictionary compression roundtrip"
|
2016-05-31 00:29:45 +00:00
|
|
|
$ZSTD -f tmp -D tmpDict
|
2016-09-21 12:20:56 +00:00
|
|
|
$ZSTD -d tmp.zst -D tmpDict -fo result
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF $TESTFILE result
|
2017-12-29 18:14:18 +00:00
|
|
|
$ECHO "- Dictionary compression with btlazy2 strategy"
|
|
|
|
$ZSTD -f tmp -D tmpDict --zstd=strategy=6
|
|
|
|
$ZSTD -d tmp.zst -D tmpDict -fo result
|
|
|
|
$DIFF $TESTFILE result
|
2017-12-13 19:48:30 +00:00
|
|
|
if [ -n "$hasMT" ]
|
|
|
|
then
|
|
|
|
$ECHO "- Test dictionary compression with multithreading "
|
saves 3-bytes on small input with streaming API
zstd streaming API was adding a null-block at end of frame for small input.
Reason is : on small input, a single block is enough.
ZSTD_CStream would size its input buffer to expect a single block of this size,
automatically triggering a flush on reaching this size.
Unfortunately, that last byte was generally received before the "end" directive (at least in `fileio`).
The later "end" directive would force the creation of a 3-bytes last block to indicate end of frame.
The solution is to not flush automatically, which is btw the expected behavior.
It happens in this case because blocksize is defined with exactly the same size as input.
Just adding one-byte is enough to stop triggering the automatic flush.
I initially looked at another solution, solving the problem directly in the compression context.
But it felt awkward.
Now, the underlying compression API `ZSTD_compressContinue()` would take the decision the close a frame
on reaching its expected end (`pledgedSrcSize`).
This feels awkward, a responsability over-reach, beyond the definition of this API.
ZSTD_compressContinue() is clearly documented as a guaranteed flush,
with ZSTD_compressEnd() generating a guaranteed end.
I faced similar issue when trying to port a similar mechanism at the higher streaming layer.
Having ZSTD_CStream end a frame automatically on reaching `pledgedSrcSize` can surprise the caller,
since it did not explicitly requested an end of frame.
The only sensible action remaining after that is to end the frame with no additional input.
This adds additional logic in the ZSTD_CStream state to check this condition.
Plus some potential confusion on the meaning of ZSTD_endStream() with no additional input (ending confirmation ? new 0-size frame ?)
In the end, just enlarging input buffer by 1 byte feels the least intrusive change.
It's also a contract remaining inside the streaming layer, so the logic is contained in this part of the code.
The patch also introduces a new test checking that size of small frame is as expected, without additional 3-bytes null block.
2017-12-14 19:47:02 +00:00
|
|
|
./datagen -g5M | $ZSTD -T2 -D tmpDict | $ZSTD -t -D tmpDict # fails with v1.3.2
|
2017-12-13 19:48:30 +00:00
|
|
|
fi
|
2017-02-26 22:43:07 +00:00
|
|
|
$ECHO "- Create second (different) dictionary "
|
2016-08-18 13:13:41 +00:00
|
|
|
$ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC
|
2016-09-21 12:20:56 +00:00
|
|
|
$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Create dictionary with short dictID"
|
2017-03-25 01:36:56 +00:00
|
|
|
$ZSTD --train *.c ../programs/*.c --dictID=1 -o tmpDict1
|
2016-05-30 19:18:52 +00:00
|
|
|
cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
|
2016-09-21 12:20:56 +00:00
|
|
|
$ECHO "- Create dictionary with wrong dictID parameter order (must fail)"
|
|
|
|
$ZSTD --train *.c ../programs/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
|
|
|
|
$ECHO "- Create dictionary with size limit"
|
2017-03-25 01:36:56 +00:00
|
|
|
$ZSTD --train *.c ../programs/*.c -o tmpDict2 --maxdict=4K -v
|
2017-08-21 18:16:47 +00:00
|
|
|
$ECHO "- Create dictionary with small size limit"
|
|
|
|
$ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict=1K -v
|
2016-09-21 12:20:56 +00:00
|
|
|
$ECHO "- Create dictionary with wrong parameter order (must fail)"
|
2017-08-21 18:16:47 +00:00
|
|
|
$ZSTD --train *.c ../programs/*.c -o tmpDict3 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
|
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
|
2016-09-21 12:20:56 +00:00
|
|
|
$ZSTD -d tmp.zst -D tmpDict -fo result
|
2016-12-22 17:05:07 +00:00
|
|
|
$DIFF $TESTFILE result
|
2016-09-21 12:20:56 +00:00
|
|
|
$ECHO "- Compress with wrong argument order (must fail)"
|
2017-03-17 19:32:18 +00:00
|
|
|
$ZSTD tmp -Df tmpDict1 -c > $INTOVOID && die "-D must be followed by dictionary name "
|
2016-06-15 17:02:11 +00:00
|
|
|
$ECHO "- Compress multiple files with dictionary"
|
|
|
|
rm -rf dirTestDict
|
|
|
|
mkdir dirTestDict
|
|
|
|
cp *.c dirTestDict
|
2016-08-18 13:13:41 +00:00
|
|
|
cp ../programs/*.c dirTestDict
|
|
|
|
cp ../programs/*.h dirTestDict
|
2016-08-25 17:09:21 +00:00
|
|
|
$MD5SUM dirTestDict/* > tmph1
|
|
|
|
$ZSTD -f --rm dirTestDict/* -D tmpDictC
|
2016-08-25 20:22:50 +00:00
|
|
|
$ZSTD -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
|
2016-12-12 18:22:47 +00:00
|
|
|
case "$UNAME" in
|
|
|
|
Darwin) $ECHO "md5sum -c not supported on OS-X : test skipped" ;; # not compatible with OS-X's md5
|
2016-12-06 20:02:56 +00:00
|
|
|
*) $MD5SUM -c tmph1 ;;
|
|
|
|
esac
|
2016-06-15 17:02:11 +00:00
|
|
|
rm -rf dirTestDict
|
2017-03-23 23:24:02 +00:00
|
|
|
$ECHO "- dictionary builder on bogus input"
|
|
|
|
$ECHO "Hello World" > tmp
|
2017-05-02 06:40:20 +00:00
|
|
|
$ZSTD --train-legacy -q tmp && die "Dictionary training should fail : not enough input source"
|
2017-03-23 23:24:02 +00:00
|
|
|
./datagen -P0 -g10M > tmp
|
2017-05-02 06:40:20 +00:00
|
|
|
$ZSTD --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise"
|
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
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> cover dictionary builder : advanced options "
|
2017-01-01 06:59:51 +00:00
|
|
|
|
|
|
|
TESTFILE=../programs/zstdcli.c
|
|
|
|
./datagen > tmpDict
|
|
|
|
$ECHO "- Create first dictionary"
|
2017-05-02 06:40:20 +00:00
|
|
|
$ZSTD --train-cover=k=46,d=8 *.c ../programs/*.c -o tmpDict
|
2017-01-01 06:59:51 +00:00
|
|
|
cp $TESTFILE tmp
|
|
|
|
$ZSTD -f tmp -D tmpDict
|
|
|
|
$ZSTD -d tmp.zst -D tmpDict -fo result
|
|
|
|
$DIFF $TESTFILE result
|
|
|
|
$ECHO "- Create second (different) dictionary"
|
2017-05-02 06:40:20 +00:00
|
|
|
$ZSTD --train-cover=k=56,d=8 *.c ../programs/*.c ../programs/*.h -o tmpDictC
|
2017-01-01 06:59:51 +00:00
|
|
|
$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
|
|
|
|
$ECHO "- Create dictionary with short dictID"
|
2017-05-02 06:40:20 +00:00
|
|
|
$ZSTD --train-cover=k=46,d=8 *.c ../programs/*.c --dictID=1 -o tmpDict1
|
2017-01-01 06:59:51 +00:00
|
|
|
cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
|
|
|
|
$ECHO "- Create dictionary with size limit"
|
2017-05-02 06:40:20 +00:00
|
|
|
$ZSTD --train-cover=steps=8 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
|
|
|
|
rm tmp*
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> legacy dictionary builder "
|
2017-05-02 06:40:20 +00:00
|
|
|
|
|
|
|
TESTFILE=../programs/zstdcli.c
|
|
|
|
./datagen > tmpDict
|
|
|
|
$ECHO "- Create first dictionary"
|
|
|
|
$ZSTD --train-legacy=selectivity=8 *.c ../programs/*.c -o tmpDict
|
|
|
|
cp $TESTFILE tmp
|
|
|
|
$ZSTD -f tmp -D tmpDict
|
|
|
|
$ZSTD -d tmp.zst -D tmpDict -fo result
|
|
|
|
$DIFF $TESTFILE result
|
|
|
|
$ECHO "- Create second (different) dictionary"
|
|
|
|
$ZSTD --train-legacy=s=5 *.c ../programs/*.c ../programs/*.h -o tmpDictC
|
|
|
|
$ZSTD -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
|
|
|
|
$ECHO "- Create dictionary with short dictID"
|
|
|
|
$ZSTD --train-legacy -s5 *.c ../programs/*.c --dictID=1 -o tmpDict1
|
|
|
|
cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
|
|
|
|
$ECHO "- Create dictionary with size limit"
|
|
|
|
$ZSTD --train-legacy -s9 *.c ../programs/*.c -o tmpDict2 --maxdict=4K
|
2017-01-01 06:59:51 +00:00
|
|
|
rm tmp*
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +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
|
2017-05-06 02:15:24 +00:00
|
|
|
test -f tmp1.zst # check file is still present
|
|
|
|
split -b16384 tmp1.zst tmpSplit.
|
|
|
|
$ZSTD -t tmpSplit.* && die "bad file not detected !"
|
2017-07-18 21:45:49 +00:00
|
|
|
./datagen | $ZSTD -c | $ZSTD -t
|
2015-12-17 19:30:14 +00:00
|
|
|
|
2016-05-23 17:46:47 +00:00
|
|
|
|
2017-07-28 18:54:28 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> golden files tests "
|
2017-07-28 18:54:28 +00:00
|
|
|
|
|
|
|
$ZSTD -t -r files
|
|
|
|
$ZSTD -c -r files | $ZSTD -t
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> benchmark mode tests "
|
2016-10-28 21:43:24 +00:00
|
|
|
|
|
|
|
$ECHO "bench one file"
|
|
|
|
./datagen > tmp1
|
2017-03-02 00:49:20 +00:00
|
|
|
$ZSTD -bi0 tmp1
|
2016-10-28 21:43:24 +00:00
|
|
|
$ECHO "bench multiple levels"
|
2017-03-02 00:49:20 +00:00
|
|
|
$ZSTD -i0b0e3 tmp1
|
2016-10-28 21:43:24 +00:00
|
|
|
$ECHO "with recursive and quiet modes"
|
2017-03-02 00:49:20 +00:00
|
|
|
$ZSTD -rqi1b1e2 tmp1
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> gzip compatibility tests "
|
2017-03-02 00:49:20 +00:00
|
|
|
|
|
|
|
GZIPMODE=1
|
|
|
|
$ZSTD --format=gzip -V || GZIPMODE=0
|
|
|
|
if [ $GZIPMODE -eq 1 ]; then
|
2017-03-02 01:02:49 +00:00
|
|
|
$ECHO "gzip support detected"
|
2017-03-02 00:49:20 +00:00
|
|
|
GZIPEXE=1
|
2017-03-02 01:02:49 +00:00
|
|
|
gzip -V || GZIPEXE=0
|
2017-03-02 00:49:20 +00:00
|
|
|
if [ $GZIPEXE -eq 1 ]; then
|
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD --format=gzip -f tmp
|
|
|
|
gzip -t -v tmp.gz
|
|
|
|
gzip -f tmp
|
|
|
|
$ZSTD -d -f -v tmp.gz
|
2017-03-14 01:11:07 +00:00
|
|
|
rm tmp*
|
2017-03-02 00:49:20 +00:00
|
|
|
else
|
|
|
|
$ECHO "gzip binary not detected"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
$ECHO "gzip mode not supported"
|
|
|
|
fi
|
2016-10-28 21:43:24 +00:00
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> gzip frame tests "
|
2017-03-14 01:11:07 +00:00
|
|
|
|
|
|
|
if [ $GZIPMODE -eq 1 ]; then
|
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD -f --format=gzip tmp
|
|
|
|
$ZSTD -f tmp
|
|
|
|
cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp
|
2017-04-24 23:48:25 +00:00
|
|
|
head -c -1 tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
|
2017-03-14 01:11:07 +00:00
|
|
|
rm tmp*
|
|
|
|
else
|
|
|
|
$ECHO "gzip mode not supported"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> xz compatibility tests "
|
2017-03-14 01:11:07 +00:00
|
|
|
|
|
|
|
LZMAMODE=1
|
|
|
|
$ZSTD --format=xz -V || LZMAMODE=0
|
|
|
|
if [ $LZMAMODE -eq 1 ]; then
|
|
|
|
$ECHO "xz support detected"
|
|
|
|
XZEXE=1
|
|
|
|
xz -V && lzma -V || XZEXE=0
|
|
|
|
if [ $XZEXE -eq 1 ]; then
|
2017-06-26 18:24:36 +00:00
|
|
|
$ECHO "Testing zstd xz and lzma support"
|
2017-03-14 01:11:07 +00:00
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD --format=lzma -f tmp
|
|
|
|
$ZSTD --format=xz -f tmp
|
|
|
|
xz -t -v tmp.xz
|
|
|
|
xz -t -v tmp.lzma
|
|
|
|
xz -f -k tmp
|
|
|
|
lzma -f -k --lzma1 tmp
|
|
|
|
$ZSTD -d -f -v tmp.xz
|
|
|
|
$ZSTD -d -f -v tmp.lzma
|
|
|
|
rm tmp*
|
2017-06-26 18:24:36 +00:00
|
|
|
$ECHO "Creating symlinks"
|
|
|
|
ln -s $ZSTD ./xz
|
|
|
|
ln -s $ZSTD ./unxz
|
|
|
|
ln -s $ZSTD ./lzma
|
|
|
|
ln -s $ZSTD ./unlzma
|
|
|
|
$ECHO "Testing xz and lzma symlinks"
|
|
|
|
./datagen > tmp
|
|
|
|
./xz tmp
|
|
|
|
xz -d tmp.xz
|
|
|
|
./lzma tmp
|
|
|
|
lzma -d tmp.lzma
|
|
|
|
$ECHO "Testing unxz and unlzma symlinks"
|
|
|
|
xz tmp
|
|
|
|
./xz -d tmp.xz
|
|
|
|
lzma tmp
|
|
|
|
./lzma -d tmp.lzma
|
|
|
|
rm xz unxz lzma unlzma
|
|
|
|
rm tmp*
|
2017-03-14 01:11:07 +00:00
|
|
|
else
|
|
|
|
$ECHO "xz binary not detected"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
$ECHO "xz mode not supported"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> xz frame tests "
|
2017-03-14 01:11:07 +00:00
|
|
|
|
|
|
|
if [ $LZMAMODE -eq 1 ]; then
|
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD -f --format=xz tmp
|
|
|
|
$ZSTD -f --format=lzma tmp
|
|
|
|
$ZSTD -f tmp
|
|
|
|
cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp
|
2017-04-24 23:48:25 +00:00
|
|
|
head -c -1 tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
|
|
|
|
head -c -1 tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
|
2017-03-14 01:11:07 +00:00
|
|
|
rm tmp*
|
|
|
|
else
|
|
|
|
$ECHO "xz mode not supported"
|
|
|
|
fi
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> lz4 compatibility tests "
|
2017-04-24 23:48:25 +00:00
|
|
|
|
|
|
|
LZ4MODE=1
|
|
|
|
$ZSTD --format=lz4 -V || LZ4MODE=0
|
|
|
|
if [ $LZ4MODE -eq 1 ]; then
|
|
|
|
$ECHO "lz4 support detected"
|
|
|
|
LZ4EXE=1
|
|
|
|
lz4 -V || LZ4EXE=0
|
|
|
|
if [ $LZ4EXE -eq 1 ]; then
|
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD --format=lz4 -f tmp
|
|
|
|
lz4 -t -v tmp.lz4
|
|
|
|
lz4 -f tmp
|
|
|
|
$ZSTD -d -f -v tmp.lz4
|
|
|
|
rm tmp*
|
|
|
|
else
|
|
|
|
$ECHO "lz4 binary not detected"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
$ECHO "lz4 mode not supported"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> lz4 frame tests "
|
2017-04-24 23:48:25 +00:00
|
|
|
|
|
|
|
if [ $LZ4MODE -eq 1 ]; then
|
|
|
|
./datagen > tmp
|
|
|
|
$ZSTD -f --format=lz4 tmp
|
|
|
|
$ZSTD -f tmp
|
|
|
|
cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp
|
|
|
|
head -c -1 tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
|
|
|
|
rm tmp*
|
|
|
|
else
|
|
|
|
$ECHO "lz4 mode not supported"
|
|
|
|
fi
|
2017-03-14 01:11:07 +00:00
|
|
|
|
2017-10-16 21:01:42 +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
|
2017-03-02 00:49:20 +00:00
|
|
|
roundTripTest -g522K # TableID==0
|
|
|
|
roundTripTest -g519K 6 # greedy, hash chain
|
|
|
|
roundTripTest -g517K 16 # btlazy2
|
|
|
|
roundTripTest -g516K 19 # btopt
|
2016-02-15 19:37:23 +00:00
|
|
|
|
2017-04-12 00:15:13 +00:00
|
|
|
fileRoundTripTest -g500K
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd long distance matching round-trip tests "
|
2017-07-28 22:51:33 +00:00
|
|
|
roundTripTest -g0 "2 --long"
|
|
|
|
roundTripTest -g1000K "1 --long"
|
|
|
|
roundTripTest -g517K "6 --long"
|
|
|
|
roundTripTest -g516K "16 --long"
|
|
|
|
roundTripTest -g518K "19 --long"
|
|
|
|
fileRoundTripTest -g5M "3 --long"
|
|
|
|
|
|
|
|
|
2017-04-17 18:38:53 +00:00
|
|
|
if [ -n "$hasMT" ]
|
|
|
|
then
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstdmt round-trip tests "
|
2017-04-17 19:10:58 +00:00
|
|
|
roundTripTest -g4M "1 -T0"
|
|
|
|
roundTripTest -g8M "3 -T2"
|
2017-04-21 18:38:13 +00:00
|
|
|
roundTripTest -g8000K "2 --threads=2"
|
2017-04-17 19:10:58 +00:00
|
|
|
fileRoundTripTest -g4M "19 -T2 -B1M"
|
2017-07-28 22:51:33 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstdmt long distance matching round-trip tests "
|
2017-07-28 22:51:33 +00:00
|
|
|
roundTripTest -g8M "3 --long -T2"
|
2017-04-17 18:38:53 +00:00
|
|
|
else
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> no multithreading, skipping zstdmt tests "
|
2017-04-17 18:38:53 +00:00
|
|
|
fi
|
|
|
|
|
2016-02-15 19:37:23 +00:00
|
|
|
rm tmp*
|
2015-12-08 15:36:37 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd --list/-l single frame tests "
|
2017-06-15 23:53:03 +00:00
|
|
|
./datagen > tmp1
|
|
|
|
./datagen > tmp2
|
|
|
|
./datagen > tmp3
|
|
|
|
$ZSTD tmp*
|
2017-06-20 17:45:06 +00:00
|
|
|
$ZSTD -l *.zst
|
2017-10-14 06:47:01 +00:00
|
|
|
$ZSTD -lv *.zst | grep "Decompressed Size:" # check that decompressed size is present in header
|
2017-06-20 17:45:06 +00:00
|
|
|
$ZSTD --list *.zst
|
|
|
|
$ZSTD --list -v *.zst
|
2017-06-15 23:53:03 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd --list/-l multiple frame tests "
|
2017-06-15 23:53:03 +00:00
|
|
|
cat tmp1.zst tmp2.zst > tmp12.zst
|
2017-09-27 22:16:27 +00:00
|
|
|
cat tmp12.zst tmp3.zst > tmp123.zst
|
2017-06-20 17:45:06 +00:00
|
|
|
$ZSTD -l *.zst
|
|
|
|
$ZSTD -lv *.zst
|
2017-06-15 23:53:03 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd --list/-l error detection tests "
|
2017-06-20 21:14:53 +00:00
|
|
|
! $ZSTD -l tmp1 tmp1.zst
|
|
|
|
! $ZSTD --list tmp*
|
|
|
|
! $ZSTD -lv tmp1*
|
2017-09-27 22:16:27 +00:00
|
|
|
! $ZSTD --list -v tmp2 tmp12.zst
|
2017-06-20 18:54:44 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd --list/-l test with null files "
|
2017-06-20 21:33:08 +00:00
|
|
|
./datagen -g0 > tmp5
|
|
|
|
$ZSTD tmp5
|
2017-06-21 19:09:53 +00:00
|
|
|
$ZSTD -l tmp5.zst
|
2017-06-20 21:33:08 +00:00
|
|
|
! $ZSTD -l tmp5*
|
2017-10-17 23:23:20 +00:00
|
|
|
$ZSTD -lv tmp5.zst | grep "Decompressed Size: 0.00 KB (0 B)" # check that 0 size is present in header
|
2017-06-20 21:33:08 +00:00
|
|
|
! $ZSTD -lv tmp5*
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd --list/-l test with no content size field "
|
2017-10-14 06:47:01 +00:00
|
|
|
./datagen -g513K | $ZSTD > tmp6.zst
|
2017-06-21 00:43:36 +00:00
|
|
|
$ZSTD -l tmp6.zst
|
2017-10-14 06:47:01 +00:00
|
|
|
! $ZSTD -lv tmp6.zst | grep "Decompressed Size:" # must NOT be present in header
|
2017-06-21 19:09:53 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd --list/-l test with no checksum "
|
2017-06-21 19:09:53 +00:00
|
|
|
$ZSTD -f --no-check tmp1
|
|
|
|
$ZSTD -l tmp1.zst
|
|
|
|
$ZSTD -lv tmp1.zst
|
2017-06-21 00:43:36 +00:00
|
|
|
|
2017-06-15 23:53:03 +00:00
|
|
|
rm tmp*
|
|
|
|
|
2017-06-21 19:09:53 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd long distance matching tests "
|
2017-09-27 22:48:06 +00:00
|
|
|
roundTripTest -g0 " --long"
|
|
|
|
roundTripTest -g9M "2 --long"
|
|
|
|
# Test parameter parsing
|
|
|
|
roundTripTest -g1M -P50 "1 --long=29" " --memory=512MB"
|
|
|
|
roundTripTest -g1M -P50 "1 --long=29 --zstd=wlog=28" " --memory=256MB"
|
|
|
|
roundTripTest -g1M -P50 "1 --long=29" " --long=28 --memory=512MB"
|
|
|
|
roundTripTest -g1M -P50 "1 --long=29" " --zstd=wlog=28 --memory=512MB"
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> large files tests "
|
2017-09-27 22:48:06 +00:00
|
|
|
|
2015-12-08 15:36:37 +00:00
|
|
|
roundTripTest -g270000000 1
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g250000000 2
|
|
|
|
roundTripTest -g230000000 3
|
2015-12-08 15:36:37 +00:00
|
|
|
|
|
|
|
roundTripTest -g140000000 -P60 4
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g130000000 -P62 5
|
|
|
|
roundTripTest -g120000000 -P65 6
|
2015-12-08 15:36:37 +00:00
|
|
|
|
|
|
|
roundTripTest -g70000000 -P70 7
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g60000000 -P71 8
|
|
|
|
roundTripTest -g50000000 -P73 9
|
2015-12-08 15:36:37 +00:00
|
|
|
|
|
|
|
roundTripTest -g35000000 -P75 10
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g30000000 -P76 11
|
|
|
|
roundTripTest -g25000000 -P78 12
|
2015-12-08 15:11:10 +00:00
|
|
|
|
2017-07-11 00:16:41 +00:00
|
|
|
roundTripTest -g18000013 -P80 13
|
|
|
|
roundTripTest -g18000014 -P80 14
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g18000015 -P81 15
|
|
|
|
roundTripTest -g18000016 -P84 16
|
|
|
|
roundTripTest -g18000017 -P88 17
|
2017-07-11 00:16:41 +00:00
|
|
|
roundTripTest -g18000018 -P94 18
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g18000019 -P96 19
|
2015-12-08 16:36:42 +00:00
|
|
|
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g5000000000 -P99 1
|
2017-12-29 16:40:36 +00:00
|
|
|
roundTripTest -g1700000000 -P0 "1 --zstd=strategy=6" # ensure btlazy2 can survive an overflow rescale
|
2016-02-15 19:37:23 +00:00
|
|
|
|
2017-04-12 00:15:13 +00:00
|
|
|
fileRoundTripTest -g4193M -P99 1
|
|
|
|
|
2017-09-27 22:48:06 +00:00
|
|
|
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstd long, long distance matching round-trip tests "
|
2017-07-28 22:51:33 +00:00
|
|
|
roundTripTest -g270000000 "1 --long"
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g130000000 -P60 "5 --long"
|
|
|
|
roundTripTest -g35000000 -P70 "8 --long"
|
2017-07-28 22:51:33 +00:00
|
|
|
roundTripTest -g18000001 -P80 "18 --long"
|
2017-09-22 21:04:39 +00:00
|
|
|
# Test large window logs
|
2017-09-27 22:38:27 +00:00
|
|
|
roundTripTest -g700M -P50 "1 --long=29"
|
|
|
|
roundTripTest -g600M -P50 "1 --long --zstd=wlog=29,clog=28"
|
2017-07-28 22:51:33 +00:00
|
|
|
|
|
|
|
|
2017-04-17 18:38:53 +00:00
|
|
|
if [ -n "$hasMT" ]
|
|
|
|
then
|
2017-10-16 21:01:42 +00:00
|
|
|
$ECHO "\n===> zstdmt long round-trip tests "
|
2017-09-27 22:16:27 +00:00
|
|
|
roundTripTest -g80000000 -P99 "19 -T2" " "
|
|
|
|
roundTripTest -g5000000000 -P99 "1 -T2" " "
|
|
|
|
roundTripTest -g500000000 -P97 "1 -T999" " "
|
|
|
|
fileRoundTripTest -g4103M -P98 " -T0" " "
|
|
|
|
roundTripTest -g400000000 -P97 "1 --long=24 -T2" " "
|
2017-04-17 18:38:53 +00:00
|
|
|
else
|
|
|
|
$ECHO "\n**** no multithreading, skipping zstdmt tests **** "
|
|
|
|
fi
|
|
|
|
|
2016-02-15 19:37:23 +00:00
|
|
|
rm tmp*
|