2008-01-17 17:50:29 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
#
|
2009-04-13 04:27:40 -04:00
|
|
|
# Author: Lasse Collin
|
2008-01-17 17:50:29 -05:00
|
|
|
#
|
2009-04-13 04:27:40 -04:00
|
|
|
# This file has been put into the public domain.
|
|
|
|
# You can do whatever you want with this file.
|
2008-01-17 17:50:29 -05: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 16:52:24 -05:00
|
|
|
test_xz() {
|
|
|
|
if $XZ -c "$@" "$FILE" > tmp_compressed; then
|
2008-01-17 17:50:29 -05:00
|
|
|
:
|
|
|
|
else
|
2008-06-18 11:02:10 -04:00
|
|
|
echo "Compressing failed: $* $FILE"
|
2008-01-17 17:50:29 -05:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-11-19 16:52:24 -05:00
|
|
|
if $XZ -cd tmp_compressed > tmp_uncompressed ; then
|
2008-01-17 17:50:29 -05:00
|
|
|
:
|
|
|
|
else
|
2008-06-18 11:02:10 -04:00
|
|
|
echo "Decoding failed: $* $FILE"
|
2008-01-17 17:50:29 -05:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if cmp tmp_uncompressed "$FILE" ; then
|
|
|
|
:
|
|
|
|
else
|
2008-06-18 11:02:10 -04:00
|
|
|
echo "Decoded file does not match the original: $* $FILE"
|
2008-01-17 17:50:29 -05:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-11-19 16:52:24 -05:00
|
|
|
if $XZDEC tmp_compressed > tmp_uncompressed ; then
|
2008-01-17 17:50:29 -05:00
|
|
|
:
|
|
|
|
else
|
2008-06-18 11:02:10 -04:00
|
|
|
echo "Decoding failed: $* $FILE"
|
2008-01-17 17:50:29 -05:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if cmp tmp_uncompressed "$FILE" ; then
|
|
|
|
:
|
|
|
|
else
|
2008-06-18 11:02:10 -04:00
|
|
|
echo "Decoded file does not match the original: $* $FILE"
|
2008-01-17 17:50:29 -05:00
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Show progress:
|
|
|
|
echo . | tr -d '\n\r'
|
|
|
|
}
|
|
|
|
|
2010-08-10 04:04:30 -04:00
|
|
|
XZ="../src/xz/xz --memlimit-compress=28MiB --memlimit-decompress=4MiB \
|
|
|
|
--no-adjust --threads=1 --check=crc64"
|
|
|
|
XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
|
2008-01-17 17:50:29 -05:00
|
|
|
|
|
|
|
# Create the required input files.
|
|
|
|
if ./create_compress_files ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
rm -f compress_*
|
|
|
|
echo "Failed to create files to test compression."
|
|
|
|
(exit 1)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove temporary now (in case they are something weird), and on exit.
|
|
|
|
rm -f tmp_compressed tmp_uncompressed
|
|
|
|
trap 'rm -f tmp_compressed tmp_uncompressed' 0
|
|
|
|
|
|
|
|
# Encode and decode each file with various filter configurations.
|
|
|
|
# This takes quite a bit of time.
|
|
|
|
echo "test_compress.sh:"
|
|
|
|
for FILE in compress_generated_* "$srcdir"/compress_prepared_*
|
|
|
|
do
|
|
|
|
MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
|
|
|
|
echo " $MSG" | tr -d '\n\r'
|
|
|
|
|
|
|
|
# Don't test with empty arguments; it breaks some ancient
|
2008-11-19 16:52:24 -05:00
|
|
|
# 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 17:50:29 -05:00
|
|
|
|
2008-12-31 11:59:02 -05:00
|
|
|
# Disabled until Subblock format is stable.
|
|
|
|
# --subblock \
|
|
|
|
# --subblock=size=1 \
|
|
|
|
# --subblock=size=1,rle=1 \
|
|
|
|
# --subblock=size=1,rle=4 \
|
|
|
|
# --subblock=size=4,rle=4 \
|
|
|
|
# --subblock=size=8,rle=4 \
|
|
|
|
# --subblock=size=8,rle=8 \
|
|
|
|
# --subblock=size=4096,rle=12 \
|
2009-01-19 15:37:16 -05:00
|
|
|
#
|
2008-01-17 17:50:29 -05:00
|
|
|
for ARGS in \
|
2008-09-27 16:13:54 -04:00
|
|
|
--delta=dist=1 \
|
|
|
|
--delta=dist=4 \
|
|
|
|
--delta=dist=256 \
|
2008-01-17 17:50:29 -05:00
|
|
|
--x86 \
|
|
|
|
--powerpc \
|
|
|
|
--ia64 \
|
|
|
|
--arm \
|
|
|
|
--armthumb \
|
|
|
|
--sparc
|
|
|
|
do
|
2008-11-19 16:52:24 -05:00
|
|
|
test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
|
2009-01-19 15:37:16 -05:00
|
|
|
|
2008-12-31 11:59:02 -05:00
|
|
|
# Disabled until Subblock format is stable.
|
|
|
|
# test_xz --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
|
2008-01-17 17:50:29 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
(exit 0)
|
|
|
|
exit 0
|