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."
32 if $LZMA -c "$@" "$FILE" > tmp_compressed; then
35 echo "Non-streamed compressing failed: $* $FILE"
40 if $LZMA -cd tmp_compressed > tmp_uncompressed ; then
43 echo "Decoding of non-streamed file failed: $* $FILE"
48 if cmp tmp_uncompressed "$FILE" ; then
51 echo "Decoded non-streamed file does not match the original: $* $FILE"
56 if $LZMADEC tmp_compressed > tmp_uncompressed ; then
59 echo "Decoding of non-streamed file failed: $* $FILE"
64 if cmp tmp_uncompressed "$FILE" ; then
67 echo "Decoded non-streamed file does not match the original: $* $FILE"
76 if $LZMA -c "$@" < "$FILE" > tmp_compressed; then
79 echo "Streamed compressing failed: $* $FILE"
84 if $LZMA -cd < tmp_compressed > tmp_uncompressed ; then
87 echo "Decoding of streamed file failed: $* $FILE"
92 if cmp tmp_uncompressed "$FILE" ; then
95 echo "Decoded streamed file does not match the original: $* $FILE"
100 if $LZMADEC < tmp_compressed > tmp_uncompressed ; then
103 echo "Decoding of streamed file failed: $* $FILE"
108 if cmp tmp_uncompressed "$FILE" ; then
111 echo "Decoded streamed file does not match the original: $* $FILE"
117 echo . | tr -d '\n\r'
120 LZMA="../src/lzma/lzma --memory=15Mi --threads=1"
121 LZMADEC="../src/lzmadec/lzmadec --memory=4Mi"
124 # Create the required input files.
125 if ./create_compress_files ; then
129 echo "Failed to create files to test compression."
134 # Remove temporary now (in case they are something weird), and on exit.
135 rm -f tmp_compressed tmp_uncompressed
136 trap 'rm -f tmp_compressed tmp_uncompressed' 0
138 # Encode and decode each file with various filter configurations.
139 # This takes quite a bit of time.
140 echo "test_compress.sh:"
141 for FILE in compress_generated_* "$srcdir"/compress_prepared_*
143 MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
144 echo " $MSG" | tr -d '\n\r'
146 # Don't test with empty arguments; it breaks some ancient
147 # proprietary /bin/sh versions due to $@ used in test_lzma().
157 --subblock=size=1,rle=1 \
158 --subblock=size=1,rle=4 \
159 --subblock=size=4,rle=4 \
160 --subblock=size=8,rle=4 \
161 --subblock=size=8,rle=8 \
162 --subblock=size=4096,rle=12 \
165 --delta=distance=256 \
174 test_lzma --subblock $ARGS
175 test_lzma $ARGS --subblock
176 test_lzma --subblock $ARGS --subblock