aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2011-07-31 11:01:47 +0300
committerLasse Collin <lasse.collin@tukaani.org>2011-07-31 11:01:47 +0300
commit1c673e5681720491a74fc4b2992e075f47302c22 (patch)
treefe5b667068731fadd3f803cd014c3c46b9777cf7 /tests
parentliblzma: Remove unneeded semicolon. (diff)
downloadxz-1c673e5681720491a74fc4b2992e075f47302c22.tar.xz
Fix exit status of "xzdiff foo.xz bar.xz".
xzdiff was clobbering the exit status from diff in a case statement used to analyze the exit statuses from "xz" when its operands were two compressed files. Save and restore diff's exit status to fix this. The bug is inherited from zdiff in GNU gzip and was fixed there on 2009-10-09. Thanks to Jonathan Nieder for the patch and to Peter Pallinger for reporting the bug.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rwxr-xr-xtests/test_scripts.sh54
2 files changed, 57 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d0807ae4..0469264a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,6 +10,7 @@ EXTRA_DIST = \
tests.h \
test_files.sh \
test_compress.sh \
+ test_scripts.sh \
bcj_test.c \
compress_prepared_bcj_sparc \
compress_prepared_bcj_x86
@@ -42,7 +43,8 @@ TESTS = \
test_block_header \
test_index \
test_files.sh \
- test_compress.sh
+ test_compress.sh \
+ test_scripts.sh
clean-local:
-rm -f compress_generated_*
diff --git a/tests/test_scripts.sh b/tests/test_scripts.sh
new file mode 100755
index 00000000..891fc76a
--- /dev/null
+++ b/tests/test_scripts.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+###############################################################################
+#
+# Author: Jonathan Nieder
+#
+# This file has been put into the public domain.
+# You can do whatever you want with this file.
+#
+###############################################################################
+
+# If scripts weren't built, this test is skipped.
+XZ=../src/xz/xz
+XZDIFF=../src/scripts/xzdiff
+test -x "$XZ" || XZ=
+test -r "$XZDIFF" || XZDIFF=
+if test -z "$XZ" || test -z "$XZDIFF"; then
+ (exit 77)
+ exit 77
+fi
+
+PATH=`pwd`/../src/xz:$PATH
+export PATH
+
+preimage=$srcdir/files/good-1-check-crc32.xz
+samepostimage=$srcdir/files/good-1-check-crc64.xz
+otherpostimage=$srcdir/files/good-1-lzma2-1.xz
+
+sh "$XZDIFF" "$preimage" "$samepostimage" >/dev/null
+status=$?
+if test "$status" != 0 ; then
+ echo "xzdiff with no changes exited with status $status != 0"
+ (exit 1)
+ exit 1
+fi
+
+sh "$XZDIFF" "$preimage" "$otherpostimage" >/dev/null
+status=$?
+if test "$status" != 1 ; then
+ echo "xzdiff with changes exited with status $status != 1"
+ (exit 1)
+ exit 1
+fi
+
+sh "$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev/null 2>&1
+status=$?
+if test "$status" != 2 ; then
+ echo "xzdiff with missing operand exited with status $status != 2"
+ (exit 1)
+ exit 1
+fi
+
+(exit 0)
+exit 0