1#!/bin/sh 2 3############################################################################### 4# 5# Author: Jonathan Nieder 6# 7# This file has been put into the public domain. 8# You can do whatever you want with this file. 9# 10############################################################################### 11 12# If scripts weren't built, this test is skipped. 13XZ=../src/xz/xz 14XZDIFF=../src/scripts/xzdiff 15XZGREP=../src/scripts/xzgrep 16 17for i in XZ XZDIFF XZGREP; do 18 eval test -x "\$$i" && continue 19 (exit 77) 20 exit 77 21done 22 23PATH=`pwd`/../src/xz:$PATH 24export PATH 25 26test -z "$srcdir" && srcdir=. 27preimage=$srcdir/files/good-1-check-crc32.xz 28samepostimage=$srcdir/files/good-1-check-crc64.xz 29otherpostimage=$srcdir/files/good-1-lzma2-1.xz 30 31"$XZDIFF" "$preimage" "$samepostimage" >/dev/null 32status=$? 33if test "$status" != 0 ; then 34 echo "xzdiff with no changes exited with status $status != 0" 35 (exit 1) 36 exit 1 37fi 38 39"$XZDIFF" "$preimage" "$otherpostimage" >/dev/null 40status=$? 41if test "$status" != 1 ; then 42 echo "xzdiff with changes exited with status $status != 1" 43 (exit 1) 44 exit 1 45fi 46 47"$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev/null 2>&1 48status=$? 49if test "$status" != 2 ; then 50 echo "xzdiff with missing operand exited with status $status != 2" 51 (exit 1) 52 exit 1 53fi 54 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. 57cp "$srcdir/files/good-1-lzma2-1.xz" xzgrep_test_1.xz 58cp "$srcdir/files/good-2-lzma2.xz" xzgrep_test_2.xz 59for 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 65done > xzgrep_test_output 2>&1 66 67if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then 68 : 69else 70 echo "unexpected output from xzgrep" 71 (exit 1) 72 exit 1 73fi 74 75(exit 0) 76exit 0 77