2011-07-31 08:01:47 +00:00
|
|
|
#!/bin/sh
|
2024-02-12 15:09:10 +00:00
|
|
|
# SPDX-License-Identifier: 0BSD
|
2011-07-31 08:01:47 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Author: Jonathan Nieder
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# If scripts weren't built, this test is skipped.
|
2024-02-17 13:35:35 +00:00
|
|
|
# When this is run from CMake, $1 is a relative path
|
|
|
|
# to the directory with the executables and the scripts.
|
|
|
|
XZ=${1:-../src/xz}/xz
|
|
|
|
XZDIFF=${1:-../src/scripts}/xzdiff
|
|
|
|
XZGREP=${1:-../src/scripts}/xzgrep
|
2014-06-11 18:03:25 +00:00
|
|
|
|
|
|
|
for i in XZ XZDIFF XZGREP; do
|
|
|
|
eval test -x "\$$i" && continue
|
2011-07-31 08:01:47 +00:00
|
|
|
exit 77
|
2014-06-11 18:03:25 +00:00
|
|
|
done
|
2011-07-31 08:01:47 +00:00
|
|
|
|
2022-10-19 16:39:35 +00:00
|
|
|
# If decompression support is missing, this test is skipped.
|
|
|
|
# Installing the scripts in this case is a bit silly but they
|
|
|
|
# could still be used with other decompression tools so configure
|
|
|
|
# doesn't automatically disable scripts if decoders are disabled.
|
2024-02-17 13:35:35 +00:00
|
|
|
if test ! -f ../config.h \
|
|
|
|
|| grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then
|
2022-10-19 16:39:35 +00:00
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Decompression support is disabled, skipping this test."
|
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
|
2024-02-17 13:35:35 +00:00
|
|
|
PATH=`pwd`/${1:-../src/xz}:$PATH
|
2011-07-31 08:01:47 +00:00
|
|
|
export PATH
|
|
|
|
|
2014-06-11 18:03:25 +00:00
|
|
|
test -z "$srcdir" && srcdir=.
|
2011-07-31 08:01:47 +00:00
|
|
|
preimage=$srcdir/files/good-1-check-crc32.xz
|
|
|
|
samepostimage=$srcdir/files/good-1-check-crc64.xz
|
|
|
|
otherpostimage=$srcdir/files/good-1-lzma2-1.xz
|
|
|
|
|
2011-08-06 17:37:28 +00:00
|
|
|
"$XZDIFF" "$preimage" "$samepostimage" >/dev/null
|
2011-07-31 08:01:47 +00:00
|
|
|
status=$?
|
|
|
|
if test "$status" != 0 ; then
|
|
|
|
echo "xzdiff with no changes exited with status $status != 0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-08-06 17:37:28 +00:00
|
|
|
"$XZDIFF" "$preimage" "$otherpostimage" >/dev/null
|
2011-07-31 08:01:47 +00:00
|
|
|
status=$?
|
|
|
|
if test "$status" != 1 ; then
|
|
|
|
echo "xzdiff with changes exited with status $status != 1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-08-06 17:37:28 +00:00
|
|
|
"$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev/null 2>&1
|
2011-07-31 08:01:47 +00:00
|
|
|
status=$?
|
|
|
|
if test "$status" != 2 ; then
|
|
|
|
echo "xzdiff with missing operand exited with status $status != 2"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-06-11 18:03:25 +00:00
|
|
|
# The exit status must be 0 when a match was found at least from one file,
|
|
|
|
# and 1 when no match was found in any file.
|
2014-06-13 15:58:22 +00:00
|
|
|
cp "$srcdir/files/good-1-lzma2-1.xz" xzgrep_test_1.xz
|
|
|
|
cp "$srcdir/files/good-2-lzma2.xz" xzgrep_test_2.xz
|
2014-06-11 18:03:25 +00:00
|
|
|
for pattern in el Hello NOMATCH; do
|
|
|
|
for opts in "" "-l" "-h" "-H"; do
|
2014-06-13 15:58:22 +00:00
|
|
|
echo "=> xzgrep $opts $pattern <="
|
|
|
|
"$XZGREP" $opts $pattern xzgrep_test_1.xz xzgrep_test_2.xz
|
|
|
|
echo retval $?
|
2014-06-11 18:03:25 +00:00
|
|
|
done
|
2014-06-13 15:58:22 +00:00
|
|
|
done > xzgrep_test_output 2>&1
|
|
|
|
|
|
|
|
if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "unexpected output from xzgrep"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-06-11 18:03:25 +00:00
|
|
|
|
2011-07-31 08:01:47 +00:00
|
|
|
exit 0
|