mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
xzgrep: Improve the test script.
Now it should be close to the functionality of the original version by Pavel Raiskup.
This commit is contained in:
parent
1e60f2c0a0
commit
4244b65b06
3 changed files with 55 additions and 11 deletions
|
@ -52,4 +52,5 @@ TESTS += test_scripts.sh
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
-rm -f compress_generated_*
|
-rm -f compress_generated_* \
|
||||||
|
xzgrep_test_output xzgrep_test_1.xz xzgrep_test_2.xz
|
||||||
|
|
|
@ -54,19 +54,23 @@ fi
|
||||||
|
|
||||||
# The exit status must be 0 when a match was found at least from one file,
|
# The exit status must be 0 when a match was found at least from one file,
|
||||||
# and 1 when no match was found in any file.
|
# and 1 when no match was found in any file.
|
||||||
|
cp "$srcdir/files/good-1-lzma2-1.xz" xzgrep_test_1.xz
|
||||||
|
cp "$srcdir/files/good-2-lzma2.xz" xzgrep_test_2.xz
|
||||||
for pattern in el Hello NOMATCH; do
|
for pattern in el Hello NOMATCH; do
|
||||||
for opts in "" "-l" "-h" "-H"; do
|
for opts in "" "-l" "-h" "-H"; do
|
||||||
"$XZGREP" $opts $pattern \
|
echo "=> xzgrep $opts $pattern <="
|
||||||
"$srcdir/files/good-1-lzma2-1.xz" \
|
"$XZGREP" $opts $pattern xzgrep_test_1.xz xzgrep_test_2.xz
|
||||||
"$srcdir/files/good-2-lzma2.xz" > /dev/null 2>&1
|
echo retval $?
|
||||||
status=$?
|
|
||||||
test $status = 0 && test $pattern != NOMATCH && continue
|
|
||||||
test $status = 1 && test $pattern = NOMATCH && continue
|
|
||||||
echo "wrong exit status from xzgrep"
|
|
||||||
(exit 1)
|
|
||||||
exit 1
|
|
||||||
done
|
done
|
||||||
done
|
done > xzgrep_test_output 2>&1
|
||||||
|
|
||||||
|
if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "unexpected output from xzgrep"
|
||||||
|
(exit 1)
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
(exit 0)
|
(exit 0)
|
||||||
exit 0
|
exit 0
|
||||||
|
|
39
tests/xzgrep_expected_output
Normal file
39
tests/xzgrep_expected_output
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
=> xzgrep el <=
|
||||||
|
xzgrep_test_1.xz:elit, sed do eiusmod tempor incididunt ut
|
||||||
|
xzgrep_test_1.xz:in voluptate velit esse cillum dolore eu
|
||||||
|
xzgrep_test_2.xz:Hello
|
||||||
|
retval 0
|
||||||
|
=> xzgrep -l el <=
|
||||||
|
xzgrep_test_1.xz
|
||||||
|
xzgrep_test_2.xz
|
||||||
|
retval 0
|
||||||
|
=> xzgrep -h el <=
|
||||||
|
elit, sed do eiusmod tempor incididunt ut
|
||||||
|
in voluptate velit esse cillum dolore eu
|
||||||
|
Hello
|
||||||
|
retval 0
|
||||||
|
=> xzgrep -H el <=
|
||||||
|
xzgrep_test_1.xz:elit, sed do eiusmod tempor incididunt ut
|
||||||
|
xzgrep_test_1.xz:in voluptate velit esse cillum dolore eu
|
||||||
|
xzgrep_test_2.xz:Hello
|
||||||
|
retval 0
|
||||||
|
=> xzgrep Hello <=
|
||||||
|
xzgrep_test_2.xz:Hello
|
||||||
|
retval 0
|
||||||
|
=> xzgrep -l Hello <=
|
||||||
|
xzgrep_test_2.xz
|
||||||
|
retval 0
|
||||||
|
=> xzgrep -h Hello <=
|
||||||
|
Hello
|
||||||
|
retval 0
|
||||||
|
=> xzgrep -H Hello <=
|
||||||
|
xzgrep_test_2.xz:Hello
|
||||||
|
retval 0
|
||||||
|
=> xzgrep NOMATCH <=
|
||||||
|
retval 1
|
||||||
|
=> xzgrep -l NOMATCH <=
|
||||||
|
retval 1
|
||||||
|
=> xzgrep -h NOMATCH <=
|
||||||
|
retval 1
|
||||||
|
=> xzgrep -H NOMATCH <=
|
||||||
|
retval 1
|
Loading…
Reference in a new issue