2008-01-17 22:50:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
#
|
2009-04-13 08:27:40 +00:00
|
|
|
# Author: Lasse Collin
|
2008-01-17 22:50:29 +00:00
|
|
|
#
|
2009-04-13 08:27:40 +00:00
|
|
|
# This file has been put into the public domain.
|
|
|
|
# You can do whatever you want with this file.
|
2008-01-17 22:50:29 +00:00
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2010-10-08 12:32:29 +00:00
|
|
|
# If xz wasn't built, this test is skipped.
|
|
|
|
if test -x ../src/xz/xz ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
(exit 77)
|
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
|
2008-01-17 22:50:29 +00: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)
|
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
|
2008-11-19 21:52:24 +00:00
|
|
|
test_xz() {
|
2022-05-23 18:17:47 +00:00
|
|
|
if $XZ -c "$@" "$FILE" > "$TMP_COMP"; then
|
2008-01-17 22:50:29 +00:00
|
|
|
:
|
|
|
|
else
|
2008-06-18 15:02:10 +00:00
|
|
|
echo "Compressing failed: $* $FILE"
|
2008-01-17 22:50:29 +00:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-05-23 18:17:47 +00:00
|
|
|
if $XZ -cd "$TMP_COMP" > "$TMP_UNCOMP" ; then
|
2008-01-17 22:50:29 +00:00
|
|
|
:
|
|
|
|
else
|
2010-10-08 12:32:29 +00:00
|
|
|
echo "Decompressing failed: $* $FILE"
|
2008-01-17 22:50:29 +00:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-05-23 18:17:47 +00:00
|
|
|
if cmp "$TMP_UNCOMP" "$FILE" ; then
|
2008-01-17 22:50:29 +00:00
|
|
|
:
|
|
|
|
else
|
2010-10-08 12:32:29 +00:00
|
|
|
echo "Decompressed file does not match" \
|
|
|
|
"the original: $* $FILE"
|
2008-01-17 22:50:29 +00:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-10-08 12:32:29 +00:00
|
|
|
if test -n "$XZDEC" ; then
|
2022-05-23 18:17:47 +00:00
|
|
|
if $XZDEC "$TMP_COMP" > "$TMP_UNCOMP" ; then
|
2010-10-08 12:32:29 +00:00
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Decompressing failed: $* $FILE"
|
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-01-17 22:50:29 +00:00
|
|
|
|
2022-05-23 18:17:47 +00:00
|
|
|
if cmp "$TMP_UNCOMP" "$FILE" ; then
|
2010-10-08 12:32:29 +00:00
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Decompressed file does not match" \
|
|
|
|
"the original: $* $FILE"
|
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-01-17 22:50:29 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-09-03 21:49:15 +00:00
|
|
|
XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
|
2010-08-10 08:04:30 +00:00
|
|
|
--no-adjust --threads=1 --check=crc64"
|
|
|
|
XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
|
2010-10-08 12:32:29 +00:00
|
|
|
test -x ../src/xzdec/xzdec || XZDEC=
|
2008-01-17 22:50:29 +00:00
|
|
|
|
2022-05-23 18:17:47 +00:00
|
|
|
# Create the required input file if needed.
|
|
|
|
FILE=$1
|
|
|
|
case $FILE in
|
|
|
|
compress_generated_*)
|
|
|
|
if ./create_compress_files "${FILE#compress_generated_}" ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
rm -f "$FILE"
|
|
|
|
echo "Failed to create the file '$FILE'."
|
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
'')
|
|
|
|
echo "No test file was specified."
|
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Derive temporary filenames for compressed and uncompressed outputs
|
|
|
|
# from the input filename. This is needed when multiple tests are
|
|
|
|
# run in parallel.
|
|
|
|
TMP_COMP="tmp_comp_${FILE##*/}"
|
|
|
|
TMP_UNCOMP="tmp_uncomp_${FILE##*/}"
|
2008-01-17 22:50:29 +00:00
|
|
|
|
|
|
|
# Remove temporary now (in case they are something weird), and on exit.
|
2022-05-23 18:17:47 +00:00
|
|
|
rm -f "$TMP_COMP" "$TMP_UNCOMP"
|
|
|
|
trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0
|
2008-01-17 22:50:29 +00:00
|
|
|
|
2022-05-23 18:17:47 +00: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 22:50:29 +00:00
|
|
|
|
2022-05-23 18:17:47 +00:00
|
|
|
for ARGS in \
|
|
|
|
--delta=dist=1 \
|
|
|
|
--delta=dist=4 \
|
|
|
|
--delta=dist=256 \
|
|
|
|
--x86 \
|
|
|
|
--powerpc \
|
|
|
|
--ia64 \
|
|
|
|
--arm \
|
|
|
|
--armthumb \
|
|
|
|
--sparc
|
|
|
|
do
|
|
|
|
test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
|
2008-01-17 22:50:29 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
(exit 0)
|
|
|
|
exit 0
|