]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[zstdgrep] Add a simple test 2024/head
authorNick Terrell <terrelln@fb.com>
Mon, 2 Mar 2020 21:04:37 +0000 (13:04 -0800)
committerNick Terrell <terrelln@fb.com>
Tue, 3 Mar 2020 00:51:34 +0000 (16:51 -0800)
tests/playTests.sh

index 09fe92fcf9a22ca4a959c09b74571c2002d5e5c8..c7605cc480fe8c1cadb3ee68e629bed8e4d24c2a 100755 (executable)
@@ -63,6 +63,7 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
 PRGDIR="$SCRIPT_DIR/../programs"
 TESTDIR="$SCRIPT_DIR/../tests"
 UNAME=$(uname)
+ZSTDGREP="$PRGDIR/zstdgrep"
 
 detectedTerminal=false
 if [ -t 0 ] && [ -t 1 ]
@@ -225,6 +226,17 @@ $ZSTD tmp -c --compress-literals    -19      | $ZSTD -t
 $ZSTD -b --fast=1 -i0e1 tmp --compress-literals
 $ZSTD -b --fast=1 -i0e1 tmp --no-compress-literals
 
+println "\n===> zstdgrep tests"
+ln -sf $ZSTD_BIN zstdcat
+rm -f tmp_grep
+echo "1234" > tmp_grep
+$ZSTD -f tmp_grep
+lines=$(ZCAT=./zstdcat $ZSTDGREP 2>&1 "1234" tmp_grep tmp_grep.zst | wc -l)
+test 2 -eq $lines
+ZCAT=./zstdcat $ZSTDGREP 2>&1 "1234" tmp_grep_bad.zst && die "Should have failed"
+ZCAT=./zstdcat $ZSTDGREP 2>&1 "1234" tmp_grep_bad.zst | grep "No such file or directory" || true
+rm -f tmp_grep*
+
 println "\n===>  --exclude-compressed flag"
 rm -rf precompressedFilterTestDir
 mkdir -p precompressedFilterTestDir