Merge tag 'v5.2.4'
[xz/debian.git] / tests / test_scripts.sh
blob48a9308a2db5094f84b4c8cbb222d319d7bf111b
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 exit 77
21 done
23 PATH=`pwd`/../src/xz:$PATH
24 export PATH
26 test -z "$srcdir" && srcdir=.
27 preimage=$srcdir/files/good-1-check-crc32.xz
28 samepostimage=$srcdir/files/good-1-check-crc64.xz
29 otherpostimage=$srcdir/files/good-1-lzma2-1.xz
31 "$XZDIFF" "$preimage" "$samepostimage" >/dev/null
32 status=$?
33 if test "$status" != 0 ; then
34 echo "xzdiff with no changes exited with status $status != 0"
35 (exit 1)
36 exit 1
39 "$XZDIFF" "$preimage" "$otherpostimage" >/dev/null
40 status=$?
41 if test "$status" != 1 ; then
42 echo "xzdiff with changes exited with status $status != 1"
43 (exit 1)
44 exit 1
47 "$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev/null 2>&1
48 status=$?
49 if test "$status" != 2 ; then
50 echo "xzdiff with missing operand exited with status $status != 2"
51 (exit 1)
52 exit 1
55 # The exit status must be 0 when a match was found at least from one file,
56 # and 1 when no match was found in any file.
57 cp "$srcdir/files/good-1-lzma2-1.xz" xzgrep_test_1.xz
58 cp "$srcdir/files/good-2-lzma2.xz" xzgrep_test_2.xz
59 for pattern in el Hello NOMATCH; do
60 for opts in "" "-l" "-h" "-H"; do
61 echo "=> xzgrep $opts $pattern <="
62 "$XZGREP" $opts $pattern xzgrep_test_1.xz xzgrep_test_2.xz
63 echo retval $?
64 done
65 done > xzgrep_test_output 2>&1
67 if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then
69 else
70 echo "unexpected output from xzgrep"
71 (exit 1)
72 exit 1
75 (exit 0)
76 exit 0