Tests: Make test_files.sh more flexible

Add a new optional argument to specify the directory of the xz and
xzdec executables.

If ../config.h doesn't exist, assume that all encoders and decoders
are available.
This commit is contained in:
Lasse Collin 2024-05-20 16:55:00 +03:00
parent b40e6efbb4
commit a7e9230af9
1 changed files with 13 additions and 5 deletions

View File

@ -7,9 +7,12 @@
# #
############################################################################### ###############################################################################
# Optional argument:
# $1 = directory of the xz executable
# If both xz and xzdec were not built, skip this test. # If both xz and xzdec were not built, skip this test.
XZ=../src/xz/xz XZ=${1:-../src/xz}/xz
XZDEC=../src/xzdec/xzdec XZDEC=${2:-../src/xzdec}/xzdec
test -x "$XZ" || XZ= test -x "$XZ" || XZ=
test -x "$XZDEC" || XZDEC= test -x "$XZDEC" || XZDEC=
if test -z "$XZ$XZDEC"; then if test -z "$XZ$XZDEC"; then
@ -21,7 +24,9 @@ fi
# This isn't perfect as if only some decompressors are disabled # This isn't perfect as if only some decompressors are disabled
# then some good files might not decompress and the test fails # then some good files might not decompress and the test fails
# for a (kind of) wrong reason. # for a (kind of) wrong reason.
if grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then if test ! -f ../config.h ; then
:
elif grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then
: :
else else
echo "Decompression support is disabled, skipping this test." echo "Decompression support is disabled, skipping this test."
@ -33,6 +38,7 @@ fi
EXIT_STATUS=0 EXIT_STATUS=0
have_feature() have_feature()
{ {
test -f ../config.h || return 0
grep "define HAVE_$1 1" ../config.h > /dev/null && return 0 grep "define HAVE_$1 1" ../config.h > /dev/null && return 0
printf '%s: Skipping because HAVE_%s is not enabled\n' "$2" "$1" printf '%s: Skipping because HAVE_%s is not enabled\n' "$2" "$1"
EXIT_STATUS=77 EXIT_STATUS=77
@ -47,8 +53,10 @@ have_feature()
# If these integrity check types were disabled at build time, # If these integrity check types were disabled at build time,
# allow the tests to pass still. # allow the tests to pass still.
NO_WARN= NO_WARN=
grep 'define HAVE_CHECK_CRC64' ../config.h > /dev/null || NO_WARN=-qQ if test -f ../config.h ; then
grep 'define HAVE_CHECK_SHA256' ../config.h > /dev/null || NO_WARN=-qQ grep 'define HAVE_CHECK_CRC64' ../config.h > /dev/null || NO_WARN=-qQ
grep 'define HAVE_CHECK_SHA256' ../config.h > /dev/null || NO_WARN=-qQ
fi
for I in "$srcdir"/files/good-*.xz for I in "$srcdir"/files/good-*.xz
do do