From 3a8f81e0ad4cd1c102a03ff09e703cf8cb074afc Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 20 May 2024 16:55:00 +0300 Subject: [PATCH] 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. (cherry picked from commit a7e9230af9d1f87f474fe38886eb977d4149dc9b) --- tests/test_files.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/test_files.sh b/tests/test_files.sh index 16cb8619..99c9f2fa 100755 --- a/tests/test_files.sh +++ b/tests/test_files.sh @@ -7,9 +7,12 @@ # ############################################################################### +# Optional argument: +# $1 = directory of the xz executable + # If both xz and xzdec were not built, skip this test. -XZ=../src/xz/xz -XZDEC=../src/xzdec/xzdec +XZ=${1:-../src/xz}/xz +XZDEC=${2:-../src/xzdec}/xzdec test -x "$XZ" || XZ= test -x "$XZDEC" || XZDEC= if test -z "$XZ$XZDEC"; then @@ -21,7 +24,9 @@ fi # This isn't perfect as if only some decompressors are disabled # then some good files might not decompress and the test fails # 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 echo "Decompression support is disabled, skipping this test." @@ -33,6 +38,7 @@ fi EXIT_STATUS=0 have_feature() { + test -f ../config.h || 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" EXIT_STATUS=77 @@ -47,8 +53,10 @@ have_feature() # If these integrity check types were disabled at build time, # allow the tests to pass still. NO_WARN= -grep 'define HAVE_CHECK_CRC64' ../config.h > /dev/null || NO_WARN=-qQ -grep 'define HAVE_CHECK_SHA256' ../config.h > /dev/null || NO_WARN=-qQ +if test -f ../config.h ; then + 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 do