summaryrefslogtreecommitdiffstats
path: root/tests/test_compress.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtests/test_compress.sh68
1 files changed, 42 insertions, 26 deletions
diff --git a/tests/test_compress.sh b/tests/test_compress.sh
index ff13cef..a10343a 100755
--- a/tests/test_compress.sh
+++ b/tests/test_compress.sh
@@ -1,26 +1,37 @@
#!/bin/sh
+# SPDX-License-Identifier: 0BSD
###############################################################################
#
# Author: Lasse Collin
#
-# This file has been put into the public domain.
-# You can do whatever you want with this file.
-#
###############################################################################
+# Mandatory argument:
+# $1 = test filename: compress_generated_<foo> or compress_prepared_<foo>
+#
+# Optional argument:
+# $2 = directory of the xz and xzdec executables
+
+XZ=${2:-../src/xz}/xz
+XZDEC=${2:-../src/xzdec}/xzdec
+
# If xz wasn't built, this test is skipped.
-if test -x ../src/xz/xz ; then
- :
-else
+if test ! -x "$XZ"; then
+ echo "xz was not built, skipping this test."
exit 77
fi
+# xzdec isn't mandatory for this script.
+test -x "$XZDEC" || XZDEC=
+
# If compression or decompression support is missing, this test is skipped.
# This isn't perfect as if only some compressors or decompressors are disabled
# then this script can still fail because for now this doesn't check the
# availability of each filter.
-if grep 'define HAVE_ENCODERS' ../config.h > /dev/null \
+if test ! -f ../config.h ; then
+ :
+elif grep 'define HAVE_ENCODERS' ../config.h > /dev/null \
&& grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then
:
else
@@ -76,12 +87,12 @@ test_xz() {
fi
}
-XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
- --no-adjust --threads=1 --check=crc32"
-grep "define HAVE_CHECK_CRC64" ../config.h > /dev/null \
- && XZ="$XZ --check=crc64"
-XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
-test -x ../src/xzdec/xzdec || XZDEC=
+# Set memory usage limit for xz. xzdec has no memory usage limiter.
+# Force single-threaded mode as the test files are small
+# (so more than one thread wouldn't be used anyway) and
+# the tests are usually run in parallel.
+XZ="$XZ --memlimit-compress=48MiB --memlimit-decompress=5MiB \
+ --no-adjust --threads=1"
# Create the required input file if needed.
#
@@ -130,21 +141,26 @@ test_xz -4
test_filter()
{
- grep "define HAVE_ENCODER_$1 1" ../config.h > /dev/null || return
- grep "define HAVE_DECODER_$1 1" ../config.h > /dev/null || return
+ if test -f ../config.h ; then
+ grep "define HAVE_ENCODER_$1 1" ../config.h > /dev/null \
+ || return
+ grep "define HAVE_DECODER_$1 1" ../config.h > /dev/null \
+ || return
+ fi
shift
- test_xz "$@" --lzma2=dict=64KiB,nice=32,mode=fast
+ test_xz --filters="$* lzma2:dict=64KiB,nice=32,mode=fast"
}
-test_filter DELTA --delta=dist=1
-test_filter DELTA --delta=dist=4
-test_filter DELTA --delta=dist=256
-test_filter X86 --x86
-test_filter POWERPC --power
-test_filter IA64 --ia64
-test_filter ARM --arm
-test_filter ARMTHUMB --armthumb
-test_filter ARM64 --arm64
-test_filter SPARC --sparc
+test_filter DELTA delta:dist=1
+test_filter DELTA delta:dist=4
+test_filter DELTA delta:dist=256
+test_filter X86 x86
+test_filter POWERPC powerpc
+test_filter IA64 ia64
+test_filter ARM arm
+test_filter ARMTHUMB armthumb
+test_filter ARM64 arm64
+test_filter SPARC sparc
+test_filter RISCV riscv
exit 0