Home | History | Annotate | Line # | Download | only in tests
test_scripts.sh revision 1.1.1.1
      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.
     13 XZ=../src/xz/xz
     14 XZDIFF=../src/scripts/xzdiff
     15 XZGREP=../src/scripts/xzgrep
     16 
     17 for i in XZ XZDIFF XZGREP; do
     18 	eval test -x "\$$i" && continue
     19 	(exit 77)
     20 	exit 77
     21 done
     22 
     23 PATH=`pwd`/../src/xz:$PATH
     24 export PATH
     25 
     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
     30 
     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
     37 fi
     38 
     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
     45 fi
     46 
     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
     53 fi
     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.
     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
     66 
     67 if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then
     68 	:
     69 else
     70 	echo "unexpected output from xzgrep"
     71 	(exit 1)
     72 	exit 1
     73 fi
     74 
     75 (exit 0)
     76 exit 0
     77