3 ###############################################################################
5 # Author: Jonathan Nieder
7 # This file has been put into the public domain.
8 # You can do whatever you want with this file.
10 ###############################################################################
12 # If scripts weren't built, this test is skipped.
14 XZDIFF
=..
/src
/scripts
/xzdiff
15 XZGREP
=..
/src
/scripts
/xzgrep
17 for i
in XZ XZDIFF XZGREP
; do
18 eval test -x "\$$i" && continue
22 # If decompression support is missing, this test is skipped.
23 # Installing the scripts in this case is a bit silly but they
24 # could still be used with other decompression tools so configure
25 # doesn't automatically disable scripts if decoders are disabled.
26 if grep 'define HAVE_DECODERS' ..
/config.h
> /dev
/null
; then
29 echo "Decompression support is disabled, skipping this test."
33 PATH
=`pwd`/..
/src
/xz
:$PATH
36 test -z "$srcdir" && srcdir
=.
37 preimage
=$srcdir/files
/good-1-check-crc32.xz
38 samepostimage
=$srcdir/files
/good-1-check-crc64.xz
39 otherpostimage
=$srcdir/files
/good-1-lzma2-1.xz
41 "$XZDIFF" "$preimage" "$samepostimage" >/dev
/null
43 if test "$status" != 0 ; then
44 echo "xzdiff with no changes exited with status $status != 0"
48 "$XZDIFF" "$preimage" "$otherpostimage" >/dev
/null
50 if test "$status" != 1 ; then
51 echo "xzdiff with changes exited with status $status != 1"
55 "$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev
/null
2>&1
57 if test "$status" != 2 ; then
58 echo "xzdiff with missing operand exited with status $status != 2"
62 # The exit status must be 0 when a match was found at least from one file,
63 # and 1 when no match was found in any file.
64 cp "$srcdir/files/good-1-lzma2-1.xz" xzgrep_test_1.xz
65 cp "$srcdir/files/good-2-lzma2.xz" xzgrep_test_2.xz
66 for pattern
in el Hello NOMATCH
; do
67 for opts
in "" "-l" "-h" "-H"; do
68 echo "=> xzgrep $opts $pattern <="
69 "$XZGREP" $opts $pattern xzgrep_test_1.xz xzgrep_test_2.xz
72 done > xzgrep_test_output
2>&1
74 if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output
; then
77 echo "unexpected output from xzgrep"