2008-01-17 23:50:29 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
#
|
2009-04-13 10:27:40 +02:00
|
|
|
# Author: Lasse Collin
|
2008-01-17 23:50:29 +01:00
|
|
|
#
|
2009-04-13 10:27:40 +02:00
|
|
|
# This file has been put into the public domain.
|
|
|
|
# You can do whatever you want with this file.
|
2008-01-17 23:50:29 +01:00
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2010-10-08 14:32:29 +02:00
|
|
|
# If xz wasn't built, this test is skipped.
|
|
|
|
if test -x ../src/xz/xz ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
|
2022-10-19 18:39:35 +02:00
|
|
|
# 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 \
|
|
|
|
&& grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Compression or decompression support is disabled, skipping this test."
|
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
|
2008-01-17 23:50:29 +01:00
|
|
|
# Find out if our shell supports functions.
|
|
|
|
eval 'unset foo ; foo() { return 42; } ; foo'
|
|
|
|
if test $? != 42 ; then
|
|
|
|
echo "/bin/sh doesn't support functions, skipping this test."
|
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
|
2008-11-19 22:52:24 +01:00
|
|
|
test_xz() {
|
2022-05-23 20:17:47 +02:00
|
|
|
if $XZ -c "$@" "$FILE" > "$TMP_COMP"; then
|
2008-01-17 23:50:29 +01:00
|
|
|
:
|
|
|
|
else
|
2008-06-18 17:02:10 +02:00
|
|
|
echo "Compressing failed: $* $FILE"
|
2008-01-17 23:50:29 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-05-23 20:17:47 +02:00
|
|
|
if $XZ -cd "$TMP_COMP" > "$TMP_UNCOMP" ; then
|
2008-01-17 23:50:29 +01:00
|
|
|
:
|
|
|
|
else
|
2010-10-08 14:32:29 +02:00
|
|
|
echo "Decompressing failed: $* $FILE"
|
2008-01-17 23:50:29 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-05-23 20:17:47 +02:00
|
|
|
if cmp "$TMP_UNCOMP" "$FILE" ; then
|
2008-01-17 23:50:29 +01:00
|
|
|
:
|
|
|
|
else
|
2010-10-08 14:32:29 +02:00
|
|
|
echo "Decompressed file does not match" \
|
|
|
|
"the original: $* $FILE"
|
2008-01-17 23:50:29 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-10-08 14:32:29 +02:00
|
|
|
if test -n "$XZDEC" ; then
|
2022-05-23 20:17:47 +02:00
|
|
|
if $XZDEC "$TMP_COMP" > "$TMP_UNCOMP" ; then
|
2010-10-08 14:32:29 +02:00
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Decompressing failed: $* $FILE"
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-01-17 23:50:29 +01:00
|
|
|
|
2022-05-23 20:17:47 +02:00
|
|
|
if cmp "$TMP_UNCOMP" "$FILE" ; then
|
2010-10-08 14:32:29 +02:00
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Decompressed file does not match" \
|
|
|
|
"the original: $* $FILE"
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-01-17 23:50:29 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-09-03 23:49:15 +02:00
|
|
|
XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
|
2022-10-27 00:12:40 +02:00
|
|
|
--no-adjust --threads=1 --check=crc32"
|
|
|
|
grep "define HAVE_CHECK_CRC64" ../config.h > /dev/null \
|
|
|
|
&& XZ="$XZ --check=crc64"
|
2010-08-10 10:04:30 +02:00
|
|
|
XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
|
2010-10-08 14:32:29 +02:00
|
|
|
test -x ../src/xzdec/xzdec || XZDEC=
|
2008-01-17 23:50:29 +01:00
|
|
|
|
2022-05-23 20:17:47 +02:00
|
|
|
# Create the required input file if needed.
|
2023-01-04 17:40:28 +01:00
|
|
|
#
|
2023-01-04 16:58:58 +01:00
|
|
|
# Derive temporary filenames for compressed and uncompressed outputs
|
|
|
|
# from the input filename. This is needed when multiple tests are
|
|
|
|
# run in parallel.
|
2023-01-04 17:40:28 +01:00
|
|
|
FILE=$1
|
2023-01-04 16:58:58 +01:00
|
|
|
TMP_COMP="tmp_comp_$FILE"
|
|
|
|
TMP_UNCOMP="tmp_uncomp_$FILE"
|
2023-01-04 17:40:28 +01:00
|
|
|
|
2022-05-23 20:17:47 +02:00
|
|
|
case $FILE in
|
2023-01-04 17:40:28 +01:00
|
|
|
# compress_generated files will be created in the build directory
|
|
|
|
# in the /tests/ sub-directory.
|
2022-05-23 20:17:47 +02:00
|
|
|
compress_generated_*)
|
2023-01-04 16:58:58 +01:00
|
|
|
if ./create_compress_files "$FILE" ; then
|
2022-05-23 20:17:47 +02:00
|
|
|
:
|
|
|
|
else
|
|
|
|
rm -f "$FILE"
|
|
|
|
echo "Failed to create the file '$FILE'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
2023-01-04 17:40:28 +01:00
|
|
|
# compress_prepared files exist in the source directory since they
|
|
|
|
# do not need to be copied or regenerated.
|
2023-01-04 16:58:58 +01:00
|
|
|
compress_prepared_*)
|
|
|
|
FILE="$srcdir/$FILE"
|
|
|
|
;;
|
2022-05-23 20:17:47 +02:00
|
|
|
'')
|
|
|
|
echo "No test file was specified."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-01-17 23:50:29 +01:00
|
|
|
# Remove temporary now (in case they are something weird), and on exit.
|
2022-05-23 20:17:47 +02:00
|
|
|
rm -f "$TMP_COMP" "$TMP_UNCOMP"
|
|
|
|
trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0
|
2008-01-17 23:50:29 +01:00
|
|
|
|
2022-05-23 20:17:47 +02:00
|
|
|
# Compress and decompress the file with various filter configurations.
|
|
|
|
#
|
|
|
|
# Don't test with empty arguments; it breaks some ancient
|
|
|
|
# proprietary /bin/sh versions due to $@ used in test_xz().
|
|
|
|
test_xz -1
|
|
|
|
test_xz -2
|
|
|
|
test_xz -3
|
|
|
|
test_xz -4
|
2008-01-17 23:50:29 +01:00
|
|
|
|
2022-10-27 00:12:40 +02:00
|
|
|
test_filter()
|
|
|
|
{
|
2023-07-14 15:30:25 +02:00
|
|
|
grep "define HAVE_ENCODER_$1 1" ../config.h > /dev/null || return
|
|
|
|
grep "define HAVE_DECODER_$1 1" ../config.h > /dev/null || return
|
2022-10-27 00:12:40 +02:00
|
|
|
shift
|
2023-01-05 17:03:35 +01:00
|
|
|
test_xz --filters="$* lzma2:dict=64KiB,nice=32,mode=fast"
|
2022-10-27 00:12:40 +02:00
|
|
|
}
|
|
|
|
|
2023-01-05 17:03:35 +01:00
|
|
|
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
|
2023-07-20 16:11:13 +02:00
|
|
|
test_filter ARM64 arm64
|
2023-01-05 17:03:35 +01:00
|
|
|
test_filter SPARC sparc
|
2024-01-22 16:33:39 +01:00
|
|
|
test_filter RISCV riscv
|
2008-01-17 23:50:29 +01:00
|
|
|
|
|
|
|
exit 0
|