aboutsummaryrefslogtreecommitdiff
path: root/tests/playTests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/playTests.sh')
-rwxr-xr-xtests/playTests.sh42
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/playTests.sh b/tests/playTests.sh
index ef4861b52917..bce2710159ed 100755
--- a/tests/playTests.sh
+++ b/tests/playTests.sh
@@ -49,7 +49,7 @@ fileRoundTripTest() {
}
truncateLastByte() {
- dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1" status=none
+ dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1"
}
UNAME=$(uname)
@@ -200,6 +200,15 @@ $ZSTD tmp -fo tmp && die "zstd compression overwrote the input file"
$ZSTD tmp.zst -dfo tmp.zst && die "zstd decompression overwrote the input file"
$ECHO "test: detect that input file does not exist"
$ZSTD nothere && die "zstd hasn't detected that input file does not exist"
+$ECHO "test: --[no-]compress-literals"
+$ZSTD tmp -c --no-compress-literals -1 | $ZSTD -t
+$ZSTD tmp -c --no-compress-literals --fast=1 | $ZSTD -t
+$ZSTD tmp -c --no-compress-literals -19 | $ZSTD -t
+$ZSTD tmp -c --compress-literals -1 | $ZSTD -t
+$ZSTD tmp -c --compress-literals --fast=1 | $ZSTD -t
+$ZSTD tmp -c --compress-literals -19 | $ZSTD -t
+$ZSTD -b --fast=1 -i1e1 tmp --compress-literals
+$ZSTD -b --fast=1 -i1e1 tmp --no-compress-literals
$ECHO "test : file removal"
$ZSTD -f --rm tmp
@@ -314,18 +323,28 @@ $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
+
+
+if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
$ECHO "\n===> symbolic link test "
-rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
+rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
$ECHO "hello world" > hello.tmp
ln -s hello.tmp world.tmp
-$ZSTD world.tmp hello.tmp
+ln -s hello.tmp world2.tmp
+$ZSTD world.tmp hello.tmp || true
test -f hello.tmp.zst # regular file should have been compressed!
test ! -f world.tmp.zst # symbolic link should not have been compressed!
+$ZSTD world.tmp || true
+test ! -f world.tmp.zst # symbolic link should not have been compressed!
+$ZSTD world.tmp world2.tmp || true
+test ! -f world.tmp.zst # symbolic link should not have been compressed!
+test ! -f world2.tmp.zst # symbolic link should not have been compressed!
$ZSTD world.tmp hello.tmp -f
test -f world.tmp.zst # symbolic link should have been compressed with --force
-rm -f hello.tmp world.tmp hello.tmp.zst world.tmp.zst
+rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
fi
@@ -391,6 +410,8 @@ $ECHO "- Create first dictionary "
TESTFILE=../programs/zstdcli.c
$ZSTD --train *.c ../programs/*.c -o tmpDict
cp $TESTFILE tmp
+$ECHO "- Test dictionary compression with tmpDict as an input file and dictionary"
+$ZSTD -f tmpDict -D tmpDict && die "compression error not detected!"
$ECHO "- Dictionary compression roundtrip"
$ZSTD -f tmp -D tmpDict
$ZSTD -d tmp.zst -D tmpDict -fo result
@@ -809,6 +830,19 @@ $ZSTD --list tmp* && die "-l must fail on non-zstd file"
$ZSTD -lv tmp1* && die "-l must fail on non-zstd file"
$ZSTD --list -v tmp2 tmp12.zst && die "-l must fail on non-zstd file"
+$ECHO "test : detect truncated compressed file "
+TEST_DATA_FILE=truncatable-input.txt
+FULL_COMPRESSED_FILE=${TEST_DATA_FILE}.zst
+TRUNCATED_COMPRESSED_FILE=truncated-input.txt.zst
+./datagen -g50000 > $TEST_DATA_FILE
+$ZSTD -f $TEST_DATA_FILE -o $FULL_COMPRESSED_FILE
+dd bs=1 count=100 if=$FULL_COMPRESSED_FILE of=$TRUNCATED_COMPRESSED_FILE
+$ZSTD --list $TRUNCATED_COMPRESSED_FILE && die "-l must fail on truncated file"
+
+rm $TEST_DATA_FILE
+rm $FULL_COMPRESSED_FILE
+rm $TRUNCATED_COMPRESSED_FILE
+
$ECHO "\n===> zstd --list/-l errors when presented with stdin / no files"
$ZSTD -l && die "-l must fail on empty list of files"
$ZSTD -l - && die "-l does not work on stdin"