aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-10-27 15:49:18 +0300
committerLasse Collin <lasse.collin@tukaani.org>2022-10-27 15:49:18 +0300
commit05c72de06fcaaedc78f8abba7d5ec568ddcf1e75 (patch)
treef7b92b15df4c517e54bd21de815c8f569e048885 /tests
parentTests: test_files.sh: Suppress an expected warning from the log. (diff)
downloadxz-05c72de06fcaaedc78f8abba7d5ec568ddcf1e75.tar.xz
Tests: test_files.sh: Make it not fail if features were disabled at build.
It now tries to test as many files as easily possible. The exit status indicates skipping if any of the files were skipped. This way it is easy to notice if something is being skipped when it isn't expected.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_files.sh50
1 files changed, 46 insertions, 4 deletions
diff --git a/tests/test_files.sh b/tests/test_files.sh
index 4fa3492c..6aa10d4e 100755
--- a/tests/test_files.sh
+++ b/tests/test_files.sh
@@ -30,21 +30,60 @@ else
exit 77
fi
+# If a feature was disabled at build time, make it possible to skip
+# some of the test files. Use exit status 77 if any files were skipped.
+EXIT_STATUS=0
+have_feature()
+{
+ grep "define HAVE_$1" ../config.h > /dev/null && return 0
+ printf '%s: Skipping because HAVE_%s is not enabled\n' "$2" "$1"
+ EXIT_STATUS=77
+ return 1
+}
+
#######
# .xz #
#######
+# 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
+
for I in "$srcdir"/files/good-*.xz
do
- if test -z "$XZ" || "$XZ" -dc "$I" > /dev/null; then
+ # If features were disabled at build time, keep this still working.
+ case $I in
+ */good-1-*delta-lzma2*.xz)
+ have_feature DECODER_DELTA "$I" || continue
+ ;;
+ esac
+ case $I in
+ */good-1-empty-bcj-lzma2.xz)
+ have_feature DECODER_POWERPC "$I" || continue
+ ;;
+ esac
+ case $I in
+ */good-1-sparc-lzma2.xz)
+ have_feature DECODER_SPARC "$I" || continue
+ ;;
+ esac
+ case $I in
+ */good-1-x86-lzma2.xz)
+ have_feature DECODER_X86 "$I" || continue
+ ;;
+ esac
+
+ if test -z "$XZ" || "$XZ" $NO_WARN -dc "$I" > /dev/null; then
:
else
echo "Good file failed: $I"
exit 1
fi
- if test -z "$XZDEC" || "$XZDEC" "$I" > /dev/null; then
+ if test -z "$XZDEC" || "$XZDEC" $NO_WARN "$I" > /dev/null; then
:
else
echo "Good file failed: $I"
@@ -59,7 +98,10 @@ do
exit 1
fi
- if test -n "$XZDEC" && "$XZDEC" "$I" > /dev/null 2>&1; then
+ # xzdec doesn't warn about unsupported check so skip this if any of
+ # the check types were disabled at built time (NO_WARN isn't empty).
+ if test -n "$XZDEC" && test -z "$NO_WARN" \
+ && "$XZDEC" "$I" > /dev/null 2>&1; then
echo "Bad file succeeded: $I"
exit 1
fi
@@ -122,4 +164,4 @@ do
fi
done
-exit 0
+exit "$EXIT_STATUS"