liblzma: Prevent warning for MSYS2 Windows build.
[xz/debian.git] / tests / test_scripts.sh
blobee823612271841634aeb089489fae54d56adf996
1 #!/bin/sh
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.
13 XZ=../src/xz/xz
14 XZDIFF=../src/scripts/xzdiff
15 XZGREP=../src/scripts/xzgrep
17 for i in XZ XZDIFF XZGREP; do
18 eval test -x "\$$i" && continue
19 exit 77
20 done
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
28 else
29 echo "Decompression support is disabled, skipping this test."
30 exit 77
33 PATH=`pwd`/../src/xz:$PATH
34 export 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
42 status=$?
43 if test "$status" != 0 ; then
44 echo "xzdiff with no changes exited with status $status != 0"
45 exit 1
48 "$XZDIFF" "$preimage" "$otherpostimage" >/dev/null
49 status=$?
50 if test "$status" != 1 ; then
51 echo "xzdiff with changes exited with status $status != 1"
52 exit 1
55 "$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev/null 2>&1
56 status=$?
57 if test "$status" != 2 ; then
58 echo "xzdiff with missing operand exited with status $status != 2"
59 exit 1
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
70 echo retval $?
71 done
72 done > xzgrep_test_output 2>&1
74 if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then
76 else
77 echo "unexpected output from xzgrep"
78 exit 1
81 exit 0