3 ###############################################################################
5 # Copyright (C) 2008 Lasse Collin
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 ###############################################################################
19 # Find out if our shell supports functions.
20 eval 'unset foo ; foo() { return 42; } ; foo'
21 if test $? != 42 ; then
22 echo "/bin/sh doesn't support functions, skipping this test."
28 if $LZMA -c "$@" "$FILE" > tmp_compressed; then
31 echo "Compressing failed: $* $FILE"
36 if $LZMA -cd tmp_compressed > tmp_uncompressed ; then
39 echo "Decoding failed: $* $FILE"
44 if cmp tmp_uncompressed "$FILE" ; then
47 echo "Decoded file does not match the original: $* $FILE"
52 if $LZMADEC tmp_compressed > tmp_uncompressed ; then
55 echo "Decoding failed: $* $FILE"
60 if cmp tmp_uncompressed "$FILE" ; then
63 echo "Decoded file does not match the original: $* $FILE"
72 # TODO: Remove --format=xz once the command name has been changed.
73 LZMA="../src/lzma/lzma --memory=15Mi --threads=1 --format=xz"
74 LZMADEC="../src/lzmadec/lzmadec --memory=4Mi"
77 # Create the required input files.
78 if ./create_compress_files ; then
82 echo "Failed to create files to test compression."
87 # Remove temporary now (in case they are something weird), and on exit.
88 rm -f tmp_compressed tmp_uncompressed
89 trap 'rm -f tmp_compressed tmp_uncompressed' 0
91 # Encode and decode each file with various filter configurations.
92 # This takes quite a bit of time.
93 echo "test_compress.sh:"
94 for FILE in compress_generated_* "$srcdir"/compress_prepared_*
96 MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
97 echo " $MSG" | tr -d '\n\r'
99 # Don't test with empty arguments; it breaks some ancient
100 # proprietary /bin/sh versions due to $@ used in test_lzma().
109 --subblock=size=1,rle=1 \
110 --subblock=size=1,rle=4 \
111 --subblock=size=4,rle=4 \
112 --subblock=size=8,rle=4 \
113 --subblock=size=8,rle=8 \
114 --subblock=size=4096,rle=12 \
125 test_lzma $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
126 test_lzma --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast